Unicorn-binance-websocket-api

Latest version: v2.4.0

Safety actively analyzes 618849 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 24

2.4.0

Optimization of the performance and revision of the life support of the ListenKey.

Changed
- 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 by `asyncio.sleep()`
Fixed
- In `_run_sockets()` `time.sleep()` was mistakenly used instead of `asyncio.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. [issue330](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/issues/330)
- Added exception handling for `TypeError` to `subscribe_to_stream()` and `unsubscribe_from_stream()`.

2.4.0.dev

2.3.0

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!

Added
- `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" for `BinanceWebSocketApiManager()` and
`create_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 with
`await get_stream_data_from_asyncio_queue(stream_id)` as an AsyncIO alternative to
`pop_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()`
Changed
- Updated from websockets 10.4 to 11.0.3.
- `pop_stream_data_from_stream_buffer()` returns `None` instead of `False`
- The parameter `throw_exception_if_unrepairable` was removed by the UBWA Manager and replaced by the stream_signal
`STREAM_UNREPAIRABLE`.
Info: https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/wiki/%60stream_signals%60
- Many `False` values have been changed to `None` 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 by `datetime.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()` with `is_crash_request()`
- Renamed `stream_is_crashing()` with `_stream_is_crashing()`
- Renamed `stream_is_stopping()` with `_stream_is_stopping()`
Fixed
- 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 the `symbol` parameter to query all open orders.
- Completely revised the error handling.
Removed
- Parameter `throw_exception_if_unrepairable` of `BinanceWebSocketApiManager()`.
- Exception `StreamRecoveryError`.
- `set_restart_request()`
- `_restart_stream()`
- `_keepalive_streams()`
- `kill_stream()`

2.2.0

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!

Added
- Parameter `process_stream_data_async` in `manager.py` to `BinanceWebSocketApiManager()` as global setting parameter
and to `create_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` and `specific_process_stream_data_async[stream_id]` to `socket.py`.
- Support for `with-context` to `BinanceWebSocketApiSocket()`.
- `run_socket()` to `manager.py`.
- `shutdown_asyncgens()` to `manager.py`.
- `timeout` parameter (float) to `delete_stream_from_stream_list()`, `wait_till_stream_has_stopped()` and
`wait_till_stream_has_started()` with default value 10.0 seconds.
- Automatic data cleanup of stopped web streams. [issue307](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/issues/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 is `False`. Also added the function `remove_all_data_of_stream_id()` and
`_auto_data_cleanup_stopped_streams()` which are doing the cleaning up job.
Changed
- Parameter `process_stream_data` in `manager.py` from `False` to `None`.
- Parameter `process_stream_signals` in `manager.py` from `False` to `None`.
- Usage of `BinanceWebSocketApiSocket()` in `manager.py` by using the new `with-context` and `ubwa.run_socket()` to
close every websocket connection when leaving.
- Now using `wait_till_stream_has_stopped()` in `delete_stream_from_stream_list()`. This avoids many errors ;)
- Rewrite of the `try-except` and the `finally` code part for the loop handling in `_create_stream_thread()`.
Fixed
- Missing `await` of `websocket.close()` in `socket.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 by `return False`.
Removed
- `import sys` in `sockets.py`

2.1.4

Added
- Websocket API: `create_order()` and `create_test_order()` - Support of parameter `quoteOrderQty`, Behavior: If
activated, it replaces the `quantity` parameter.
Fixed
- Websocket API: `create_order()` and `create_test_order()` - [issue353](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/issues/353)
and [issue352](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/issues/352)
- Websocket API: `create_order()` and `create_test_order()` - `trailingDelta` is only used if `stopPrice` was not
specified.
- Binance futures testnet userData stream in `restclient.py` - [issue347](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/issues/347)

2.1.3

Fixed
- Troubleshooting restart problems
- `manager.delete_listen_key_by_stream_id()` used `False` instead of `None`

Page 1 of 24

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.