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.
Check this or we will delete your issue. (fill in the checkbox with an X like so: [x])
[x] I have searched for other issues with the same problem or similar feature requests.
Select one:
[x] Bug
[ ] Feature Request
[ ] Technical Help
[ ] Other
Environment
[x] Are you using the module on a VPS or other Cloud hosting?
[ ] Are you using the module on a Raspberry Pi?
What kind of internet connection do you have?
Include here a description of your internet access like cable, lte and up and download rate.
Average system load (CPU)
Include here the ammount of cpu cores and the average system load.
Hardware specification
Include here a description of the server hardware.
Operating System? (include version)
[ ] macOS
[ ] Windows
[X] Linux (include flavour)
Options
[x] stream_buffer
[ ] process_stream_data
Which endpoint do you connect?
Include here the endpint you are connecting to, like binance.com, binance.com-isolated_margin or binance.org-testnet
Python Version Requirement
[x] I am using Python 3.7 or above
Exact Python Version?
Include here the response of 'python --version' AND 'python3 --version'
python --version
Pip Version?
Include here the response of 'python3 -m pip --version' or 'pip3 --version'
pip 21.0.1 from /root/anaconda3/envs/binancebot/lib/python3.8/site-packages/pip (python 3.8)
Dependencies
Run pip list > pip_list.txt and upload the file.
Package 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
Include the contents of the log file here. (REMOVE API_KEY, API_SECRET, LISTEN_KEY!!)
`
from unicorn_binance_websocket_api.unicorn_binance_websocket_api_manager import BinanceWebSocketApiManager
import logging
import time
import os
print(f"FIFO START ##################################################")
i = 0
while i < 5:
oldest_stream_data_from_stream_buffer = binance_websocket_api_manager.pop_stream_data_from_stream_buffer(stream_buffer_name="buffer1")
if oldest_stream_data_from_stream_buffer is False:
time.sleep(0.01)
else:
if oldest_stream_data_from_stream_buffer is not None:
print(f"FIFO: {oldest_stream_data_from_stream_buffer}")
i += 1
print(f"LIFO START ##################################################")
i = 0
while i < 5:
oldest_stream_data_from_stream_buffer = binance_websocket_api_manager.pop_stream_data_from_stream_buffer(stream_buffer_name="buffer2",
mode="LIFO")
if oldest_stream_data_from_stream_buffer is False:
time.sleep(0.01)
else:
if oldest_stream_data_from_stream_buffer is not None:
print(f"LIFO: {oldest_stream_data_from_stream_buffer}")
i += 1
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?
Average system load (CPU)
Hardware specification
Operating System? (include version)
Options
Which endpoint do you connect?
Python Version Requirement
Exact Python Version?
Pip Version?
Dependencies
Run
pip list > pip_list.txt
and upload the file. Package Versionaniso8601 9.0.1 certifi 2021.5.30 charset-normalizer 2.0.6 cheroot 8.5.2 click 8.0.1 colorama 0.4.4 Flask 2.0.1 Flask-RESTful 0.3.9 idna 3.2 itsdangerous 2.0.1 jaraco.functools 3.3.0 Jinja2 3.0.1 MarkupSafe 2.0.1 more-itertools 8.10.0 pathlib 1.0.1 pip 21.0.1 psutil 5.8.0 pytz 2021.1 requests 2.26.0 setuptools 58.0.4 six 1.16.0 ujson 4.2.0 unicorn-binance-websocket-api 1.34.0 unicorn-fy 0.11.0 urllib3 1.26.7 websocket-client 1.2.1 websockets 10.0 Werkzeug 2.0.1 wheel 0.37.0
UNICORN Binance WebSocket API Version?
Description of your issue
` from unicorn_binance_websocket_api.unicorn_binance_websocket_api_manager import BinanceWebSocketApiManager import logging import time import os
# https://docs.python.org/3/library/logging.html#logging-levels
logging.basicConfig(level=logging.ERROR, 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", stream_buffer_maxlen=3)
binance_websocket_api_manager.create_stream('kline_1m', 'btcusdt', stream_buffer_name="buffer1", stream_buffer_maxlen=4, output="UnicornFy")
binance_websocket_api_manager.create_stream('kline_1m', 'ethusdt', stream_buffer_name="buffer2", stream_buffer_maxlen=4, output="UnicornFy")
time.sleep(4) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"clearing...") binance_websocket_api_manager.clear_stream_buffer(stream_buffer_name="buffer1") binance_websocket_api_manager.clear_stream_buffer(stream_buffer_name="buffer2") print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}") time.sleep(1) print(f"sb-len: {binance_websocket_api_manager.get_stream_buffer_length()}")
print(f"FIFO START ##################################################") i = 0 while i < 5: oldest_stream_data_from_stream_buffer = binance_websocket_api_manager.pop_stream_data_from_stream_buffer(stream_buffer_name="buffer1") if oldest_stream_data_from_stream_buffer is False: time.sleep(0.01) else: if oldest_stream_data_from_stream_buffer is not None: print(f"FIFO: {oldest_stream_data_from_stream_buffer}") i += 1
print(f"LIFO START ##################################################") i = 0 while i < 5: oldest_stream_data_from_stream_buffer = binance_websocket_api_manager.pop_stream_data_from_stream_buffer(stream_buffer_name="buffer2", mode="LIFO") if oldest_stream_data_from_stream_buffer is False: time.sleep(0.01) else: if oldest_stream_data_from_stream_buffer is not None: print(f"LIFO: {oldest_stream_data_from_stream_buffer}") i += 1
binance_websocket_api_manager.stop_manager_with_all_streams() `