tudorelu / pyjuque

⚡ Open Source Algorithmic Trading Bot for Python.
MIT License
456 stars 90 forks source link

Balance & Selling manually caused pyjuque notification messages non-stop #29

Closed hlford closed 2 years ago

hlford commented 2 years ago

Describe the bug

I added more funds in the exchange but pyjuque didn't notice because it's still using the starting/current balance from the database instead letting me update the balance: INFO:pyjuque.Engine.BotController:Error placing order <class 'ccxt.base.errors.InsufficientFunds'>

I manually sold the coin on the market. But pyjuque didn't notice it and kept on trying to access the record in the database and notify about it. Is there any to get rid of the old/expired records in the database? INFO:pyjuque.Engine.BotController:Error getting data from the exchange for updating open order

tudorelu commented 2 years ago

I know this is not ideal but right now the fix would be updating the bot's current_balance entry in the database manually.

I'm currently doing some massive reworking to this library, changing the code base - so in the new code I will avoid this issue, but I'm not sure I will fix it in the current codebase (the one you're using now). If you have the time / will, free to make a pull request that fixes it and I will merge it.

The fix would be as simple as checking that the balance on the exchange is greater than or equal to the bot's current balance. If it is, then good, but if not - update the bot's balance to be equal to the one displayed on the exchange.

hlford commented 2 years ago

I'm still learning python and right now I just avoid selling manually so it doesn't get confused. My main focus it's adjusting the startup, I haven't peeked too deep into the BotController yet because the controller codes are quite stable. I'm still trying to figure out and fix the startup to see if I can add some delays when the bot gets too busy, so it won't "forget" to update the order/pair since there's no "self-cleanup" routine yet: <class 'ccxt.base.errors.OrderNotFound'> kucoin order not exist. <traceback object at 0x7fb1eb4200> INFO:pyjuque.Engine.BotController:Error getting data from the exchange for updating open order