unicorn-binance-websocket-api
unicorn-binance-websocket-api copied to clipboard
Program stopped running unexpectedly
Version of this library.
I am using the code from one of the examples to get futures data:
from unicorn_binance_websocket_api.manager import BinanceWebSocketApiManager import logging import time from math import trunc import logging from binance.lib.utils import config_logging
''' logging.getLogger("unicorn_binance_websocket_api") logging.basicConfig(level=logging.INFO, filename=os.path.basename(file) + '.log', format="{asctime} [{levelname:8}] {process} {thread} {module}: {message}", style="{")'''
create instance of BinanceWebSocketApiManager
binance_websocket_api_manager = BinanceWebSocketApiManager(exchange="binance.com-futures", output_default="UnicornFy")
def get_live_market_data(markets): binance_websocket_api_manager.create_stream('kline_1m', markets, stream_label="UnicornFy", output="UnicornFy")
binance_websocket_api_manager.create_stream('kline_1m', markets, stream_label="dict", output="dict")
binance_websocket_api_manager.create_stream('kline_1m', markets, stream_label="raw_data", output="raw_data")
market_data_1m = {}
print(f"Printing the closing klines:")
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 False:
time.sleep(0.01)
else:
if oldest_stream_data_from_stream_buffer is not None:
try:
if oldest_stream_data_from_stream_buffer['kline']['is_closed']:
#print(f"UnicornFy: {oldest_stream_data_from_stream_buffer}")
market_data_1m[oldest_stream_data_from_stream_buffer['kline']['symbol']]=[oldest_stream_data_from_stream_buffer['kline']['kline_start_time'],oldest_stream_data_from_stream_buffer['kline']['open_price'],oldest_stream_data_from_stream_buffer['kline']['high_price'],oldest_stream_data_from_stream_buffer['kline']['low_price'],oldest_stream_data_from_stream_buffer['kline']['close_price'],oldest_stream_data_from_stream_buffer['kline']['base_volume'],oldest_stream_data_from_stream_buffer['kline']['kline_close_time'],oldest_stream_data_from_stream_buffer['kline']['quote'],oldest_stream_data_from_stream_buffer['kline']['number_of_trades'],oldest_stream_data_from_stream_buffer['kline']['taker_by_base_asset_volume'],oldest_stream_data_from_stream_buffer['kline']['taker_by_quote_asset_volume'],oldest_stream_data_from_stream_buffer['kline']['ignore']]
if len(markets)==len(market_data_1m):
print(market_data_1m)
return market_data_1m
except KeyError:
try:
if oldest_stream_data_from_stream_buffer['k']['x']:
print('KeyError happened')
#print(f"dict: {oldest_stream_data_from_stream_buffer}")
except KeyError:
pass
except TypeError:
if '"x":true' in oldest_stream_data_from_stream_buffer:
print('TypeError happened')
#print(f"raw_data: {oldest_stream_data_from_stream_buffer}")
markets={'oneusdt', 'enjusdt', 'ftmusdt', 'chzusdt', 'algousdt', 'galausdt', 'wavesusdt', 'celousdt', 'hntusdt', 'btcusdt', 'ethusdt', 'zilusdt', 'qtumusdt', 'batusdt', 'crvusdt'} get_live_market_data(markets)
Solution to Issue cannot be found in the documentation or other Issues and also occurs in the latest version of this library.
- [X] I checked the documentation and other Issues. I am using the latest version of this library.
Hardware?
Local server/workstation
Operating System?
macOS
Python version?
Python3.9
Installed packages
Package Version
----------------------------- --------------------
aiohttp 3.8.1
aiosignal 1.2.0
aniso8601 9.0.1
apprise 0.9.7
argcomplete 2.0.0
async-timeout 4.0.2
attrs 21.4.0
autobahn 22.5.1
Automat 20.2.0
beautifulsoup4 4.10.0
binance-futures-connector 3.1.1
bs4 0.0.1
certifi 2021.10.8
cffi 1.15.0
charset-normalizer 2.0.12
cheroot 8.6.0
click 8.1.2
colorama 0.4.5
constantly 15.1.0
cryptography 37.0.2
cycler 0.11.0
dateparser 1.1.1
findiff 0.8.9
Flask 2.1.2
Flask-RESTful 0.3.9
fonttools 4.31.2
frozenlist 1.3.0
hyperlink 21.0.0
idna 3.3
importlib-metadata 4.11.3
incremental 21.3.0
install 1.3.5
itsdangerous 2.1.2
jaraco.functools 3.5.0
Jinja2 3.1.2
joblib 1.1.0
kiwisolver 1.4.2
kucoin-python 1.0.11
lxml 4.8.0
Markdown 3.3.6
MarkupSafe 2.1.1
matplotlib 3.5.1
more-itertools 8.13.0
mpl-finance 0.10.1
mplcursors 0.5.1.post2+g158b329
mplfinance 0.12.8b9
mpmath 1.2.1
multidict 6.0.2
multitasking 0.0.10
numpy 1.22.3
oauthlib 3.2.0
packaging 21.3
pandas 1.4.2
pathspec 0.9.0
Pillow 9.1.0
pip 22.1.2
plotly 5.7.0
psutil 5.9.1
py3cw 0.0.36
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.21
pyOpenSSL 22.0.0
pyparsing 3.0.7
python-binance 1.0.16
python-dateutil 2.8.2
pytz 2022.1
pytz-deprecation-shim 0.1.0.post0
PyYAML 6.0
regex 2022.3.2
requests 2.27.1
requests-oauthlib 1.3.1
scikit-learn 1.0.2
scipy 1.8.0
service-identity 21.1.0
setupext 0.24.8
setuptools 49.2.1
shyaml 0.6.2
six 1.16.0
soupsieve 2.3.2
sympy 1.10.1
tenacity 8.0.1
threadpoolctl 3.1.0
toml 0.10.2
Twisted 22.4.0
txaio 22.2.1
typing_extensions 4.2.0
tzdata 2022.1
tzlocal 4.2
ujson 5.1.0
unicorn-binance-websocket-api 1.41.0
unicorn-fy 0.12.2
urllib3 1.26.9
websocket-client 1.3.2
websockets 10.3
Werkzeug 2.1.2
xmltodict 0.13.0
yamllint 1.26.3
yarl 1.7.2
yfinance 0.1.70
yq 2.14.0
zipp 3.8.0
zope.interface 5.4.0
Logging output
BinanceWebSocketApiManager.stream_is_crashing(6964d0da0e76-d863-7a1f-1e7e-e8a79efb)
BinanceWebSocketApiManager._create_stream_thread() stream_id=6964d0da0e76-d863-7a1f-1e7e-e8a79efb - RuntimeError `error: 11` - error_msg: cannot schedule new futures after interpreter shutdown - Please create an issue: https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/issues/new/choose
Processing method?
stream_buffer
Used endpoint?
binance.com-coin_futures
Issue
Program just stopped running after I received this error message