Closed ghost closed 3 years ago
Thx, i pick it up soon.
I took a look into the code, with
binance_websocket_api_manager = BinanceWebSocketApiManager(exchange="binance.com")
stream_id = binance_websocket_api_manager.create_stream(['ticker'], ['btcusdt', 'bnbbtc', 'ethbtc'])
time.sleep(10)
binance_websocket_api_manager.get_stream_subscriptions(stream_id)
time.sleep(5)
print(str(binance_websocket_api_manager.get_results_from_endpoints()))
time.sleep(5)
while True:
oldest_stream_data_from_stream_buffer = binance_websocket_api_manager.pop_stream_data_from_stream_buffer()
if oldest_stream_data_from_stream_buffer:
oldest_stream_data_from_stream_buffer = UnicornFy.binance_com_websocket(oldest_stream_data_from_stream_buffer)
print(oldest_stream_data_from_stream_buffer)
I receive
['{"result":null,"id":1}', '{"result":["ethbtc@ticker","bnbbtc@ticker","btcusdt@ticker"],"id":2}']
{'result': None, 'id': 1, 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282371107, 'symbol': 'BNBBTC', 'price_change': '-0.00003940', 'price_change_percent': '-1.605', 'weighted_average_price': '0.00242543', 'trade_before_24h_window': '0.00245370', 'last_price': '0.00241480', 'last_quantity': '0.50000000', 'best_bid_price': '0.00241370', 'best_bid_quantity': '2.23000000', 'best_ask_price': '0.00241480', 'best_ask_quantity': '1.29000000', 'open_price': '0.00245420', 'high_price': '0.00247000', 'low_price': '0.00237500', 'total_traded_base_asset_volume': '818869.54000000', 'total_traded_quote_asset_volume': '1986.11249683', 'statistics_open_time': 1601195969791, 'statistics_close_time': 1601282369791, 'first_trade_id': 90223425, 'last_trade_id': 90322184, 'total_nr_of_trades': 98760}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282371387, 'symbol': 'ETHBTC', 'price_change': '-0.00009900', 'price_change_percent': '-0.299', 'weighted_average_price': '0.03295512', 'trade_before_24h_window': '0.03305800', 'last_price': '0.03296000', 'last_quantity': '0.10000000', 'best_bid_price': '0.03295600', 'best_bid_quantity': '3.44100000', 'best_ask_price': '0.03296000', 'best_ask_quantity': '0.27000000', 'open_price': '0.03305900', 'high_price': '0.03324700', 'low_price': '0.03273000', 'total_traded_base_asset_volume': '210975.62300000', 'total_traded_quote_asset_volume': '6952.72672078', 'statistics_open_time': 1601195970485, 'statistics_close_time': 1601282370485, 'first_trade_id': 195770534, 'last_trade_id': 195871688, 'total_nr_of_trades': 101155}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'event_time': 1601282371550, 'symbol': 'BTCUSDT', 'price_change': '242.00000000', 'price_change_percent': '2.275', 'weighted_average_price': '10788.54496996', 'trade_before_24h_window': '10639.20000000', 'last_price': '10881.12000000', 'last_quantity': '0.00910200', 'best_bid_price': '10880.80000000', 'best_bid_quantity': '0.01186000', 'best_ask_price': '10880.81000000', 'best_ask_quantity': '2.28967400', 'open_price': '10639.12000000', 'high_price': '10950.00000000', 'low_price': '10594.82000000', 'total_traded_base_asset_volume': '37625.78790400', 'total_traded_quote_asset_volume': '405927504.83261226', 'statistics_open_time': 1601195971451, 'statistics_close_time': 1601282371451, 'first_trade_id': 423723606, 'last_trade_id': 424287485, 'total_nr_of_trades': 563880}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282372002, 'symbol': 'BNBBTC', 'price_change': '-0.00004000', 'price_change_percent': '-1.630', 'weighted_average_price': '0.00242543', 'trade_before_24h_window': '0.00245410', 'last_price': '0.00241370', 'last_quantity': '2.23000000', 'best_bid_price': '0.00241340', 'best_bid_quantity': '2.38000000', 'best_ask_price': '0.00241460', 'best_ask_quantity': '1.60000000', 'open_price': '0.00245370', 'high_price': '0.00247000', 'low_price': '0.00237500', 'total_traded_base_asset_volume': '818737.33000000', 'total_traded_quote_asset_volume': '1985.78800844', 'statistics_open_time': 1601195971745, 'statistics_close_time': 1601282371745, 'first_trade_id': 90223432, 'last_trade_id': 90322185, 'total_nr_of_trades': 98754}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282372268, 'symbol': 'ETHBTC', 'price_change': '-0.00009800', 'price_change_percent': '-0.296', 'weighted_average_price': '0.03295512', 'trade_before_24h_window': '0.03306000', 'last_price': '0.03296000', 'last_quantity': '0.10400000', 'best_bid_price': '0.03295500', 'best_bid_quantity': '2.00000000', 'best_ask_price': '0.03296000', 'best_ask_quantity': '0.26600000', 'open_price': '0.03305800', 'high_price': '0.03324700', 'low_price': '0.03273000', 'total_traded_base_asset_volume': '210969.03800000', 'total_traded_quote_asset_volume': '6952.50902963', 'statistics_open_time': 1601195972167, 'statistics_close_time': 1601282372167, 'first_trade_id': 195770539, 'last_trade_id': 195871689, 'total_nr_of_trades': 101151}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'event_time': 1601282372557, 'symbol': 'BTCUSDT', 'price_change': '241.54000000', 'price_change_percent': '2.270', 'weighted_average_price': '10788.54514624', 'trade_before_24h_window': '10639.20000000', 'last_price': '10880.66000000', 'last_quantity': '0.06012500', 'best_bid_price': '10880.66000000', 'best_bid_quantity': '0.00002600', 'best_ask_price': '10880.67000000', 'best_ask_quantity': '4.03807900', 'open_price': '10639.12000000', 'high_price': '10950.00000000', 'low_price': '10594.82000000', 'total_traded_base_asset_volume': '37625.85988900', 'total_traded_quote_asset_volume': '405928288.07858276', 'statistics_open_time': 1601195972544, 'statistics_close_time': 1601282372544, 'first_trade_id': 423723606, 'last_trade_id': 424287488, 'total_nr_of_trades': 563883}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282372759, 'symbol': 'BNBBTC', 'price_change': '-0.00004050', 'price_change_percent': '-1.650', 'weighted_average_price': '0.00242543', 'trade_before_24h_window': '0.00245350', 'last_price': '0.00241370', 'last_quantity': '2.23000000', 'best_bid_price': '0.00241340', 'best_bid_quantity': '2.38000000', 'best_ask_price': '0.00241420', 'best_ask_quantity': '1.87000000', 'open_price': '0.00245420', 'high_price': '0.00247000', 'low_price': '0.00237500', 'total_traded_base_asset_volume': '818732.33000000', 'total_traded_quote_asset_volume': '1985.77574045', 'statistics_open_time': 1601195972722, 'statistics_close_time': 1601282372722, 'first_trade_id': 90223434, 'last_trade_id': 90322185, 'total_nr_of_trades': 98752}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282373403, 'symbol': 'ETHBTC', 'price_change': '-0.00010200', 'price_change_percent': '-0.309', 'weighted_average_price': '0.03295511', 'trade_before_24h_window': '0.03305800', 'last_price': '0.03295600', 'last_quantity': '1.15600000', 'best_bid_price': '0.03295600', 'best_bid_quantity': '2.08400000', 'best_ask_price': '0.03295800', 'best_ask_quantity': '0.35500000', 'open_price': '0.03305800', 'high_price': '0.03324700', 'low_price': '0.03273000', 'total_traded_base_asset_volume': '210960.34000000', 'total_traded_quote_asset_volume': '6952.22133616', 'statistics_open_time': 1601195973327, 'statistics_close_time': 1601282373327, 'first_trade_id': 195770542, 'last_trade_id': 195871692, 'total_nr_of_trades': 101151}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'event_time': 1601282373565, 'symbol': 'BTCUSDT', 'price_change': '241.37000000', 'price_change_percent': '2.269', 'weighted_average_price': '10788.54585842', 'trade_before_24h_window': '10639.13000000', 'last_price': '10880.49000000', 'last_quantity': '0.10007100', 'best_bid_price': '10880.49000000', 'best_bid_quantity': '0.01032900', 'best_ask_price': '10880.50000000', 'best_ask_quantity': '3.57121300', 'open_price': '10639.12000000', 'high_price': '10950.00000000', 'low_price': '10594.82000000', 'total_traded_base_asset_volume': '37626.07197100', 'total_traded_quote_asset_volume': '405930602.93135981', 'statistics_open_time': 1601195973277, 'statistics_close_time': 1601282373277, 'first_trade_id': 423723608, 'last_trade_id': 424287538, 'total_nr_of_trades': 563931}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282374102, 'symbol': 'BNBBTC', 'price_change': '-0.00004080', 'price_change_percent': '-1.662', 'weighted_average_price': '0.00242543', 'trade_before_24h_window': '0.00245350', 'last_price': '0.00241340', 'last_quantity': '2.38000000', 'best_bid_price': '0.00241300', 'best_bid_quantity': '1.94000000', 'best_ask_price': '0.00241370', 'best_ask_quantity': '1.73000000', 'open_price': '0.00245420', 'high_price': '0.00247000', 'low_price': '0.00237500', 'total_traded_base_asset_volume': '818734.77000000', 'total_traded_quote_asset_volume': '1985.78162919', 'statistics_open_time': 1601195974086, 'statistics_close_time': 1601282374086, 'first_trade_id': 90223434, 'last_trade_id': 90322187, 'total_nr_of_trades': 98754}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282374386, 'symbol': 'ETHBTC', 'price_change': '-0.00010200', 'price_change_percent': '-0.309', 'weighted_average_price': '0.03295511', 'trade_before_24h_window': '0.03305800', 'last_price': '0.03295600', 'last_quantity': '1.15600000', 'best_bid_price': '0.03295600', 'best_bid_quantity': '2.08400000', 'best_ask_price': '0.03295800', 'best_ask_quantity': '0.35500000', 'open_price': '0.03305800', 'high_price': '0.03324700', 'low_price': '0.03273000', 'total_traded_base_asset_volume': '210960.34000000', 'total_traded_quote_asset_volume': '6952.22133616', 'statistics_open_time': 1601195973327, 'statistics_close_time': 1601282373327, 'first_trade_id': 195770542, 'last_trade_id': 195871692, 'total_nr_of_trades': 101151}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'event_time': 1601282374599, 'symbol': 'BTCUSDT', 'price_change': '240.88000000', 'price_change_percent': '2.264', 'weighted_average_price': '10788.54662435', 'trade_before_24h_window': '10639.13000000', 'last_price': '10880.00000000', 'last_quantity': '0.02016100', 'best_bid_price': '10880.24000000', 'best_bid_quantity': '0.01186000', 'best_ask_price': '10880.25000000', 'best_ask_quantity': '3.81186000', 'open_price': '10639.12000000', 'high_price': '10950.00000000', 'low_price': '10594.82000000', 'total_traded_base_asset_volume': '37626.05595400', 'total_traded_quote_asset_volume': '405930458.95003503', 'statistics_open_time': 1601195974597, 'statistics_close_time': 1601282374597, 'first_trade_id': 423723611, 'last_trade_id': 424287544, 'total_nr_of_trades': 563934}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282375101, 'symbol': 'BNBBTC', 'price_change': '-0.00004050', 'price_change_percent': '-1.650', 'weighted_average_price': '0.00242543', 'trade_before_24h_window': '0.00245350', 'last_price': '0.00241370', 'last_quantity': '0.02000000', 'best_bid_price': '0.00241290', 'best_bid_quantity': '2.91000000', 'best_ask_price': '0.00241360', 'best_ask_quantity': '1.65000000', 'open_price': '0.00245420', 'high_price': '0.00247000', 'low_price': '0.00237500', 'total_traded_base_asset_volume': '818734.79000000', 'total_traded_quote_asset_volume': '1985.78167746', 'statistics_open_time': 1601195975100, 'statistics_close_time': 1601282375100, 'first_trade_id': 90223434, 'last_trade_id': 90322188, 'total_nr_of_trades': 98755}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282375391, 'symbol': 'ETHBTC', 'price_change': '-0.00010200', 'price_change_percent': '-0.309', 'weighted_average_price': '0.03295511', 'trade_before_24h_window': '0.03305800', 'last_price': '0.03295600', 'last_quantity': '1.51500000', 'best_bid_price': '0.03295600', 'best_bid_quantity': '1.72500000', 'best_ask_price': '0.03295700', 'best_ask_quantity': '0.26600000', 'open_price': '0.03305800', 'high_price': '0.03324700', 'low_price': '0.03273000', 'total_traded_base_asset_volume': '210960.69900000', 'total_traded_quote_asset_volume': '6952.23316736', 'statistics_open_time': 1601195974854, 'statistics_close_time': 1601282374854, 'first_trade_id': 195770542, 'last_trade_id': 195871693, 'total_nr_of_trades': 101152}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'event_time': 1601282375582, 'symbol': 'BTCUSDT', 'price_change': '241.11000000', 'price_change_percent': '2.266', 'weighted_average_price': '10788.54804839', 'trade_before_24h_window': '10639.12000000', 'last_price': '10880.24000000', 'last_quantity': '0.01183100', 'best_bid_price': '10880.24000000', 'best_bid_quantity': '0.00002900', 'best_ask_price': '10880.25000000', 'best_ask_quantity': '6.33962700', 'open_price': '10639.13000000', 'high_price': '10950.00000000', 'low_price': '10594.82000000', 'total_traded_base_asset_volume': '37625.71646900', 'total_traded_quote_asset_volume': '405926849.98107255', 'statistics_open_time': 1601195974855, 'statistics_close_time': 1601282374855, 'first_trade_id': 423723612, 'last_trade_id': 424287545, 'total_nr_of_trades': 563934}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282376048, 'symbol': 'BNBBTC', 'price_change': '-0.00004050', 'price_change_percent': '-1.650', 'weighted_average_price': '0.00242543', 'trade_before_24h_window': '0.00245350', 'last_price': '0.00241370', 'last_quantity': '0.02000000', 'best_bid_price': '0.00241290', 'best_bid_quantity': '1.17000000', 'best_ask_price': '0.00241350', 'best_ask_quantity': '2.12000000', 'open_price': '0.00245420', 'high_price': '0.00247000', 'low_price': '0.00237500', 'total_traded_base_asset_volume': '818734.79000000', 'total_traded_quote_asset_volume': '1985.78167746', 'statistics_open_time': 1601195975783, 'statistics_close_time': 1601282375783, 'first_trade_id': 90223434, 'last_trade_id': 90322188, 'total_nr_of_trades': 98755}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282376410, 'symbol': 'ETHBTC', 'price_change': '-0.00010300', 'price_change_percent': '-0.312', 'weighted_average_price': '0.03295511', 'trade_before_24h_window': '0.03305800', 'last_price': '0.03295600', 'last_quantity': '1.54900000', 'best_bid_price': '0.03295600', 'best_bid_quantity': '1.69100000', 'best_ask_price': '0.03295700', 'best_ask_quantity': '0.26600000', 'open_price': '0.03305900', 'high_price': '0.03324700', 'low_price': '0.03273000', 'total_traded_base_asset_volume': '210959.73300000', 'total_traded_quote_asset_volume': '6952.20122986', 'statistics_open_time': 1601195975644, 'statistics_close_time': 1601282375644, 'first_trade_id': 195770543, 'last_trade_id': 195871694, 'total_nr_of_trades': 101152}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'event_time': 1601282376591, 'symbol': 'BTCUSDT', 'price_change': '241.02000000', 'price_change_percent': '2.265', 'weighted_average_price': '10788.55018542', 'trade_before_24h_window': '10639.12000000', 'last_price': '10880.15000000', 'last_quantity': '0.01186300', 'best_bid_price': '10880.15000000', 'best_bid_quantity': '0.00002600', 'best_ask_price': '10880.16000000', 'best_ask_quantity': '5.00124100', 'open_price': '10639.13000000', 'high_price': '10950.00000000', 'low_price': '10594.82000000', 'total_traded_base_asset_volume': '37625.79199800', 'total_traded_quote_asset_volume': '405927745.23654944', 'statistics_open_time': 1601195976449, 'statistics_close_time': 1601282376449, 'first_trade_id': 423723621, 'last_trade_id': 424287553, 'total_nr_of_trades': 563933}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282376919, 'symbol': 'BNBBTC', 'price_change': '-0.00004050', 'price_change_percent': '-1.650', 'weighted_average_price': '0.00242543', 'trade_before_24h_window': '0.00245350', 'last_price': '0.00241370', 'last_quantity': '0.02000000', 'best_bid_price': '0.00241290', 'best_bid_quantity': '1.17000000', 'best_ask_price': '0.00241350', 'best_ask_quantity': '2.12000000', 'open_price': '0.00245420', 'high_price': '0.00247000', 'low_price': '0.00237500', 'total_traded_base_asset_volume': '818734.79000000', 'total_traded_quote_asset_volume': '1985.78167746', 'statistics_open_time': 1601195975783, 'statistics_close_time': 1601282375783, 'first_trade_id': 90223434, 'last_trade_id': 90322188, 'total_nr_of_trades': 98755}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282377311, 'symbol': 'ETHBTC', 'price_change': '-0.00010200', 'price_change_percent': '-0.309', 'weighted_average_price': '0.03295511', 'trade_before_24h_window': '0.03305900', 'last_price': '0.03295600', 'last_quantity': '1.90900000', 'best_bid_price': '0.03295600', 'best_bid_quantity': '1.33100000', 'best_ask_price': '0.03295700', 'best_ask_quantity': '0.26600000', 'open_price': '0.03305800', 'high_price': '0.03324700', 'low_price': '0.03273000', 'total_traded_base_asset_volume': '210957.52800000', 'total_traded_quote_asset_volume': '6952.12829769', 'statistics_open_time': 1601195976435, 'statistics_close_time': 1601282376435, 'first_trade_id': 195770544, 'last_trade_id': 195871695, 'total_nr_of_trades': 101152}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'event_time': 1601282377513, 'symbol': 'BTCUSDT', 'price_change': '241.03000000', 'price_change_percent': '2.266', 'weighted_average_price': '10788.55368872', 'trade_before_24h_window': '10639.20000000', 'last_price': '10880.16000000', 'last_quantity': '1.16776200', 'best_bid_price': '10880.15000000', 'best_bid_quantity': '0.00002600', 'best_ask_price': '10880.16000000', 'best_ask_quantity': '1.90472600', 'open_price': '10639.13000000', 'high_price': '10950.00000000', 'low_price': '10594.82000000', 'total_traded_base_asset_volume': '37626.79348900', 'total_traded_quote_asset_volume': '405938681.69051535', 'statistics_open_time': 1601195977372, 'statistics_close_time': 1601282377372, 'first_trade_id': 423723631, 'last_trade_id': 424287558, 'total_nr_of_trades': 563928}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'bnbbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282377870, 'symbol': 'BNBBTC', 'price_change': '-0.00004050', 'price_change_percent': '-1.650', 'weighted_average_price': '0.00242543', 'trade_before_24h_window': '0.00245350', 'last_price': '0.00241370', 'last_quantity': '0.02000000', 'best_bid_price': '0.00241290', 'best_bid_quantity': '1.17000000', 'best_ask_price': '0.00241350', 'best_ask_quantity': '2.12000000', 'open_price': '0.00245420', 'high_price': '0.00247000', 'low_price': '0.00237500', 'total_traded_base_asset_volume': '818734.79000000', 'total_traded_quote_asset_volume': '1985.78167746', 'statistics_open_time': 1601195975783, 'statistics_close_time': 1601282375783, 'first_trade_id': 90223434, 'last_trade_id': 90322188, 'total_nr_of_trades': 98755}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'ethbtc@ticker', 'event_type': '24hrTicker', 'event_time': 1601282378367, 'symbol': 'ETHBTC', 'price_change': '-0.00009800', 'price_change_percent': '-0.296', 'weighted_average_price': '0.03295511', 'trade_before_24h_window': '0.03305800', 'last_price': '0.03295600', 'last_quantity': '0.48100000', 'best_bid_price': '0.03295600', 'best_bid_quantity': '23.51900000', 'best_ask_price': '0.03295800', 'best_ask_quantity': '0.35500000', 'open_price': '0.03305400', 'high_price': '0.03324700', 'low_price': '0.03273000', 'total_traded_base_asset_volume': '210960.04000000', 'total_traded_quote_asset_volume': '6952.21107668', 'statistics_open_time': 1601195978347, 'statistics_close_time': 1601282378347, 'first_trade_id': 195770545, 'last_trade_id': 195871699, 'total_nr_of_trades': 101155}], 'unicorn_fied': ['binance.com', '0.5.0']}
{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'data': [{'stream_type': 'btcusdt@ticker', 'event_type': '24hrTicker', 'event_time': 1601282378606, 'symbol': 'BTCUSDT', 'price_change': '240.81000000', 'price_change_percent': '2.263', 'weighted_average_price': '10788.55420294', 'trade_before_24h_window': '10639.13000000', 'last_price': '10880.01000000', 'last_quantity': '0.04102400', 'best_bid_price': '10880.01000000', 'best_bid_quantity': '0.52119400', 'best_ask_price': '10880.07000000', 'best_ask_quantity': '0.35956200', 'open_price': '10639.20000000', 'high_price': '10950.00000000', 'low_price': '10594.82000000', 'total_traded_base_asset_volume': '37626.84622800', 'total_traded_quote_asset_volume': '405939270.01630014', 'statistics_open_time': 1601195978559, 'statistics_close_time': 1601282378559, 'first_trade_id': 423723632, 'last_trade_id': 424287563, 'total_nr_of_trades': 563932}], 'unicorn_fied': ['binance.com', '0.5.0']}
I think only in !ticker
are more than one result in data
.
I'm consistently getting key_error when I try to get data from the json output. For example print(unicorn_fied_stream_data) works But when I try to get the data part such as print(unicorn_fied_stream_data["data"]) it crashes with KeyError: 'data' This is my code below. Code works on version 4.0.0 in my mac and ubuntu vps. The latest version gives the error