binance.com-coin-futures trade channel does not stream
See original GitHub issueCheck 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
- 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.
Cable, with 177Mbps download, 5 Mbps upload.
Average system load (CPU)
Include here the amount of cpu cores and the average system load.
4 Core i-7 Intel
Hardware specification
Include here a description of the server hardware.
Operating System? (include version)
- macOS
- Windows
- [x ] Linux (include flavour) Ubuntu
Options
- 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
binance.com-coin-futures
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'
Tested on 3.9.6 and 3.8.11, both does not work.
Pip Version?
Include here the response of 'python3 -m pip --version' or 'pip3 --version'
pip 21.0.1
Dependencies
Run pip list > pip_list.txt
and upload the file.
Package Version
aniso8601 9.0.1 appdirs 1.4.4 argcomplete 1.12.3 certifi 2021.5.30 charset-normalizer 2.0.4 cheroot 8.5.2 click 8.0.1 colorama 0.4.4 distlib 0.3.1 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.8.0 numpy 1.21.2 packaging 21.0 pandas 1.3.2 pathlib 1.0.1 pip 21.0.1 pipx 0.16.3 psutil 5.8.0 python-dateutil 2.8.2 pytz 2021.1 requests 2.26.0 setuptools 52.0.0.post20210125 six 1.16.0 ujson 4.1.0 unicorn-binance-websocket-api 1.32.0 unicorn-fy 0.11.0 urllib3 1.26.6 userpath 1.6.0 virtualenv 20.4.2 websocket-client 1.2.1 websockets 9.1 Werkzeug 2.0.1 wheel 0.37.0
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
Latest up to now.
Description of your issue
Include the contents of the log file here. (REMOVE API_KEY, API_SECRET, LISTEN_KEY!!)
Code Used
from unicorn_binance_websocket_api.unicorn_binance_websocket_api_manager import BinanceWebSocketApiManager
import logging
import time
import threading
import os, json
# https://docs.python.org/3/library/logging.html#logging-levels
logging.basicConfig(level=logging.INFO,
filename=os.path.basename(os.path.dirname(os.path.realpath('__file__'))) + '.log',
format="{asctime} [{levelname:8}] {process} {thread} {module}: {message}",
style="{")
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 False:
time.sleep(0.01)
else:
print(oldest_stream_data_from_stream_buffer)
binance_futures_websocket_api_manager = BinanceWebSocketApiManager(exchange="binance.com-coin-futures")
channels = {'trade'}
markets = {'btcusdt'}
# create stream
trade_stream_id = binance_futures_websocket_api_manager.create_stream(channels, markets)
worker_thread = threading.Thread(target=print_stream_data_from_stream_buffer, args=(binance_futures_websocket_api_manager,))
worker_thread.start()
worker_thread.join()
Issue is that the terminal only output
{"id":1,"result":null}
without outputting any trades. Log file
2021-08-24 21:07:21,697 [INFO ] 97719 139809439859584 unicorn_binance_websocket_api_manager: New instance of unicorn-binance-websocket-api_1.32.0-python_3.8.11 on Linux 5.11.0-31-generic for exchange binance.com-coin-futures started ...
2021-08-24 21:07:21,697 [INFO ] 97719 139809439859584 unicorn_binance_websocket_api_manager: Using `stream_buffer`
2021-08-24 21:07:21,697 [INFO ] 97719 139809382258240 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager._frequent_checks() new instance created with frequent_checks_id=1629864441.69786
2021-08-24 21:07:21,698 [INFO ] 97719 139809305654848 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager._keepalive_streams() new instance created with keepalive_streams_id=1629864441.6985614
2021-08-24 21:07:22,498 [INFO ] 97719 139809439859584 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.create_stream({'trade'}, ['btcusdt'], None, False, False) with stream_id=f5131bd7-e01c-4a28-acda-c8b7ba4f0e17
2021-08-24 21:07:22,498 [INFO ] 97719 139809439859584 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager._add_stream_to_stream_list(f5131bd7-e01c-4a28-acda-c8b7ba4f0e17, {'trade'}, ['btcusdt'], None, False, None, False)
2021-08-24 21:07:22,499 [INFO ] 97719 139809390650944 unicorn_binance_websocket_api_socket: BinanceWebSocketApiSocket.start_socket(f5131bd7-e01c-4a28-acda-c8b7ba4f0e17, {'trade'}, ['btcusdt']) socket_id=d7251163-f21c-473c-bfaf-84b9679b1cae recent_socket_id=d7251163-f21c-473c-bfaf-84b9679b1cae
2021-08-24 21:07:22,500 [INFO ] 97719 139809390650944 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.subscribe_to_stream(f5131bd7-e01c-4a28-acda-c8b7ba4f0e17, {'trade'}, ['btcusdt']) started ...
2021-08-24 21:07:22,500 [INFO ] 97719 139809390650944 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.create_payload(f5131bd7-e01c-4a28-acda-c8b7ba4f0e17, ['trade'], ['btcusdt']) started ...
2021-08-24 21:07:22,501 [INFO ] 97719 139809390650944 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.create_payload(f5131bd7-e01c-4a28-acda-c8b7ba4f0e17, ['trade'], ['btcusdt']) - Payload: [{'method': 'SUBSCRIBE', 'params': ['btcusdt@trade'], 'id': 1}]
2021-08-24 21:07:22,501 [INFO ] 97719 139809390650944 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.create_payload(f5131bd7-e01c-4a28-acda-c8b7ba4f0e17, ['trade'], ['btcusdt']) finished ...
2021-08-24 21:07:22,501 [INFO ] 97719 139809390650944 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.subscribe_to_stream(f5131bd7-e01c-4a28-acda-c8b7ba4f0e17, ['trade'], ['btcusdt']) finished ...
2021-08-24 21:07:22,501 [INFO ] 97719 139809390650944 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager.create_websocket_uri({'trade'}, ['btcusdt'], , False) - Created websocket URI for stream_id=f5131bd7-e01c-4a28-acda-c8b7ba4f0e17 is wss://dstream.binance.com/stream?streams=btcusdt@trade
2021-08-24 21:07:24,324 [INFO ] 97719 139809390650944 unicorn_binance_websocket_api_socket: BinanceWebSocketApiSocket.start_socket(f5131bd7-e01c-4a28-acda-c8b7ba4f0e17, {'trade'}, ['btcusdt'] socket_id=d7251163-f21c-473c-bfaf-84b9679b1cae recent_socket_id=d7251163-f21c-473c-bfaf-84b9679b1cae - Sending payload started ...
2021-08-24 21:07:24,324 [INFO ] 97719 139809390650944 unicorn_binance_websocket_api_socket: BinanceWebSocketApiSocket.start_socket(f5131bd7-e01c-4a28-acda-c8b7ba4f0e17, {'trade'}, ['btcusdt'] - Sending payload: {'method': 'SUBSCRIBE', 'params': ['btcusdt@trade'], 'id': 1}
2021-08-24 21:07:24,730 [INFO ] 97719 139809390650944 unicorn_binance_websocket_api_socket: BinanceWebSocketApiSocket.start_socket(f5131bd7-e01c-4a28-acda-c8b7ba4f0e17) - Received result message: {"id":1,"result":null}
2021-08-24 21:07:25,009 [INFO ] 97719 139809382258240 unicorn_binance_websocket_api_manager: BinanceWebSocketApiManager._frequent_checks() - reached new `highest_receiving_speed` 71 B/s at 2021-08-25, 04:07:25 UTC
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
OK problem solved. For future reference to avoid such low-level mistakes please check out the ticker names to match exactly with what’s available in the market. In this case, I should use
BTCUSD_PERP
. Thanks for the help Oliver. Happy trading!great! thanks for reporting the reason! best regards!