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

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

markPrice stream is empty #322

Closed Animouse31 closed 1 year ago

Animouse31 commented 1 year ago

Version of this library.

--- Call Binance WebSocket API Manager - Mark Index Prices

ws_price = BinanceWebSocketApiManager(exchange="binance.com-futures", high_performance=True, # debug=False, throw_exception_if_unrepairable=True, restart_timeout=15,)

Create Streams

ws_price.create_stream('markPrice', SYMBOLS, output='dict', # Options: 'raw_data', 'dict', 'UnicornFy' api_key=API_KEY, api_secret=API_SECRET, stream_buffer_name='price', ping_interval=1, ping_timeout=5, close_timeout=5, stream_buffer_maxlen=STREAM_BUFFER_MAXLEN)

while True:

Get Streams

        stream_price = ws_price.pop_stream_data_from_stream_buffer('price', mode='FIFO')

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.8

Installed packages

No response

Logging output

No response

Processing method?

stream_buffer

Used endpoint?

binance.com-futures

Issue

Since 2 days ago, my markPrice stream has been troubled. First, it sent an error message something like illegal activity. And then, since yesterday I haven't received any markPrice message, including different streams like markPrice@1s and !markPrice@arr.

I wonder if Binance server is troubled? Or are there some changes that I don't know?

oliver-zehentleitner commented 1 year ago

There could be so many reasons, without a logfile and version nr i cant help you!

oliver-zehentleitner commented 1 year ago

Escepically if you use "ping_interval=1, ping_timeout=5, close_timeout=5," and play with restart timeout there are a few possibilities to break the function...

Animouse31 commented 1 year ago

Escepically if you use "ping_interval=1, ping_timeout=5, close_timeout=5," and play with restart timeout there are a few possibilities to break the function...

I just know about it. What is the ideal ping_interval, ping_timeout, and close_timeout? Should I leave it blank (default)?

oliver-zehentleitner commented 1 year ago

it depends on your needs of "real time data", how much data you process and it must fit to peak times... sometimes binance traffic is 3-5 times higher as in the usual days. setting it to low timeouts maybe initiate more websocket restarts than neccessary which also leads to more interruptions and more lost data... maybe you should look also to stream_buffer length, fifo/lifo stack too to optimize your access to the data and manage restarts or a buffer clear to just delete the buffer (if to much is on the stack) and avoid the restart overhead.

close_timeout is the time how long a socket has time to close... i think this can be also 1 - waiting longer has no real benefit and delays the restart...

oliver-zehentleitner commented 1 year ago

and... i used the best settings for default to have most stable connection for most usecases. you should have a reason to touch this.

oliver-zehentleitner commented 1 year ago

I close this, just post the log file if the error remains and i will reopen.