All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
Discussions about unicorn-binance-websocket-api releases!
How to upgrade to the latest version!
- New
Websocket API Spot
functions:manager.api.spot.cancel_and_replace_order()
manager.api.spot.get_aggregate_trades()
manager.api.spot.get_current_average_price()
manager.api.spot.get_historical_trades()
manager.api.spot.get_klines()
manager.api.spot.get_ui_klines()
manager.api.spot.get_recent_trades()
manager.api.spot.get_unfilled_order_count()
- Full Support for
Websocket API Futures
:manager.api.futures.cancel_order()
manager.api.futures.create_order()
manager.api.futures.get_account_balance()
(v1+v2)manager.api.futures.get_account_position()
(v1+v2)manager.api.futures.get_account_status()
(v1+v2)manager.api.futures.get_listen_key()
manager.api.futures.get_order()
manager.api.futures.get_order_book()
manager.api.futures.get_ticker_order_book()
manager.api.futures.get_ticker_price()
manager.api.futures.get_server_time()
manager.api.futures.modify_order()
manager.api.futures.ping()
- Error handling if someone tries to use the WebSocket API Feature with an unsupported exchange.
- ujson has been replaced by orjson (faster!)
- Websocket API functions are no longer available under
manager.api
but undermanager.api.spot
. In addition, there is now alsomanager.api.futures
. - No more use of deepcopy in ws api (faster!)
- Enhanced logging in WS API
- Log levels in
send_with_stream()
to be less verbose. - Dropping support for Python 3.7
AttributeError: 'NoneType' object has no attribute 'get'
inget_latest_version()
.
clear_asyncio_queue()
- Made the logic of
is_exchange_type()
better readable. - Type of parameter
stream_buffer_name
in all methods.
get_latest_version()
KeyError.
- Obsolete import
from __future__ import print_function
insockets.py
.
- Stream Data is always returned in
raw_data
format. issue#380
- Parameter
footer
toprint_summary()
,print_summary_to_png()
andprint_stream_info()
- Improved text of
MaximumSubscriptionsExceeded
exception. - Updated description text in all files.
- Import in
licensing_manager.py
. - Type of global
logger
andconnect
variable.
- Set higher minimum version
2.31.0
forrequests
, as vulnerabilities were found in earlier versions:- CVE-2023-32681, Score: 6.1 (Medium)
- Requests is a HTTP library. Requests has been leaking Proxy-Authorization headers to destination servers when
redirected to an HTTPS endpoint. This is a product of how we use
rebuild_proxies
to reattach theProxy-Authorization
header to requests. For HTTP connections sent through the tunnel, the proxy will identify the header in the request itself and remove it prior to forwarding to the destination server. However when sent over HTTPS, theProxy-Authorization
header must be sent in the CONNECT request as the proxy has no visibility into the tunneled request. This results in Requests forwarding proxy credentials to the destination server unintentionally, allowing a malicious actor to potentially exfiltrate sensitive information. This issue affects versions 2.3.0 through 2.30.0. - https://devhub.checkmarx.com/cve-details/CVE-2023-32681/
- Requests is a HTTP library. Requests has been leaking Proxy-Authorization headers to destination servers when
redirected to an HTTPS endpoint. This is a product of how we use
- CVE-2023-32681, Score: 6.1 (Medium)
- Set higher minimum version
2.5.1
forunicorn-binance-rest-api
are affected by vulnerabilities in used dependencies!- Dependency
certifi
:- CVE-2023-37920, Score: 9.8 (High)
- Certifi is a curated collection of Root Certificates for validating the trustworthiness of SSL certificates while verifying the identity of TLS hosts. Certifi 1.0.1 through 2023.5.7 recognizes "e-Tugra" root certificates. e-Tugra's root certificates were subject to an investigation prompted by reporting of security issues in their systems. Certifi 2023.07.22 removes root certificates from "e-Tugra" from the root store.
- https://devhub.checkmarx.com/cve-details/CVE-2023-37920/
- CVE-2023-37920, Score: 9.8 (High)
- Dependency
cryptography
:- CVE-2023-38325, Score: 7.5 (High)
- The cryptography package versions prior to 41.0.2 for Python mishandles SSH certificates that have critical options.
- https://devhub.checkmarx.com/cve-details/CVE-2023-38325/
- CVE-2023-49083, Score: 7.5 (High)
- Cryptography is a package designed to expose cryptographic primitives and recipes to Python developers. Calling
load_pem_pkcs7_certificates
orload_der_pkcs7_certificates
could lead to a NULL-pointer dereference and segfault. Exploitation of this vulnerability poses a serious risk of Denial of Service (DoS) for any application attempting to deserialize a PKCS7 blob/certificate. The consequences extend to potential disruptions in system availability and stability. This issue affects versions 3.1 through 41.0.5. - https://devhub.checkmarx.com/cve-details/CVE-2023-49083/
- Cryptography is a package designed to expose cryptographic primitives and recipes to Python developers. Calling
- CVE-2023-50782, Score: 7.5 (High)
- A flaw was found in the python cryptography package versions prior to 42.0.0. This issue may allow a remote attacker to decrypt captured messages in TLS servers that use RSA key exchanges, which may lead to exposure of confidential or sensitive data. This issue is an incomplete fix of CVE-2020-25659.
- https://devhub.checkmarx.com/cve-details/CVE-2023-50782/
- CVE-2024-26130, Score: 7.5 (High)
- cryptography is a package designed to expose cryptographic primitives and recipes to Python developers. Starting
in version 38.0.0 and prior to version 42.0.4, if
pkcs12.serialize_key_and_certificates
is called with both a certificate whose public key did not match the provided private key and anencryption_algorithm
withhmac_hash
set (viaPrivateFormat.PKCS12.encryption_builder().hmac_hash(...)
, then a NULL pointer dereference would occur, crashing the Python process. This has been resolved in version 42.0.4, the first version in which aValueError
is properly raised. - https://devhub.checkmarx.com/cve-details/CVE-2024-26130/
- cryptography is a package designed to expose cryptographic primitives and recipes to Python developers. Starting
in version 38.0.0 and prior to version 42.0.4, if
- CVE-2023-38325, Score: 7.5 (High)
- Dependency
requests
:- CVE-2023-32681, Score: 6.1 (Medium)
- Requests is a HTTP library. Requests has been leaking Proxy-Authorization headers to destination servers when
redirected to an HTTPS endpoint. This is a product of how we use
rebuild_proxies
to reattach theProxy-Authorization
header to requests. For HTTP connections sent through the tunnel, the proxy will identify the header in the request itself and remove it prior to forwarding to the destination server. However when sent over HTTPS, theProxy-Authorization
header must be sent in the CONNECT request as the proxy has no visibility into the tunneled request. This results in Requests forwarding proxy credentials to the destination server unintentionally, allowing a malicious actor to potentially exfiltrate sensitive information. This issue affects versions 2.3.0 through 2.30.0. - https://devhub.checkmarx.com/cve-details/CVE-2023-32681/
- Requests is a HTTP library. Requests has been leaking Proxy-Authorization headers to destination servers when
redirected to an HTTPS endpoint. This is a product of how we use
- CVE-2023-32681, Score: 6.1 (Medium)
- Dependency
- Exception
MaximumSubscriptionsExceeded
thrown bysubscribe_to_stream()
. print_summary()
andprint_stream_info()
now displaybinance_api_status_code
in color! Green at 200 otherwise red.
subscribe_to_stream()
now throws the exceptionMaximumSubscriptionsExceeded
instand of returningFalse
if
the number of allowed subscriptions per stream is exceeded.
- Typing of
create_stream()
parameters. - Type of parameter
stream_label
inget_stream_id_by_label()
. - Type of first return variable in
restclient.get_listen_key()
. - Typo in
is_update_availabe_unicorn_fy()
tois_update_available_unicorn_fy()
. - Typo in
is_update_availabe_check_command()
tois_update_available_check_command()
. - A couple of small text typos.
- Better Logging to investigate issue#374
send_with_stream()
- Send a payload with a specific stream.- Since UBWA is delivered as a compiled C extension, IDEs such as Pycharm and Visual Code cannot use information about available methods, parameters and their types for autocomplete and other intellisense functions. As a solution, from now on stub files (PYI) will be created in the build process and attached to the packages. The IDEs can automatically obtain the required information from these.
- Replaced all calls of
add_payload_to_stream()
inmanager.py
,api.py
withsend_with_stream()
. - Calling
set_socket_is_not_ready()
insockets.__aexit__()
. - Consistent use of
stream_list_lock
and replacement ofstream_threading_lock
bystream_list_lock
inmanager.py
.
Functionally, nothing changes with this update. However, there are now sensible error messages if errors occur in the
code of the process_asyncio_queue
-coroutine.
- Solved
Tracebacks of process_asyncio_queue-coroutines
issue#375
Optimization of the performance and revision of the life support of the ListenKey.
- The management methods are no longer started individually in threads but together in an event loop in 'run()'. By
switching from threads to AsyncIO tasks, some
time.sleep()
could be replaced byasyncio.sleep()
- In
_run_sockets()
time.sleep()
was mistakenly used instead ofasyncio.sleep()
. - Keeping the ListenKey alive has been revised and now runs as an asyncIO task in the event loop of the stream. In the event of an exception due to an IP ban, the time window until the ban is lifted is extracted from the Binance response and now waits until then to continue. issue#330
- Added exception handling for
TypeError
tosubscribe_to_stream()
andunsubscribe_from_stream()
.
Redesign and rewrite of connection.py
, sockets.py
as well as the loop and exception handling in manager.py
and
support for await get_stream_data_from_asyncio_queue(stream_id)
.
Runs perfectly on Python 3.7 to 3.12 on Windows, Linux and Mac!
ubwa.api.get_listen_key()
- Unit tests for python 3.7 to 3.12, extension of the tests.
- Support and use of an
asyncio.queue()
. The parameter "process_asyncio_queue" forBinanceWebSocketApiManager()
andcreate_stream()
can be passed an async function, which is automatically added to the event loop of the websocket as an async task. Received websocket data can be conveniently awaited withawait get_stream_data_from_asyncio_queue(stream_id)
as an AsyncIO alternative topop_stream_data_from_stream_buffer()
. This is probably the smartest way to process data from the websocket and should be preferred to the stream_buffer and the callback function. is_socket_ready()
- Updated from websockets 10.4 to 11.0.3.
pop_stream_data_from_stream_buffer()
returnsNone
instead ofFalse
- The parameter
throw_exception_if_unrepairable
was removed by the UBWA Manager and replaced by the stream_signalSTREAM_UNREPAIRABLE
.
Info: https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/wiki/%60stream_signals%60 - Many
False
values have been changed toNone
values in accordance with Python conventions. shutdown_asyncgens()
to_shutdown_asyncgens()
run_socket()
to_run_socket()
_auto_data_cleanup_stopped_streams()
now performs a check every 60 seconds and deletes the data from streams that have been stopped for more than 900 seconds.datetime.utcfromtimestamp(stream_info['start_time']).strftime('%Y-%m-%d, %H:%M:%S UTC'))
is obsolete and has been replaced bydatetime.fromtimestamp(timestamp, timezone.utc).strftime('%Y-%m-%d, %H:%M:%S UTC')
.- Renamed
stop_stream_as_crash()
with_crash_stream()
- Renamed
is_stop_as_crash_request()
withis_crash_request()
- Renamed
stream_is_crashing()
with_stream_is_crashing()
- Renamed
stream_is_stopping()
with_stream_is_stopping()
- In Websocket API wrong method names were used in logging.
- Logging info in
connection.py
revised. ubwa.api.get_open_orders()
can now be used without thesymbol
parameter to query all open orders.- Completely revised the error handling.
- Parameter
throw_exception_if_unrepairable
ofBinanceWebSocketApiManager()
. - Exception
StreamRecoveryError
. set_restart_request()
_restart_stream()
_keepalive_streams()
kill_stream()
This update is primarily aimed at stabilization. The loop management has been improved and runs absolutely fine in tests!
unicorn-binance-websocket-api
can now also be installed on all architectures on which there are no precompiled
packages from LUCIT. PIP now automatically recognises whether there is a suitable precompiled package and if not,
the source is automatically compiled on the target system during the installation process with Cython. Even if you
don't have to do anything special, please note that this process takes some time!
- Parameter
process_stream_data_async
inmanager.py
toBinanceWebSocketApiManager()
as global setting parameter and tocreate_stream()
as stream specific parameter. This means it is possible to provide a global and a stream specific asyncio function as "process_stream_data" function. - Support for
process_stream_data_async
andspecific_process_stream_data_async[stream_id]
tosocket.py
. - Support for
with-context
toBinanceWebSocketApiSocket()
. run_socket()
tomanager.py
.shutdown_asyncgens()
tomanager.py
.timeout
parameter (float) todelete_stream_from_stream_list()
,wait_till_stream_has_stopped()
andwait_till_stream_has_started()
with default value 10.0 seconds.- Automatic data cleanup of stopped web streams. issue#307
The UBWA Manager can be informed via the parameter
auto_data_cleanup_stopped_streams=True
that all remaining data within the UBWA of a stopped stream should be automatically and completely deleted (duration 60 sec). Default value isFalse
. Also added the functionremove_all_data_of_stream_id()
and_auto_data_cleanup_stopped_streams()
which are doing the cleaning up job.
- Parameter
process_stream_data
inmanager.py
fromFalse
toNone
. - Parameter
process_stream_signals
inmanager.py
fromFalse
toNone
. - Usage of
BinanceWebSocketApiSocket()
inmanager.py
by using the newwith-context
andubwa.run_socket()
to close every websocket connection when leaving. - Now using
wait_till_stream_has_stopped()
indelete_stream_from_stream_list()
. This avoids many errors ;) - Rewrite of the
try-except
and thefinally
code part for the loop handling in_create_stream_thread()
.
- Missing
await
ofwebsocket.close()
insocket.py
. - Event loops were not closed in rare situations. Adjustments to
_create_stream_thread()
,create_stream()
and_restart_stream()
- In
connection.py
sys.exit()
statements were used within an asyncio loop, this prevented the correct closing of the asyncio loops in rare cases and was replaced byreturn False
.
import sys
insockets.py
- Websocket API:
create_order()
andcreate_test_order()
- Support of parameterquoteOrderQty
, Behavior: If activated, it replaces thequantity
parameter.
- Websocket API:
create_order()
andcreate_test_order()
- issue#353 and issue#352 - Websocket API:
create_order()
andcreate_test_order()
-trailingDelta
is only used ifstopPrice
was not specified. - Binance futures testnet userData stream in
restclient.py
- issue#347
- Troubleshooting restart problems
manager.delete_listen_key_by_stream_id()
usedFalse
instead ofNone
RuntimeError: dictionary changed size during iteration
inmanager.stop_manager()
.- Stopping
manager._restart_stream()
if manager is stopping.
- Rewrite of
restclient.py
and implementing usage of**params
withUBRA
. False
andNone
was used incorrectly in some cases, this has been unified.
manager.wait_till_stream_has_stopped()
- Handling of not retrieved error messages in AsyncIO loops
- Debug mode for AsyncIO tasks
manager.stop_manager()
alias formanager.stop_manager_with_all_streams()
- Support for
with
-context
- Exceptions in
socket.start_stocket() coroutine and replaced
sys.exit()with
return False` - AsyncIO Loop handling and closing
- Graceful shutdown in exception
UnknownExchange
manager.wait_till_stream_has_started()
- Support for Python 3.11 and 3.12
- Integration of the
lucit-licensing-python
library for verifying the UNICORN Binance Suite license. A license can be purchased in the LUCIT Online Shop: https://shop.lucit.services/software/unicorn-binance-suite - License change from MIT to LSOSL - LUCIT Synergetic Open Source License: https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/blob/master/LICENSE
- Conversion to a C++ compiled Cython package with precompiled as well as PyPy and source code wheels.
- Setup of a "Trusted Publisher" deployment chain. The source code is transparently packaged into wheels directly from the GitHub repository by a GitHub action for all possible platforms and published directly as a new release on GitHub and PyPi. A second process from Conda-Forge then uploads it to Anaconda. Thus, the entire deployment process is transparent and the user can be sure that the compilation of a version fully corresponds to the source code.
- Added
@staticmethod
to many static mehtods.
- Typos and formatting
- Shadow of a Python built-in in
manager.get_human_bytesize()
:bytes
toamount_bytes
manager.get_new_uuid_id()
returned not str()
- Issue in
api.get_exchange_info()
: #346
- Issue with separation of spot and margin accounts: #331
get_the_one_active_websocket_api()
to manger.py- Logging to
get_stream_id_by_label()
process_response
parameter toubwa.api
methods to provide specific callback functions for specific responsesreturn_response
parameter toubwa.api
methods to let the used method wait till the requested data is received via websocket, and then it returns it.
- Use UnicornFy only for non api requests in sockets.py - if
output="UnicornFy"
is used for api then its just converted to a python dict. ubwa.api
methods do not need astream_id
/stream_label
if there is only one valid websocket api. (Self-discovery of uniquely identifiable websocket api streams if nostream_id
orstream_label
was specified for identification.)- Renamed
ubwa.api.test_create_order()
toubwa.api.create_test_order()
- Entire WS API implementation reworked
- Support for
new_client_order_id
increate_test_order()
- Get listenKey from Binance API for futures and coin futures userData stream
- jex.com support
- Python 3.7+ Support
- ws_api.py to api.py
- Revised ws_api.py .... Websocket API is still BETA and not fully ready!! Please share your experience and ideas to improve the implementation: #319
- This is the first code part to support the new Binance Websocket API
issue#319:
WEBSOCKET_API_BASE_URI
to connection_settings.py and added URI for spot and testnet:wss://ws-api.binance.com/ws-api/v3
andwss://testnet.binance.vision/ws-api/v3
- Upgraded
print_stream_info()
to show if a userData stream is a Websocket API stream or not. - New methods to manager.py
get_timestamp()
,generate_signature()
,order_params()
,add_payload_to_stream
- ws_api.py to provide Binance websocket api functions in
ubwa.api.method(stream_id=stream_id)
.ubwa.api.cancel_open_orders()
ubwa.api.cancel_order()
ubwa.api.create_order()
ubwa.api.get_account_status()
ubwa.api.get_exchange_info()
ubwa.api.get_open_orders()
ubwa.api.get_order()
ubwa.api.get_order_book()
ubwa.api.get_server_time()
ubwa.api.ping()
create_stream(channels=[], markets=[])
initiated as lists and are not mandatory anymore to enable the use of parameterapi
to create a Websocket API stream.
- Passing the variable
warn_on_update
to UBRA
- Saving
binance_api_status
update indelete_listen_key()
andkeepalive_listenkey()
did not work after the integration of UBRA
BinanceRestApiManager()
- New parameter:socks5_proxy_user
andsocks5_proxy_pass
- Dependency
unicorn-binance-rest-api
tosetup.py
,requirements.txt
,environment.yml
and conda feedstock recipe socks5_proxy_user
andsocks5_proxy_pass
toBinanceWebSocketApiManager
- Full SOCKS5 Proxy support to REST API in
get_listen_key()
,keepalive_listen_key()
anddelete_listen_key()
- Show proxy info in
print_summary()
andprint_stream_info()
restclient.py
now relies onunicorn-binance-rest-api>=1.8.0
. REST config removed inconnection_settings.py
- Structure of
CONNECTION_SETTINGS
- RuntimeError: dictionary changed size during iteration in manger.py line 788, https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/commit/f189b9a8420133ffe34e9c9948e461a06d92f0a2
keepalive_listen_key()
anddelete_listen_key()
for isolated margin- Activated functionality of
restful_base_uri
in rest client - SOCKS5 proxy support only worked with one stream. Now it works with multiple streams.
restful_path_userdata
fromBinanceWebSocketApiManager
- Restore backward compatibility Python >= 3.7 issue#311
- Remove "Assignment Expressions in f-strings" to restore Python Support 3.7+.
- Added whitespace between left "=" and title in first line of
manager.print_summary()
output.
- Fix typo "bug" in dependencies of setup.py
- Official support for Python 3.11
- Socks5 proxy support for websocket only:
socks5_proxy_server
andsocks5_proxy_ssl_verification
and exceptionSocks5ProxyConnectionError
- Currently, no REST support forlistenKey
(needed for userData streams), this will be added later after the next UBRA update! - Logging to
manager.wait_till_stream_has_started()
- Logging to
manager.wait_till_stream_has_stoped()
- Added PR#305 of
issue#304 thx to
@dima-dmytruk23:
New parameters to override connection settings to
BinanceWebSocketApiManager
:websocket_base_uri
,max_subscriptions_per_stream
,restful_base_uri
,restful_path_userdata
,exchange_type
- "binance.com-coin-futures" to choose coin futures is deprecated. Use "binance.com-coin_futures" instead!
- Better "stop" measuring in
manager.wait_till_stream_has_stoped()
discussion#279
- Parameter
delete_listen_key
tostop_stream()
, so it's possible to disable the deletion of thelisten_key
- The new
listen_key
keep alive interval is 10 min, with 30 min we have expired listenKeys in some cases. issue#275 websockets
version 10.3 to 10.4- Log level error to debug issue#277
- socket.py typo in
unicorn_fy.trbinance_com_websocket()
manager.get_stream_buffer_byte_size()
avoid division by zero error- "Stream data not udpated after got event "listenKeyExpired" issue#275
debug
(bool) parameter toBinanceWebSocketApiManager()
manager.get_debug_log()
manager.set_socket_is_ready()
manager.set_socket_is_not_ready()
_handle_task_result()
- a callback for eventtasks to retrive exceptions from within the asyncio loop.
get_new_stream_id()
toget_new_uuid_id()
- Improved exception handling and restarts. This should have also positive effects to exection handling within the callback functions.
- AsyncIO implementation and a temporary workaround for stopping userData streams
- TRBinance replaced old URL
stream.binance.cc
by the new URLstream-cloud.trbinance.com
issue#249
Codebase equal to 1.40.5, testing azure pipe
- Exclude
tools
folder from package
Codebase equal to 1.40.5, just preparing conda-forge packaging
- Restart of error
sent 1011 (unexpected error) keepalive ping timeout
in sockets.py
- Rebalanced default ping interval and timeout as well as closing timeout
- Passing of
stream_buffer_name=stream_buffer_name
tospecific_process_stream_data()
- Not catching general eception anymore - we must catch the specific exceptions:
- Catch KeyError before the general exception in sockets to give better feedback within the callback function.
- Error in coroutine loop handling
- default ping interval and timeout
TypeError
inprint_summary()
- typo in
print_summary()
title
text - Callback implementation of
create_stream()
- test release
close_timeout_default
,ping_interval_default
,ping_timeout_default
socket_is_ready
system to_restart_stream()
process_stream_data
parameter for callback function tocreate_stream()
high_performance
parameter to makecreate_stream()
a non blockingtitle
toprint_summary()
andprint_stream_info()
BinanceWebSocketApiManager.stop_stream()
doesn't stop the stream immediately issue#161
- Send the
DISCONNECT
stream_signal only on status change (one time!) and if previous status is not None
- KeyError in
get_listen_key_from_restclient()
ifstream_id
invalid - Added
socket_is_ready
tostream_is_crashing()
- Websocket fails to reconnect issue#131
is_stream_signal_buffer_enabled()
stream_is_crashing()
did not send stream_signalDISCONNECT
- Without this fix no stream_signal was sent in some disconnect cases!
- Replaced the time.sleep() in create_stream with self.socket_is_ready system
- Catching
KeyError
inmanager.get_stream_buffer_length()
if buffer_name not exits
get_stream_buffer_length()
can now return the size of all stream_buffers and also of a specific stream_buffer.
- Bump websockets from 10.1 to 10.2 PR#237
- UnboundLocalError: local variable 'error_msg' referenced before assignment in sockets.py line 209 reported in issue#235
- Avoid error 2 of this post: #131 (comment)
- removed "unicorn_binance_websocket_api_"-part of the module file names (more info: Discussions)
- renamed logger name of all modules to "unicorn_binance_websocket_api", in the implementation of PR#223 every module has had its own logger name.
manager.get_new_stream_id()
to avoid security alerts like "CodeQL py/clear-text-logging-sensitive-data"
stream_id
is no longer an uuid, but a string from now on!- Correctly scope loggers so that it plays nicely with others. PR#223, issue#164
- Removed pathlib from requirements PR#224
- Moved from https://github.com/oliver-zehentleitner to https://github.com/LUCIT-Systems-and-Development/
- asyncio.TimeoutError issue#221
- Support for the new compression feature introduced in websockets10.0 because the new feature is removed in further websockets versions
- "binance.com-coin-futures" to "binance.com-coin_futures"
- fix "Default argument value is mutable" error of
subscribe_from_stream()
- No data received from binance.com-coin-futures with websockets==10.0 issue#208
- Exception handling for
websockets.exceptions.NegotiationError
in connection class.
- Logging of
restclient._request()
- No data received from binance.com-futures with websockets==10.0 issue#199
- Bump websockets from 9.1 to 10.0 - Drop support for Python 3.6, added support for Python 3.10! PR#195
- Logging websockets version on start up (logging level: INFO)
print_summary()
"most" to "peak".
- More accurate measurement of the received data quantity.
process_stream_signals
callback support issue#160
self.stream_signal_buffer
is not a list anymore, it's changed tocollections.deque()
Now stream_buffer
can be used as FIFO or LIFO stack, and it's possible to define a max length for it.
clear_stream_buffer()
to delete all items on thestream_buffer
stack.get_stream_buffer_maxlen()
to get themaxlen
value of the stack.- Support for
stream_buffer_maxlen
in methods ofBinanceWebSocketApiManager()
class_create_stream_thread()
,print_stream_info()
,__init__()
,_add_stream_to_stream_list()
,_create_stream_thread()
,create_stream()
,replace_stream()
. - Support for FIFO and LIFO in
pop_stream_data_from_stream_buffer(mode="FIFO")
get_used_weight()
replacesget_binance_api_status()
self.stream_buffer
andself.stream_buffer[xxx]
are not lists anymore, their type has changed tocollections.deque()
- Added partial support for wss://dstream.binance.com - perpetual coin futures! PR#163 - Thanks to M3tz3l
- Bump websockets from 8.1 to 9.1 PR#176
- Exception Handling listen_key issue#143
- Unsubscribe_from_stream method doesn't handle uppercase symbols while subscribe_to_stream does issue#167
- binance.je support (Binance Jersey has ceased operations.)
get_event_loop_by_stream_id()
disable_colorama
inBinanceWebSocketApiManager()
: This is needed to make ubwa compatible with SwiftBar
- The asyncio event loop is now saved to
self.stream_list[stream_id]['event_loop']
- added
delete_listen_key_by_stream_id()
tostop_stream()
issue#161
General Exception
handling instart_socket()
PR#142 thx @gronastech and @lordofserenity- Support for trbinance.com Websockets
UnboundLocalError: local variable 'market' referenced before assignment
increate_websocket_uri()
PR#142 thx @gronastech and @lordofserenity
- the stream signal
DISCONNECT
includeslast_received_data_record
which returns nowNone
if there is no record available
- Cannot use
in
with RuntimeError, must convert to string first. PR#136 thx @Bosma
- Deprecated methods
set_private_api_config()
andget_websocket_uri_length()
timeout=10
toget_result_by_request_id()
: Wait fortimeout
seconds to receive the requested result or returnFalse
- logging the use of stream_buffer or process_stream_data and the used OS plattform
- individual
max_subscriptions_per_stream
for each endpoint stream_signal_buffer
to receive signals if a stream gets connected or disconnected- 'add_to_stream_signal_buffer()'
- 'pop_stream_signal_from_stream_signal_buffer()'
- Support for stream signals:
CONNECT
,DISCONNECT
,FIRST_RECEIVED_DATA
- max subscriptions of futures endpoints to 200 issue#127
- max subscriptions of jex endpoint to 10
- Added a gracefull shutdown if the Python interpreter dies issue#131
- parameter
ping_interval
,ping_timeout
,close_timeout
tomanager.create_stream()
andreplace_stream()
- show
ping_interval
,ping_timeout
,close_timeout
inprint_stream_info()
manager.set_heartbeat()
toconnection.send()
get_result_by_request_id()
- log warning about high cpu usage is logged after 5 seconds if > 95%
get_stream_subscriptions()
returns now the usedrequest_id
instead ofTrue
output_default
toBinanceWebSocketApiManager
- unused import of
ujson
in connection class - 4 parameters from
_create_stream_thread
- timestamp to
receiving_speed_peak
in manager - log warning if the cpu usage is > 95%
- logging.info if new
highest_receiving_speed
is reached
listen_key
was printed to logfileslisten_key
cache time was not set inget_listen_key()
so it pinged immediately after its creation again, which caused a higher weight- restart stream if "The future belongs to a different loop than the one specified as the loop argument" issue#121
- renamed
_add_socket_to_socket_list
to_add_stream_to_stream_list
get_current_receiving_speed_global()
- better logging in socket class
highest_receiving_speed
inprint_summary()
- renamed variable
ubwa
tomanager
in restclient class - renamed variable
unicorn_binance_websocket_api_manager
tomanager
in socket class - renamed variable
total_receiving_speed
toaverage_receiving_speed
- renamed variable
unicorn_binance_websocket_api_connection
toconnection
- renamed variable
unicorn_binance_websocket_api_socket
tosocket
- shorted user agent string for rest and websocket client
- removed the sending of the payload in aenter in connection class, from now on its only done in the socket class!
is_update_availabe_unicorn_fy()
andget_version_unicorn_fy()
new_output
toreplace_stream()
- Rewrite of
BinanceWebSocketApiRestclient()
, its more or less stateless but compatible to the current system. Now we use one instance globally instead of creating a new one every time we need it. It will help to implement isolated margin with more than one symbol. issue#111 time.sleep()
in_frequent_checks()
from 0.1 to 0.3 seconds
RuntimeError
exception in_create_stream_thread()
- no handling added, only logging and a "Todo"
dict
tocreate_stream(output='dict')
- StreamBuffer reset on restart issue#119
- Links in docstrings
- added KeyError exception and
return False
to a few methods - binance endpoints expects
symbol
notsymbols
- RuntimeException in
close()
- restclient:
symbol
tosymbols
- binance.com testnets (spot, margin, isolated_margin, future)
show_secrets_in_logs
parameter
symbol
tosymbols
(isolated_margin)
- update
binance_api_status
replace_stream()
: new_stream_label=None, new_stream_buffer_name=False, new_symbol=False, new_api_key=False, new_api_secret=False
- reconnect counter (bug since 1.17.0)
- Handling of unknown error msg from Binance if uri = dict in connection class
- reference of api_key and secret in connection class
- Isolated margin endpoints issue #109
- Support for
@arr@@s1
issue #101 - Added
symbol
toprint_stream_info()
- Added
api_key
andapi_secret
tocreate_stream()
issue #84
- Restart to ssl.SSLError exception in connection
- error 2 code PR #98 (Thanks Flowelcat)
- Restart again if OSError in
BinanceWebSocketApiConnection()
- Logging in
BinanceWebSocketApiConnection()
- Loglevels
- Fixed exception that thrown when api key is real but was deleted from binance. PR #96 (Thanks Flowelcat)
- Package configuration is wrong. Currently one needs to have the bin-folder of the venv in the PATH. That is not feasible since you often have one venv per project. PR #97 (Thanks uggel)
- REMOVED
- Loglevels
- Fixed double slash bug when getting listen key for userDataStream. PR #87
- Fixed RuntimeError in connection row 243 (added restart)
- restart if "with connection" in socket gets closed
- exception json.decoder.JSONDecodeError: respond = request_handler.json()
- Exception AttributeError Info: module 'asyncio.base_futures' has no attribute 'InvalidStateError' issue #72
- exception in
print_suammary()
- stream_buffer control: create_stream(channels, markets, stream_buffer_name=None):
If
False
the data is going to get written to the default stream_buffer, set toTrue
to read the data viapop_stream_data_from_stream_buffer(stream_id)
or provide a string to create and use a shared stream_buffer and read it viapop_stream_data_from_stream_buffer('string')
. add_to_ringbuffer_error()
add_to_ringbuffer_result()
set_ringbuffer_error_max_size()
set_ringbuffer_result_max_size()
get_errors_from_endpoints()
get_results_from_endpoints()
get_ringbuffer_error_max_size()
get_ringbuffer_result_max_size()
- renamed
restart_stream()
to_restart_stream
and execute it only with a valid restart_request
- Ensure that during a restart, only the recent thread is able to send the payload for subscription
- psutil (new requirement)
- exception handling of
websockets.exceptions.InvalidMessage
issue #72 - general exception handling
- show threads, memory and cpu usage in
print_summary()
get_process_usage_memory()
get_process_usage_cpu()
get_process_usage_threads()
- Close WS only if open in connection class row 190 issue #72
- some code in connection row 206 which is not needed anymore and is causing a coroutine error
is_websocket_uri_length_valid()
- new parameter
stream_label
inmanager.create_stream()
issue #60 manager.get_stream_label()
issue #60manager.get_stream_id_by_label()
issue #60manager.set_stream_label()
issue #60- added
stream_label
tomanager.print_stream_info()
issue #60 - added
stream_label
tomanager.print_summary()
issue #60 manager.help()
unicorn_binance_websocket_api_exceptions.py
with exceptionStreamRecoveryError
andUnknownExchange
fill_up_space_right()
self.restart_timeout
- raising
UnknownExchange
orStreamRecoveryError
instead ofValueError
fill_up_space()
tofill_up_space_left()
- reset the payloads of a stream at a stream restart
- moved some code for a stream restart from
_keepalive_streams()
torestart_stream()
which caused that the direct call ofrestart_stream()
worked only inside of_keepalive_streams()
- handling of
RuntimeWarning
in class connection at row 189
- code to start new
_keepalive_streams()
and_frequent_checks()
threads
disable_print
inprint_summary()
pull #48print_summary_export_path
- if provided, the lib is going to export the output ofprint_summary()
to a PNG image.get_number_of_all_subscriptions()
and show all subscriptions number inprint_summary()
- ping listen_key if "!userData" is in
channels
, not only inmarkets
. - format of some logs
- stream buffer size issue #51, pull #51
- avoid sending more than 5 messages per stream per second issue #45
- stop streams and set status to "crashed" if they exceed the limit of 1024 subscriptions per stream issue #45
is_stop_as_crash_request()
stop_stream_as_crash()
get_limit_of_subscriptions_per_stream()
get_number_of_free_subscription_slots()
BinanceWebSocketApiManager(throw_exception_if_unrepairable=True)
- raiseStreamRecoveryError
if a stream is not repairable (invalid api-key format or exceeding the 1024 subscription limit)
- loglevel
connection.send()
loglevels from error to critical. - loglevel
manager.create_websocket_uri()
of known errors from error to critical.
OSError
exception forself.monitoring_api_server.start()
if its already startedfor keepalive_streams_id in self.keepalive_streams_list:
added threadding lock (issue #47)
- binance jex
- dependency websockets from 7.0 to 8.1 which needs python>=3.6.1 (issue #11)
- expception handling of send() (issue #43)
- thread lock for
frequent_checks_list
(comment #590914274) current_receiving_speed
did not reset to 0 if all streams are offline
- fill_up_space_centered()
- update check on manager start
- print_stream_info() and print_summary(): unicorn-binance-websocket-api_-python_ in top boarder row
- count subscriptions
- lower for cex and upper for dex with exceptions for arr, $all, ! and array channels
lower()
markets increate_payload()
and exception for!userData
- get_active_stream_list() took len() of false item
- reconnect handling in send() (issue #40)
- making
self.stream_buffer
thread safe
- removed simplejson exception in restclient
- set OSError from error to critical
['receives_statistic_last_second']
dict is changing size during iteration. (issue #37)
- Using ujson instead of stock json lib
- cleaning
create_payload()
for CEX
Important infos, please read!
unicorn_binance_websocket_api_manager.is_exchange_type()
- support for subscribe/unsubscribe for CEX websockets
unicorn_binance_websocket_api_manager.get_stream_subscriptions()
unicorn_binance_websocket_api_manager.increase_transmitted_counter()
and added output toprint_summary()
andprint_stream_info()
split_payload()
- The 8004 char limit for URIs on websocket connect is bypassed via subscriptions with websocket.send() and
is_websocket_uri_length_valid()
allways returnsTrue
now!
- Subscribe/unsubscribe items of DEX websockets (card #5)
['receives_statistic_last_second']
dict is changing size during iteration. (issue #37)
- Python version in print_stream_info() and print_summary()
- Typo in text string
- Endpoints for www.binance.com margin UserData listenkey (issue #35)
- Endpoints for www.binance.com spot UserData listenkey (issue #35)
- Endpoints for www.binance.com futures UserData listenkey (issue #35)
- Errors when creating private DEX streams (issue #34)
- Moved docs to GitHub pages
- binance.com Futures websocket support and example_binance_futures.py and example_bookticker.py (issue#32)
- binance.us websocket support and example_binance_us.py (issue#22)
- Trailing / is no longer accepted by the endpoints: #31
- 'websockets>=7.0' to 'websockets==7.0': Websockets 8 is released, and it seems to be not compatible
- Amount of active streams to icinga status msg
- RuntimeError in _frequent_checks
- 'except websockets.exceptions.InvalidStatusCode as error_msg:' moved to right place
- 'except websockets.exceptions.InvalidStatusCode as error_msg:' in connnection line 97 with restart
- 'except KeyError:' in connection line 162
- get_monitoring_status_plain(): exception for outdated UnicornFy
- is_update_availabe_check_command()
- get_latest_version_check_command()
- get_latest_release_info_check_command()
- get_monitoring_status_plain()
- get_monitoring_status_icinga()
- _start_monitoring_api()
- https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/blob/master/tools/icinga/ (to https://github.com/LUCIT-Systems-and-Development/check_unicorn_monitoring_api)
- support for binance.org and testnet.binance.org websockets
- exchange name to icinga status msg
- binance_manager init: throw exception for unknown exchanges
- get_current_receiving_speed()
- exchange name and lib version to print_stream_info()
- current_receiving_speed to print_summary() and print_stream_info()
- get_exchange()
- set_private_dex_config() (not in use for now)
- subscribe_to_stream() - (dont use in productive! It's not clean and will get rewritten and maybe change behaviour)
- unsubscribe_from_stream() - (dont use in productive! It's not clean and will get rewritten and maybe change behaviour)
- _create_payload()
- rewrite create_websocket_url():
- a multiplex socket now returns false if it includes a single stream type like !userData, !Ticker or !miniTicker
- added support for binance.org Binance Chain DEX
- is_websocket_uri_length_valid() now always returns True for DEX websockets
- support for binance.je (Binance Jersey) websockets
- logging on failure in
create_stream()
add_string
inprint_summary()
andprint_stream_info()
warn_on_update
inget_monitoring_status_icinga()
,get_monitoring_status_plain()
andstart_monitoring_api()
- support for binance jersey #21
- show the used exchange in
print_summary()
andprint_stream_info()
- removed space from
total_received_length
inget_monitoring_status_icinga()
to avoid 'no data' error in ICINGA
- exception for
asyncio.base_futures.InvalidStateError
by DaWe35 #18
- create_stream() returns False if websocket URL is too long
is_websocket_uri_length_valid()
to work with !userData on the pre-test increate_stream()
without api secrets
- Docstrings for
markets
andchannels
to support: str, tuple, list, set - Fine-tuning of perfdata output in
get_monitoring_status_plain()
andget_monitoring_status_icinga()
get_stream_buffer_length()
by DaWe35 #12
- the
stream_buffer
FIFO stack was a LIFO stack (Thanks to DaWe35 for recognizing and fixing this issue #12) get_stream_buffer_byte_size
returns now the real size of the stream_buffer
- added round received items to 2 decimals instead of 0
- wrong version in manager class ...
- is_manager_stopping()
- is_update_available returns False if github API is not available.
- get_monitoring_status_icinga(): update check
- get_monitoring_status_icinga(): reconnects and update check
- get_monitoring_status_plain()
- start_monitoring_api()
- 1 hour cache for release checks on GitHub
- stop_monitoring_api()
- ./tools/icinga/check_binance_websocket_api_manager (check_command for ICINGA)
- example_monitoring.py
- example_monitoring.py and tools/check_binance_websocket_api_manager
- get_monitoring_status_icinga tests for available updates and changes the
return_code
to WARNING if an update is available. but I recognized an API ban from GitHub in cause of too many requests. I have to extend it ...
- get_monitoring_status_icinga: changed
status
dict node toreturn_code
- changing output of get_monitoring_status_icinga
- get_monitoring_status_icinga() in manager class
- lib version to print_summary()
- Typo in text in print_summary()
- KeyError in manager class row 148
- Bug in class UnicornFy: kline_close_time had the value kline_start_time
- Moved UnicornFy from UNICORN Binance WebSocket API to its own repository
- connection handling (improved)
markets
in keepalive listen_key can come as str or as list and the routine only handled it as list, now str gets converted to list to keep the function working
- "UTC" text to printed times
- listen_key 30 min cache
- method to delete a listen_key
- binance_api_status added to print_stream_info()
- README.md
- rewrite coloring for status_code in print_summary
- ping_interval from None to 20 seconds
- listen_key keepalive didnt work propper
- TypeError in print_summary()
- handling for status_code and used_weight from the binance REST Api (used for listen_key) - see
get_binance_api_status()
- reconnect issues
- log levels
- if no method is provided to BinanceWebSocketApiManager when creating the instance, then all data will be written to the stream_buffer.
- comments and code in examples
- show stream_buffer content if items len > 50
- removed stream_buffer log
- renamed get_stream_data_from_stream_buffer to pop_stream_data_from_stream_buffer
- IndexError in pop_stream_data_from_stream_buffer
- _forward_stream_buffer_data: system change - no pushing anymore, it's better to buffer everything and run an import class in a separate thread, that is able to reconnect to the database
- rewrite of keepalive and frequentchecks restarts
- stream_buffer logging: log amount of items in buffer
- stream_buffer logging: log amount of items in buffer
- added two macOS specific exceptions to connection class for better reconnect management
- updated the "update" methods in manager class (error handling while no internet connection)
- trying other behaviour on "400 - bad request" error
- added handling for -2015 error from get_listen_key_from_restclient in create_websocket_uri
- changed the waiting time before setting a restart request on 400 error to 5 seconds in connection class
- replaced tabs in print_summary() with blanks
- KeyError in unicorn_binance_websocket_api_connection.py error exception 414
- UnicornFy was very buggy with ticker and miniTicker handling
- KeyError in unicorn_binance_websocket_api_manager.py
- restarting streams row to print_summary()
- show active restarting and stopped streams only if not 0
- error message handling for userData streams
- reconnect depends on disconnect reason now (network or api-settings)
- del restart request in stop_stream()
- !miniTicker and !userData didn't work in cause of lower case all currencies. added an exception for them.
- pypi_install_packaging_tools.sh
- README.md
- Removed 2nd argument from binance_websocket_api_manager.stream_is_stopping()
- Tabs in print_summary() for windows platform
- Fixing format errors from auto reformat in unicorn_binance_websocket_api_connection
- Catching "ssl.SSLError" BinanceWebSocketApiConnection.receive()
- Improvment of reconnect on invalid URI caused by no network issue and a missing listen_key from Binance
- 30 min cache for Binance "listenKey" from rest api to avoid weight costs and hammering the Binance API on a flapping network connection
- Reconnect issue on userData stream
- Reset "has_stopped" attr from "stream_list" after a conncection restart
- Modyfied docstrings descriptions
- Tabs in print_summary() on windows