- ago
I was running a crypto strategy today with position sync enabled, and it did not sell 100% of my position, more like 90%. No errors or warnings occurred at any time.

Log file: https://www.dropbox.com/s/z2z42dq7dud0q33/error_coinbase_position_sync.txt?dl=0



0
543
Solved
18 Replies

Reply

Bookmark

Sort
Cone8
 ( 28.25% )
- ago
#1
All the canceled limit orders were for the correct amount. Can you find the WealthLab order with the lower amount in the Order Manager?

Wow, those are pretty hefty fees (these days) for those trades.
0
- ago
#2
Darn, my mistake -- I see that the sell is missing from the screenshot. I no longer have the history in the Order Manager to go back and check.

From what I recall, it attempted to sell at the full (correct) amount, but there was a message that "Quantity adjusted to Sync with size of Position", which gave the impression that it was unnecessarily adjusting the quantity.

I also believe the final sell order was marked as "Canceled" rather than "Filled". But I understand this is of limited use without the associated screenshot. I will try and get better records if it happens again.
0
Cone8
 ( 28.25% )
- ago
#3
"Quantity adjusted to Sync with size of Position" will (should) always appear for exit orders when you have one of those Portfolio Sync preferences selected.

When you took the screenshot, was the position already sold? I'm asking because the Accounts tool shows the full position still in the account... although the Basis price displayed seems off.
0
- ago
#4
When I took the screenshot, the position was 90% sold. This can be verified in the screenshot from the Coinbase website, with the 5:36 PM timestamp. The screenshot from my desktop was 6:25 PM. Shortly after taking that screenshot, I manually sold the remaining 10% of the position.

Is it possible that a limit order was partially filled?

The basis price has never displayed correctly for me, though I've always dismissed it as a display bug in the Accounts panel, as it hasn't seemed to cause any problem in the past. But it's true that it still shows the full position, as though it's not aware of the sale that took place 50 minutes previous.
0
Cone8
 ( 28.25% )
- ago
#5
That's probably it - a partial fill that led to a cancel. The partially filled shares should have been updated, but it's an extremely likely possibility that price touched the limit, your order partially filled, and then the end of a 1-minute interval occurred before the rest of the shares were filled. At this point, the strategy declares the position sold (price attained the limit) and goes back to the entry logic, so existing orders are canceled.

This kind of thing could happen at any scale, but it's more probable when using shorter intervals with large orders. There is a possible [C# code] solution that we've floated in another thread - Strategies can check on the BrokerPosition to keep a limit exit order active for the number of shares reported. See https://www.wealth-lab.com/Discussion/Access-Accounts-data-from-broker-programmatically-7914 starting from Post #18

Re: Basis
I'm not sure why it's programmed this way, but the Coinbase basis price is just a current quote when the BrokerPosition is created (read: it's not really the basis price). Maybe that can be improved when the Coinbase Advanced Trade API is in place.
1
Cone8
 ( 28.25% )
- ago
#6
Actually, that BrokerPosition solution would be very complicated to use in a Strategy. The solution will be this new Portfolio Sync feature that Glitch activated to work on recently -
https://www.wealth-lab.com/Discussion/Portfolio-Sync-Use-Live-Positions-8912
1
- ago
#7
Understood, thank you for the clarification. Much appreciated!
0
- ago
#8
QUOTE:
That's probably it - a partial fill that led to a cancel.

Partial fills continue to result in errors for me, and unfortunately I haven't been able to use the new Portfolio Sync feature because of the inaccurate position data shown in the Accounts panel. Is there perhaps another way of tackling the issue?

An example that just happened:
1) Market Buy was placed, but only about half the total quantity was filled. WL8 displays "Canceled" for the order status
2) Later, the strategy submits a corresponding Market Sell, and WL8 displays "Error: Could not find a matching Position to exit"

End result is that I'm left with this half filled position that WL8 doesn't know about and never gets sold.
0
Glitch8
 ( 12.08% )
- ago
#9
We are 100% requesting position updates from the broker when a partial fill occurs, I just double checked even. I can't say why the correct positions aren't being reflected for Kucoin, maybe it has something to do with a partial fill, but it looks like their API is not returning proper information when this is the case.
0
Glitch8
 ( 12.08% )
- ago
#10
Do you think it would help to simply allow all exit orders to proceed, bypassing any kind of position check? We could add a config preference to Kucoin to enable this kind of behavior.
0
- ago
#11
QUOTE:
Do you think it would help to simply allow all exit orders to proceed, bypassing any kind of position check?

Yes, definitely.

QUOTE:
We could add a config preference to Kucoin

The above example happened in Coinbase, though I know it's no longer supported. Would it be possible for the preference to be global, rather than tied to a specific extension?

My only fear is that the exit order might still fail if WL8 doesn't know the correct quantity. When this issue has happened in the past, it seems like WL8 is unaware of the position details until I manually press "Request Updates from Broker(s)".
0
Glitch8
 ( 12.08% )
- ago
#12
Yes let’s make it a new Trading Preference.
1
Best Answer
Glitch8
 ( 12.08% )
- ago
#13
Check for the new Trading Preference now in Build 32, it's enabled by default, but you can disable it and let us know if it helps!
1
- ago
#14
Thank you for adding this new preference, I have been running my strategies with it disabled and anecdotally, I do feel like it has reduced the number of errors I encounter.

However, I still run into errors that seem related to partial fills. Note the following example:



The Buy order for ALEPH-USD is reported as "canceled", but this isn't actually true. Part of the order was filled. Then when the Sell order was issued, it results in an Error because of "Insufficient funds". But that is also not completely true, because I possessed *some* ALEPH-USD at that time, from the previous partial fill, and I was hoping that having "Block Exit Orders when Position not found" disabled would handle that.

But alas, nothing gets sold at all, and I have to later go manually issue a sell order. All of this difficulty can be avoided if I happen to be around to notice the "Canceled" buy order, and simply press "Request Update from Broker(s)". If I do that, then everything from that point forward will work correctly.

Is there any way I can execute the functionality of the "Request Update" button by calling a particular function in a coded version of the strategy?
0
Glitch8
 ( 12.08% )
- ago
#15
No, there's currently no way to invoke that.

Question: Do you have the option to "Reduce Exit Size based on Position Quantity" enabled?

0
- ago
#16
Yes, I do. Here's an overview of the preferences I use for everything, in case any other settings might be relevant:

0
Glitch8
 ( 12.08% )
- ago
#17
Ok let me work on the partial fill for entries. Should be able to improve this for next release.
1
Glitch8
 ( 12.08% )
- ago
#18
Update, after a thorough check I see we actually are creating the position on the partial entry fill, and even requesting an update from the broker on partial fills, this is the same as pressing the "Update" button that you referenced above. I can't see that we can do anything more here. I can only suppose that in this particular case the broker's API experienced some latency in returning the correct position information.
0

Reply

Bookmark

Sort