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
683 stars 165 forks source link

spot bookTicker broken #300

Closed peachy88 closed 1 year ago

peachy88 commented 1 year ago

Version of this library.

unicorn_fy: 0.12.2 unicorn_binance_local_depth_cache: not found unicorn_binance_rest_api: 1.5.0 unicorn_binance_trailing_stop_loss: not found unicorn_binance_websocket_api: 1.41.0

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?

Linux

Python version?

Python3.10

Installed packages

No response

Logging output

No response

Processing method?

process_stream_data

Used endpoint?

binance.com

Issue

bookTicker does not stream any data for spot.

broken : binance_websocket_api_manager = BinanceWebSocketApiManager(exchange="binance.com") streamid = binance_websocket_api_manager.create_stream({"!bookTicker"}, "arr") worker_thread = threading.Thread(target=print_stream_data_from_stream_buffer, args=(binance_websocket_api_manager,)) worker_thread.start()

works: binance_websocket_api_manager = BinanceWebSocketApiManager(exchange="binance.com-futures") streamid = binance_websocket_api_manager.create_stream({"!bookTicker"}, "arr") worker_thread = threading.Thread(target=print_stream_data_from_stream_buffer, args=(binance_websocket_api_manager,)) worker_thread.start()

only change is the exchange="binance.com-futures" instead of "binance.com"

There have been changes in the way binance represents the exchange_info for spot, equaling the info the way futures exchange_info is answer. if unicorn-binance-websocket uses a specific format for spot different than futures, this may be related.

thanks :)

oliver-zehentleitner commented 1 year ago

Hi @peachy88 ! I thinks thats ok, !bookTicker is not available in spot! Only a symbol specific ticker: https://binance-docs.github.io/apidocs/websocket_api/en/#symbol-order-book-ticker

There have been changes in the way binance represents the exchange_info for spot, equaling the info the way futures exchange_info is answer. if unicorn-binance-websocket uses a specific format for spot different than futures, this may be related.

If i get you right, thats a uniorn-fy issue, please post that here: https://github.com/LUCIT-Systems-and-Development/unicorn-fy

peachy88 commented 1 year ago

thanks for your answer.

a month ago the same code for spot worked. then it stopped working.

"If no symbol is specified, returns information about all symbols currently trading on the exchange." so it should still work if no symbol is specified.

oliver-zehentleitner commented 1 year ago

hm, but they write @bookTicker with and without a symbol! Its not a typical 'arr' subscription with a '!'.

binance_websocket_api_manager.create_stream("bookTicker", "") could build the right string for the subscription, but i am not sure.

We can test it out and add support for that format.

elmagow commented 1 year ago

2022-12-05

Notice: These changes are being rolled out gradually to all our servers, and will take approximately a week to complete.

WEBSOCKET

!bookTicker will be removed by December 7, 2022. Please use the Individual Book Ticker Streams instead. (<symbol>@bookTicker).
    Multiple <symbol>@bookTicker streams can be subscribed to over one connection. (E.g. wss://stream.binance.com:9443/stream?streams=btcusdt@bookTicker/bnbbtc@bookTicker)

They removed it, that's why it isn't working anymore

oliver-zehentleitner commented 1 year ago

But they also write here:

If no symbol is specified, returns information about all symbols currently trading on the exchange.

I will test it asap....

peachy88 commented 1 year ago

thank you so much for looking into this.

alternatively, should they require symbols to be specified, would it be possible to just pass them all available symbols in the request and get that way a similar response previously to their change?

oliver-zehentleitner commented 1 year ago

Hm, it works in my tests: https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/blob/master/example_bookticker.py

I think I see your mistake, try this (just change the positions): binance_websocket_api_manager.create_stream("arr", "!bookTicker")

I close this, feel free to post for further questions. :)