When I try to print a formatted unicorn dict to console i get Keyerror.
This is my code:
def print_stream_data_from_stream_buffer(binance_websocket_api_manager):
while True:
if binance_websocket_api_manager.is_manager_stopping():
exit(0)
oldest_stream_data_from_stream_buffer = \
binance_websocket_api_manager.pop_stream_data_from_stream_buffer()
if oldest_stream_data_from_stream_buffer is not False:
unicorn_fied_data = UnicornFy.binance_com_websocket(
oldest_stream_data_from_stream_buffer)
print('Time: {} Symbol: {} Side: {} Price: {} Quantity: {} '
'Status: {}'.format(unicorn_fied_data['event_time'],
unicorn_fied_data['symbol'],
unicorn_fied_data['side'],
unicorn_fied_data['order_price'],
unicorn_fied_data['order_quantity'],
unicorn_fied_data['current_order_status']))
else:
time.sleep(0.01)
This is the error:
Time: 1600220588187 Symbol: ETHBTC Side: BUY Price: 0.03000000 Quantity: 0.02300000 Status: NEW
Exception in thread Thread-16:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\ProgramData\Anaconda3\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\asus\Documents\Personal\Corporate\Python\red_robin\websockettest.py", line 23, in print_stream_data_from_stream_buffer
unicorn_fied_data['symbol'],
KeyError: 'symbol'
As you can see the correct formatting is printing to console but there still a keyerror, how can I fix this?
Hello,
When I try to print a formatted unicorn dict to console i get Keyerror.
This is my code:
This is the error:
As you can see the correct formatting is printing to console but there still a keyerror, how can I fix this?