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
678 stars 166 forks source link

KeyError: 'data' #168

Closed Rishirandhawa closed 3 years ago

Rishirandhawa commented 3 years ago

Check this or we will delete your issue. (fill in the checkbox with an X like so: [x])

Select one:

Environment

What kind of internet connection do you have?

AWS DatCenter

Average system load (CPU)

3 cores, load at 20%```

#### Hardware specification 

Intel Xenon```

Operating System? (include version)

Options

Which endpoint do you connect?

binance.com```

#### Python Version Requirement
- [ x] I am using Python 3.6.1 or above

#### Exact Python Version?

Include here the response of 'python --version' AND 'python3 --version'


#### Pip Version?

Include here the response of 'python3 -m pip --version' or 'pip3 --version'


#### Dependencies
Run `pip list > pip_list.txt` and upload the file.

#### UNICORN Binance WebSocket API Version?

Did you upgrade to the latest release version with pip install unicorn-binance-websocket-api --upgrade?

Please control what version you are using with this script and post the output: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/blob/master/tools/get_used_module_version.py


#### Description of your issue

Traceback (most recent call last): File "binance_futdb_soc_v0.py", line 323, in unicorn_fied_stream_data = UnicornFy.binance_com_websocket(oldest_stream_data_from_stream_buffer) File "/usr/local/lib/python3.8/dist-packages/unicorn_fy/unicorn_fy.py", line 88, in binance_com_websocket return UnicornFy.binance_websocket(stream_data_json, exchange="binance.com", show_deprecated_warning=False) File "/usr/local/lib/python3.8/dist-packages/unicorn_fy/unicorn_fy.py", line 287, in binance_websocket if stream_data['data']['e'] == 'aggTrade': KeyError: 'data'```

Process terminates with above error randomly. Seems for some records 'data' is not a valid field

oliver-zehentleitner commented 3 years ago

Thats not a "bug". Yes you can receive also results for example. Just add an exception for keyerror and print the receive which cause the KeyError. then you see what you have received and does not fit for stream_data['data'],