Closed sfkiwi closed 4 years ago
Using your initial investigation I was able to patch my Trader.js with a stable fix for this, the algorythm for the fix is as follows:
--On finalized or executed messages if the getOrder(id) == null then we have a message arrived before the placed confirmation --add these orphaned messages to a history/array/set etc being careful with memory (ie, history queue with max size to avoid leaks) --onOrderPlaced/confirmed add order to myBook and check the orphans history for any matching the id of the trade you just placed --if orphans found remove from orphans and re-play the message through the trader which will close/execute correctly now against the id of the order confirmation
I'll leave the actual code up to you, but this short term memory approach of seems to work pretty solidly for orphaned complete/filled messages.
Happy Coding!
Update: with this fix in place I believe the unfilledMarketOrders code can be completely removed also, since if we're tracking and handling orphan messages the order type does not matter.
Nice fix. I’d say this is a bug. Why don’t you consider doing a PR to master?
When I get some time i'll look into doing this properly with a PR but atm my gdax-tt is heavily patched with this and other fixes so it would take time to arrange them all :-( any other issues that come up on here I'm happy to help with. Will keep an eye out :-)
@LikeTheWolf Is your repo public? Mine is heavily modded at this point as well although not currently public. Did you get a 1099-k from Coinbase this year?
Nope not currently public, and as far as I know 1099-k is only for US-based customers so havent had to deal with that :+1:
On Tue, Feb 19, 2019 at 4:36 PM Mike Sutherland notifications@github.com wrote:
@LikeTheWolf https://github.com/LikeTheWolf Is your repo public? Mine is heavily modded at this point as well although not currently public. Did you get a 1099-k from Coinbase this year?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/coinbase/gdax-tt/issues/239#issuecomment-465208842, or mute the thread https://github.com/notifications/unsubscribe-auth/AtkB_jmCytFgQKjVpko32EC6ptUIcT9Wks5vPCf3gaJpZM4UjTmS .
Hi, we are closing out PRs + Issues as this project is being archived.
I have spent many hours trying to debug why I sometimes don't get a tradeExecuted and sometimes not even a tradeFinalized message on a successful order. As best I can tell the Exchange just isn't sending it sometimes. Has anyone else had trouble with this?
My understanding is that, for example if you send a PlaceOrderMessage for a market buy order you should ALWAYS get at least one tradeExecuted message and exactly one tradeFinalized Message (if the trade executes on the exchange).
There are race conditions where the tradeFinalized arrives ahead of the tradeExecuted message but even if I wait, it never arrives. I haven't been able to determine yet whether the message is getting blocked somewhere between the websocket connection and me or whether the message is just never being sent.
Even knowing that this is not a problem for other would at least let me know that its a problem with my code. If its a known problem then how are you overcoming this? I would like to keep track of my trade history and not receiving these messages makes the workaround very awkward.
Update: I traced the source of the problem to the Trader.ts which I am using. The problem happens because the Trader updates the unfilledOrders hash after receiving the MyOrderPlaced ('open') message. If the TradeExecuted ('match') message arrives before the response from the server (gdax-node -> placeOrder) then the order has not been added to the unfilled orders table and hence is ignore and no TradeExecuted event is emitted by the Trader. This (the 'match' message arriving first) actually occurs quite frequently.