Closed ghost closed 4 years ago
Hi Canercak!
This is related to unicorn-fy not to unicorn-binance-websocket-api :)
Anyway - Please tell me the exact channel name / create_stream()-settings you are using.
What shows a print(str(unicorn_fied_stream_data))
?
Hi! This is my code. This code works in my mac and ubuntu 19 server. It doesn't work in two new ubuntu 19 servers. oldest_stream_data_from_stream_buffer comes empty so I get key error. It works when I just print oldest_stream_data_from_stream_buffer
binance_websocket_api_manager = BinanceWebSocketApiManager(exchange="binance.com")
binance_websocket_api_manager.create_stream(['ticker'], symbols_to_look )
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:
unicorn_fied_stream_data = UnicornFy.binance_com_websocket(oldest_stream_data_from_stream_buffer)
symbol = unicorn_fied_stream_data['data'][0]['symbol']
fields=[symbol,
unicorn_fied_stream_data['data'][0]['event_time'],
unicorn_fied_stream_data['data'][0]['price_change'],
unicorn_fied_stream_data['data'][0]['price_change_percent'],
unicorn_fied_stream_data['data'][0]['last_price'],
unicorn_fied_stream_data['data'][0]['best_bid_price'],
unicorn_fied_stream_data['data'][0]['best_ask_price'],
unicorn_fied_stream_data['data'][0]['total_traded_base_asset_volume'],
unicorn_fied_stream_data['data'][0]['total_traded_quote_asset_volume']]
path = data_path + symbol + '.csv'
with open(path, 'a') as f:
writer = csv.writer(f)
writer.writerow(fields)
I found out version 4.0.0 of unicorn-fy works fine..I'm opening this issue on unicorn-fy
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 asprint(unicorn_fied_stream_data["data"])
it crashes with KeyError: 'data' I guess this is a bug in a newer version because same code works in my older vps.