ctubio / tribeca

Self-hosted crypto trading bot (automated high frequency market making) in node.js, angular, typescript and c++
https://127.0.0.1:3000
Other
95 stars 26 forks source link

OkCoin (+Coinbase) Too many orders sent and/or not cancelled #92

Closed Camille92 closed 7 years ago

Camille92 commented 7 years ago

Hello everyone,

I'm still investigating this issue but what I can say is that OkCoin doesn't properly cancel some orders that stay stock on the market.

I'm using OkCoin with "boomerang" and the cxl option activated.

It was working fine before so I guess something happened with a new update! capture d ecran 2017-05-22 a 15 01 15

Camille92 commented 7 years ago

It might be on all exchanges as I found this poor guy not canceled on BTC/EUR at Coinbase! capture d ecran 2017-05-22 a 15 13 32

Could that come from this update?

https://github.com/ctubio/tribeca/commit/2a49c9e491bd476544f7f780b519296480b8cd95

Camille92 commented 7 years ago

Is does seem to be very rare on Coinbase but still happen, not happening on Bitfinex and happening a lot in OkCoin!

I'll try to bring you some logs later :)

ctubio commented 7 years ago

ima leave this here https://github.com/coinbase/gdax-node/issues/25, but but but i think we dont use stop orders xD

Camille92 commented 7 years ago

Well for Coinbase it's not that big of an issue it gets cancelled at some point and it's very rare.

But for OkCoin it becomes soon untradable (as all the funds are allocated to past buy or sell orders). I'm going to make some tests!

zachaller commented 7 years ago

I think I am also getting this on Coinbase I will have orders that are stuck on the coinbase dashboard that are 20+ min old and I have cxl checked which i would have though would have cleaned those up. They build up pretty quick for me

ctubio commented 7 years ago

for me OkCoin is canceling orders too fast i think, so ima go for another fix

Camille92 commented 7 years ago

I don't have the same issue, what makes you say that?

ctubio commented 7 years ago

cos im not able to see any order while delayUI=0, if i increase it i see an order every now and then; is OkCoin working nice for you?

Camille92 commented 7 years ago

I updated to the last version and I'm quite sure that the new formula is breaking OkCoin again.

But not as much as last time: Orders are not always canceled but get canceled by the 'cxl' option!

Imho you should go back to this version ;) generateClientOrderId = (): string => parseInt((Math.random()+'').substr(-8), 10).toString();

ctubio commented 7 years ago

the problem may be somewhere else, still investigating, cos both are equal: parseInt((Math.random()+'').substr(-8), 10).toString(); new Date().valueOf().toString().substr(-8);

if i use the Math.random solution orders are not always canceled too

Camille92 commented 7 years ago

I find that very surprising because 'Math random' works perfectly for me. OkCoin has a quite weird website that doesn't always suppress the canceled orders from the web UI if you don't refresh the page.

Here is how I determined that something went wrong: I let run tribeca with the cancel option off for 5-10mn.

When I come back I go to OkCoin website look at the orders. For all formulas, I have an abnormal number of them but when I refresh the page, I have the correct number or orders with Math random but not with the other formulas!

ctubio commented 7 years ago

i put the old Math.random, that returns 8 chars like Date, so im sure we fixed nothing :S

ctubio commented 7 years ago

anyway lets test it, if this fixes something, means that OkCoin orderIds are shared between clients, so we need trully random ids, not incremental based on Date (like someone else may be doing also [having incremental ids is what i was looking for])

Camille92 commented 7 years ago

Haha, I can't say why but I can say that it works :)

OkCoin moves in mysterious ways.

ctubio commented 7 years ago

:sunflower: again, many thanks for your helpful patience Camille'¡

Camille92 commented 7 years ago

Hello Carles,

You were saying that OkCoin was weird, well I've been experiencing the same issue.

I'm suspecting that orders are canceled too quickly so we have a lot of time not in the market!

ctubio commented 7 years ago

im not sure if is because market changes or because other reason, for me seems most of the time OK but some times OkCoin is canceling orders in the very next millisecond of creation, i will review it some day when migrating the gateway to c++ (once i recover from so many gateway fights)

Camille92 commented 7 years ago

Yes, I don't know what that is but I might leave OkCoin out for now, or look for a fix.

Because (I realized that during the correction), on Okcoin Tribeca struggles a lot to get rid of position! (even with APR on).

ctubio commented 7 years ago

oh well i moved it to https://github.com/ctubio/tribeca/issues/109