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
688 stars 164 forks source link

Stream returns string instead of json #24

Closed eylence closed 5 years ago

eylence commented 5 years ago

Hi,

the miniTicker stream returns strings instead of dictionary

    def process_stream_data(msg):
        print(type(msg))
    def new_stream():
        binance_websocket_api_manager = BinanceWebSocketApiManager(process_stream_data)
        markets = {'btcusdt'}
        channels = {'miniTicker'}
        binance_websocket_api_manager.create_stream(channels, markets)

    new_stream()

output:

<class 'str'>
<class 'str'>
....

unicorn-binance-websocket-api version 1.4.0

oliver-zehentleitner commented 5 years ago

Hello! This is what happens on receive: https://github.com/unicorn-data-analysis/unicorn-binance-websocket-api/blob/master/unicorn_binance_websocket_api/unicorn_binance_websocket_api_socket.py#L62

I havent tested or researched anything now, but i would believe json received through a websocket is string type.

If you need help on miniTicker please take a look to this example: https://github.com/unicorn-data-analysis/unicorn-binance-websocket-api/blob/master/example_ticker_and_miniticker.py which is using this class for processing: https://github.com/unicorn-data-analysis/unicorn-binance-websocket-api/blob/master/unicorn_binance_websocket_api_process_streams.py

All examples are ready to run, just download, review and start!

Best regards!

oliver-zehentleitner commented 5 years ago

This class can help you, to manage your receives with less effort: https://github.com/unicorn-data-analysis/unicorn_fy

oliver-zehentleitner commented 5 years ago

eylence: Please feel free to reopen if you have further questions on this topic!