9homme / awesome-bot

My simple awesome bot for crypto trading using Binance Futures API
3 stars 3 forks source link

msg["k"]["t"] / 1000.0 problem #3

Closed concu72 closed 1 year ago

concu72 commented 1 year ago

``Waiting for next closed Some error occured but just skip, message: 'k' Traceback (most recent call last): File "C:\Users\Administrator\Desktop\awe\main.py", line 28, in handle_socket_message msg["k"]["t"] / 1000.0, timezone.utc KeyError: 'k'

I am running the bot on VPS Server. I get this error from time to time and realize that the bot has stopped. Sometimes I encounter the same error 3-4 times in a day. I could not understand that the reason for the error is because it exceeds the limit of 1000 api requests per minute on the Binance exchange. When I change the value from 1000 in main.py line 28 to 900, the bot does not work at all. Do I need to change the bot's api request limit elsewhere?

Binance exchange bans more than 1000 API requests per minute.

Could this be the cause of the bot's error?

9homme commented 1 year ago

1000 is to convert millisecond to second , so it should not be change from 1000 to any value. Actually, at line 28 we not calling to binance but just receive websocket message from binance.

Can you try change line 46 from

print(f"Some error occured but just skip, message: {str(e)}")

to

print(f"Some error occured but just skip, message: {msg}, error: {str(e)}")

and see what is the message from binance that we got at that time ?

concu72 commented 1 year ago

I'll try this and let you know.

My VPS server was on France Paris. In the searches I made with Google, there were people who had similar problems in different bots due to the French UTC. So I was trying to move my VPS server to a different country location right now. I'll let you know by trying what you wrote. Thank you for your interest.

concu72 commented 1 year ago

I haven't shut down my France VPS server yet. I will try what you said first to determine the cause of the error.

9homme commented 1 year ago

Do you also have this issue running the bot in your local machine ?

concu72 commented 1 year ago

I edited line 46 in the main.py file as you said and ran it again in the morning. I just realized that the boat has stopped again. The error it gives is as follows:

2023-02-22 08:39:56.745541 ETCUSDT 2023-02-22 07:30:00 Latest price = 22.422 already processed. Waiting for next closed Some error occured but just skip, message: {'e': 'error', 'm': 'Queue overflow. Message not filled'}, error: 'k' Traceback (most recent call last): File "C:\Users\Administrator\Desktop\awe\main.py", line 28, in handle_socket_message msg["k"]["t"] / 1000.0, timezone.utc KeyError: 'k'

1

concu72 commented 1 year ago

Botu yerel makinenizde çalıştırırken de bu sorunu yaşıyor musunuz?

I don't know as I haven't run it that long on my computer. Maybe the problem is caused by the VPS server, I'm thinking of trying my VPS server by choosing a different country, I'll let you know. Have you ever had a problem like this with your bot?

9homme commented 1 year ago

From the error message, seem like it is issue from python-binance sdk https://github.com/sammchardy/python-binance/issues/1016

There are some solution in that thread, will try to fix the issue and let you know.

9homme commented 1 year ago

I found that the consumer of the websocket may working slower than the data that coming. In a meantime ,before I can fix this , Can you try increase your VPS spec and see that the issue is gone or not ?

I'm using AWS t2.micro and not found this issue.

concu72 commented 1 year ago

The VPS server was AWS eu-west-3 t2.micro. I migrated my VPS server to eu-north-1 t3.micro yesterday. It crashed on the new server with the same error twice.

2023-02-23 03:04:31.607204 DYDXUSDT 2023-02-23 02:57:00 Latest price = 2.722 already processed. Waiting for next closed Some error occured but just skip, message: {'e': 'error', 'm': 'Queue overflow. Message not filled'}, error: 'k' Traceback (most recent call last): File "C:\Users\Administrator\Desktop\awe\main.py", line 28, in handle_socket_message msg["k"]["t"] / 1000.0, timezone.utc KeyError: 'k'

concu72 commented 1 year ago

I completely deleted the python-binance==1.0.15 version I had installed in the requirements.txt with the bot on my VPS server with the "pip uninstall python-binance" command. Then line 1 of the bot's original requirements.txt file as follows I did a complete reinstall by editing it to be "python-binance==1.0.13". I've restarted it now and I'm waiting for the result. I will let you know.

concu72 commented 1 year ago

I tried both 1.0.13 and 1.0.17 packages of python_binance package. With these packages, the bot stops itself with the same error after the first operation.

2023-02-23 15:42:31.877562 XTZUSDT 2023-02-23 15:33:00 Latest price = 1.386 already processed. Waiting for next closed cSome error occured but just skip, message: {'e': 'error', 'm': 'Queue overflow. Message not filled'}, error: 'k' Traceback (most recent call last): File "C:\Users\Administrator\Desktop\awe\main.py", line 28, in handle_socket_message msg["k"]["t"] / 1000.0, timezone.utc KeyError: 'k'

9homme commented 1 year ago

Hi @concu72 I think this issue can happened because 2 reasons

  1. candle interval is too short to process all coins
  2. list of coins is too long

So it cannot process all the coins list within interval.

What is the interval you using ? Can you try smaller coins list using alt_coins_list config ?

concu72 commented 1 year ago

MERHABA@concu72Bu sorunun 2 nedenden kaynaklanabileceğini düşünüyorum

  1. mum aralığı tüm madeni paraları işlemek için çok kısa
  2. madeni para listesi çok uzun

Bu nedenle, aralık içindeki tüm madeni para listesini işleyemez.

Kullandığınız aralık nedir? alt_coins_list config kullanarak daha küçük madeni para listesi deneyebilir misiniz?

all_coins_list = 32 coins are currently available. 3 min works according to candles.

Besides, I moved my VPS server to AWS Singapore.

Now the problem has not occurred again. I could not understand whether the source of the problem is the length of the coin list or the VPS.

concu72 commented 1 year ago

The problem is solved. You can close the topic. Thanks for your help.

9homme commented 1 year ago

I think its because singapore is closest to binance server