chrisleekr / binance-trading-bot

Automated Binance trading bot - Trade multiple cryptocurrencies. Buy low/sell high with Grid Trading. Integrated with TradingView technical analysis
MIT License
5k stars 1.09k forks source link

Bot regularly hangs after sell #519

Closed eppenga closed 1 year ago

eppenga commented 1 year ago

Thank you for bringing this great bot to the community!

I noticed that the bot regularly hangs after a sell. What I mean with that once a sell for a symbol is successful the bot keeps repeating the message "There is a last gird trade sell order. Wait." and stops operating. It does not recognize that the sell order did go through on Binance. Once the bot restarts (I restart every hour via a Cron job), this issue is resolved. The bot then recognizes that the sell went through at Binance and continues normal operation (also the message "There is a last gird trade sell order. Wait.") disappears.

Here you see at 17:37:02.333 the message "There is a last gird trade sell order. Wait." for the first time: image

However at 17:36:34 the sell did occur on Binance. image

Here is the log entry for 17:37:02.333: image

The ID of that log file entry is: 633ef61e3c66ce88ec585a2c

Here you after the restart is performed via the Cron job (hourly so at 18:00) that the bot recognizes the sell occured on Binance and resumes normal operation: image

Attached for reference is the log file: ATOMBUSD-2022-10-06-18-10-45.zip

Hope you can fix it! Thanks a lot!

habibalkhabbaz commented 1 year ago

Hello @eppenga

I didn't check the log yet, but from the first look I can assume that the problem with the WebSocket. For some reason, you didn't receive the order update from the WebSocket.

This is just an assumption, I will check the log when I have time to debug this.

habibalkhabbaz commented 1 year ago

@eppenga Can you provide more info or another screenshot for the order on Binance so I can see when the order updated and executed?

eppenga commented 1 year ago

@habibalkhabbaz yes, will do tonight, I am currently traveling. Many thanks in advance.

eppenga commented 1 year ago

@habibalkhabbaz please see below some screenshots from the order history. It is a Binance sub account so it has no graphs. What you can see is that before the sell at "2022-10-06 17:26:37" you see two cancelled sell orders.

image image

Hope this helps, please let me know if you need anything else.

eppenga commented 1 year ago

Maybe this also helps, it is a graph via Cryptowat.ch. You can see the sell at "2022-10-06 17:26:37" also there.

image

habibalkhabbaz commented 1 year ago

Hello @eppenga

Thanks for the info. As I expected, for some reason, you didn't receive any update from the WebSocket for the order ID: 510442524 (The order that you have problem with) But still I didn't figure out the exact reason. Maybe connection issues? To move on, do you use slack for notifications? If yes, do you see any message like the following?

Uncaught Exception: If you see this, kindly report it to: https://github.com/chrisleekr/binance-trading-bot/issues/new?assignees=&labels=bug&template=bug_report.md&title= Code: ....

It can be seen in the Docker container logs as well if you don't have slack.

eppenga commented 1 year ago

Hello @habibalkhabbaz ,

Yes indeed I use slack and these are the last few error messages I see:

image

image

image

image

eppenga commented 1 year ago

FYI just tried to login to the bot and all it does now is show a black screen with that it is connected. I can see from the activity on Binance that it is still running. A bit unfortunate as it handling quite some symbols.

image

habibalkhabbaz commented 1 year ago

FYI just tried to login to the bot and all it does now is show a black screen with that it is connected. I can see from the activity on Binance that it is still running. A bit unfortunate as it handling quite some symbols.

image

Hello @eppenga

I submit a PR to solve that, #521

habibalkhabbaz commented 1 year ago

Hello @habibalkhabbaz ,

Yes indeed I use slack and these are the last few error messages I see:

image

image

image

image

Yes, these are the reasons that keep your bot stops working at some point. I am going to submit another PR to partially solve this and let's see how it goes.

eppenga commented 1 year ago

FYI just tried to login to the bot and all it does now is show a black screen with that it is connected. I can see from the activity on Binance that it is still running. A bit unfortunate as it handling quite some symbols. image

Hello @eppenga

I submit a PR to solve that, #521

Thanks! Will test it asap and let you know!

eppenga commented 1 year ago

FYI just tried to login to the bot and all it does now is show a black screen with that it is connected. I can see from the activity on Binance that it is still running. A bit unfortunate as it handling quite some symbols. image

Hello @eppenga

I submit a PR to solve that, #521

Hi @habibalkhabbaz

Many thanks for your help and sorry to keep bugging you!

Just pulled the last release, restarted the docker containers and since the black screen remained I restarted the whole raspberry pi just to be sure, but I still have the black screen.

This is what I did (it's running on a raspberry pi):

cd ~/binance-trading-bot/ git pull docker-compose -f docker-compose.rpi.yml pull docker-compose -f docker-compose.rpi.yml up -d Check if the black screen is gone, no docker restart binance-bot docker restart tradingview Check if the black screen is gone, no docker restart binance-redis docker restart binance-mongo Check if the black screen is gone, no restart the raspberry pi Check if the black screen is gone, no test in an incognito browser Check if the black screen is gone, no

habibalkhabbaz commented 1 year ago

Hello @eppenga

Kindly check if your version is equal to the latest version v0.0.92 which is just released. Also, if you can get the console log from the browser so we see the errors

chrisleekr commented 1 year ago

merged.

Thanks, @habibalkhabbaz for the fix.

habibalkhabbaz commented 1 year ago

Thanks! @chrisleekr


@eppenga the issue closed as per the pull request but feel free to update this issue if you still experience issues

eppenga commented 1 year ago

Hello @eppenga

Kindly check if your version is equal to the latest version v0.0.92 which is just released. Also, if you can get the console log from the browser so we see the errors

Hi @chrisleekr ,

The frontend is back, thank you! I just pulled it again and now it is running again. A bit odd, because it was already at v0.0.92 as you can see: From https://github.com/chrisleekr/binance-trading-bot 200a781..2a592e1 master -> origin/master

Presume this is what you mean with the console log, it looks happy to me: image

Kind regards, Ebo

habibalkhabbaz commented 1 year ago

Happy to hear that @eppenga! The other issue should be also solved when @chrisleekr releases the last pull request.

eppenga commented 1 year ago

Just for fun, inspired by the timeouts I thought I replace the Wifi with a more stable cable ethernet connection and added a simple switch to our network which now goes directly to the raspberry pi running the bot :)

image

habibalkhabbaz commented 1 year ago

Sure, it will be more stable @eppenga Happy trading!

eppenga commented 1 year ago

Based on my experience I would like to add a few notes which might be handy for the general documentation as well. In the past I saw many errors via Slack, especially redlocks. What I noticed is that when you run the bot on a more powerful machine and have stable ethernet connection (no wifi, it will cause issues with the websocket streams) the errors will start to disappear. Also in my case the restart via a cronjob is necessary. I am error free :)