LUCIT-Systems-and-Development / unicorn-binance-rest-api

A Python SDK by LUCIT to use the Binance REST API`s (com+testnet, com-margin+testnet, com-isolated_margin+testnet, com-futures+testnet, us, tr) in a simple, fast, flexible, robust and fully-featured way.
https://unicorn-binance-rest-api.docs.lucit.tech
Other
61 stars 17 forks source link

API randomly stops updating #34

Closed rondha03 closed 1 year ago

rondha03 commented 2 years ago

Version of this library.

unicorn_fy: not found unicorn_binance_local_depth_cache: not found unicorn_binance_rest_api: 1.4.3 unicorn_binance_websocket_api: not found

Solution to Issue cannot be found in the documentation or other Issues and also occurs in the latest version of this library.

Hardware?

Local server/workstation

Operating System?

Windows

Python version?

Python3.10

Installed packages

aiodns                    3.0.0
aiohttp                   3.8.1
aiosignal                 1.2.0
altgraph                  0.17.2
async-timeout             4.0.2
attrs                     21.4.0
ccxt                      1.79.89
certifi                   2021.10.8
cffi                      1.15.0
charset-normalizer        2.0.12
colorama                  0.4.4
cryptography              36.0.2
dateparser                1.1.1
frozenlist                1.3.0
future                    0.18.2
idna                      3.3
multidict                 6.0.2
pefile                    2021.9.3
pip                       21.3.1
pyasn1                    0.4.8
pyasn1-modules            0.2.8
pycares                   4.1.2
pycparser                 2.21
pyinstaller               5.0
pyinstaller-hooks-contrib 2022.4
pyOpenSSL                 22.0.0
PyQt5                     5.15.6
PyQt5-Qt5                 5.15.2
PyQt5-sip                 12.10.1
PyQt5-stubs               5.15.2.0
python-dateutil           2.8.2
pytz                      2022.1
pytz-deprecation-shim     0.1.0.post0
pywin32-ctypes            0.2.0
regex                     2022.3.2
requests                  2.27.1
service-identity          21.1.0
setuptools                62.1.0
six                       1.16.0
tzdata                    2022.1
tzlocal                   4.2
ujson                     5.2.0
unicorn-binance-rest-api  1.4.3
urllib3                   1.26.9
websocket-client          1.3.2
websockets                10.3
wheel                     0.37.1
yarl                      1.7.2

Logging output

2022-04-20 15:01:11,643 [DEBUG   ] 3280 852 connectionpool: https://fapi.binance.com:443 "GET /fapi/v1/positionRisk?symbol= &timestamp=   8&signature=  HTTP/1.1" 200 None
2022-04-20 15:01:11,889 [DEBUG   ] 3280 852 connectionpool: https://fapi.binance.com:443 "GET /fapi/v1/positionRisk?symbol=  &timestamp=  &signature=  HTTP/1.1" 200 None

2022-04-19 02:18:03,281 [DEBUG   ] 4620 3684 connectionpool: https://api.binance.com:443 "GET /api/v3/ping HTTP/1.1" 200 2
2022-04-19 02:18:03,521 [DEBUG   ] 4620 3684 connectionpool: https://api.binance.com:443 "GET /api/v3/time HTTP/1.1" 200 28
2022-04-19 02:18:03,770 [DEBUG   ] 4620 3684 connectionpool: https://api.github.com:443 "GET /repos/LUCIT-Systems-and-Development/unicorn-binance-rest-api/releases/latest HTTP/1.1" 200 1045

Used endpoint?

binance.com-futures

Issue

Hello!

Randomly, I won't be able to open or close any position when orders are sent.

The debug goes from printing only fapi.binance.com:443 to api.binance.com:443 followed by api.github.com:443 then it will just stop. No freeze or error message.

I added this line my codes:
t = datetime.now() print(t)

I noticed that if after 30mn no time info has been printed, those three lines are in the debugging file and the script is no longer working. At first I tought that it may be due to been idle for too long, but there has been time when it stopped 10 minutes after opening a position.

oliver-zehentleitner commented 2 years ago

The log msg you posted is usually logged when the manager gets initialized.

I think the problem is within your code.. can you please post code to reproduce the issue?

rondha03 commented 2 years ago

Hello Oliver!

Thank you very much for the great tool and for getting back to me.

code: https://pastebin.com/ga22jhx2

UI: https://pastebin.com/8KnrZkyu

rondha03 commented 2 years ago

it seems like self.client.ping every 25 mn solves the issue.

oliver-zehentleitner commented 2 years ago

interesting! thank you, i will test this timeout issue, we can do an automatic ping within the manager class

rondha03 commented 2 years ago

Thank you! Looking forward to it.

rondha03 commented 2 years ago

Hello!

Something just hit me. In the previous post I said that I added self.client.ping. It's a mistake. I actually added self.client.futures_ping

So the issue is not just the timeout when idle for more than 20-25 minutes, but also that after resetting/reinitialization, it seems to point to spot https://api.binance.com:443 instead of future https://fapi.binance.com:443. I double checked and I've always used exchange="binance.com-futures"

oliver-zehentleitner commented 2 years ago

hi! can you give me please a demo script to easily reconstruct the error? thank you

rondha03 commented 2 years ago

I moved the older versions in to the archive, I'll share it this weekend.