ronaldlam / Autotrageur

Automated arbitrageur
2 stars 1 forks source link

Arbitrage: Add 5% crypto balance buffer notification to signal need for additional deposits. #174

Closed ronaldlam closed 6 years ago

ronaldlam commented 6 years ago

To ensure we don't hit the InsufficientCryptoBalance error, we should target having a 20% crypto buffer on both exchanges to start with. If it ever decreases to less than 5%, we a notification should be sent to notify the operators.

Add a conditional in __prepare_trade to ensure that the buffer room is >5%.

Proposal Once the buffer threshold has been breached, we will have the bot update_wallet_balances every poll to ensure that any action to increase the buffer room (e.g. deposit crypto, or place limit order) will be reflected ASAP. We then turn off the update_wallet_balances once the threshold is back above 5%.

Post implementation attempt revision The contents of __prepare_trade are the last line of defence before trade execution, and doesn't happen unless there is a hit target. The check should be done in _poll_opportunity since we immediately know the balances to start and the new information needed is only the pricing. The check, notifications and updates can all happen before trade execution does. If we go with this, we don't know the specifics of the trade amount, and can only notify whether we have the crypto balance to support a fully trade from one exchange to the other.

I believe this is the way to go since this part would only serve notification purposes. We can retain the check with the error later on, and have the bot email us with a 1h cooldown while the balance is still below the threshold.