cryptoeax / arbbot

Arbitrator, a bitcoin/altcoin arbitrage trading bot
https://gitter.im/cryptoeax-arbbot/Lobby
GNU General Public License v3.0
199 stars 78 forks source link

Liquidation somehow tries to over-liquidate an altcoin (more than the existing balance) #62

Open Exalovic opened 6 years ago

Exalovic commented 6 years ago

The liquidation module is run after the balance module has run, this leads to situations where the bot tries to liquidate coins based on balances that are wierd due to the rebalancing done by the balance module.

Additionally the bot sees the pending deposit on bittrex as part of the wallet and tries to sell the amount which is incomming to the exchange resulting in an error. On poloniex the bot tries to sell the balance without considering that it has tried to withdraw from a coin it has just placed a transfer on leading again to a error due to insufficient funds.

I propose that the order of the liquidation module and balance module are switched to mitigate this issue

cryptoeax commented 6 years ago

Switching the order of these phases achieves nothing in practice, since no matter what order we run this in, when the liquidation phase starts to run, there can be any number of pending deposits and withdrawals in progress, so it just needs to correctly deal with them.

The reason behind the difference you see between Poloniex and Bittrex right now is #50. The code here tries to get the wallet balances considering any pending deposits that are currently in flight, but that code doesn't currently work well for Poloniex, so you see this problem mostly on Bittrex. :-) I agree that we should change that code to only care about the actual balance at the liquidation time... That should be a very simple change to make.

Perhaps that would be the only change that's needed here?

cryptoeax commented 6 years ago

e4918e4 implements the change I mentioned above.