unicorn_binance_local_depth_cache package¶
Submodules¶
unicorn_binance_local_depth_cache.unicorn_binance_local_depth_cache_manager module¶
- class unicorn_binance_local_depth_cache.manager.BinanceLocalDepthCacheManager(exchange: str = 'binance.com', default_refresh_interval: int | None = None, depth_cache_update_interval: int | None = None, high_performance: bool = False, init_interval: float = 0.5, init_time_window: int = 5, websocket_close_timeout: int = 2, websocket_ping_interval: int = 10, websocket_ping_timeout: int = 20, disable_colorama: bool = False, ubra_manager: BinanceRestApiManager | None = None, warn_on_update: bool = True, lucit_api_secret: str | None = None, lucit_license_ini: str | None = None, lucit_license_profile: str | None = None, lucit_license_token: str | None = None)[source]¶
Bases:
Thread
A Python SDK by LUCIT to access and manage multiple local Binance DepthCaches with Python in a simple, fast, flexible, robust and fully-featured way.
- Binance API documentation:
- Parameters:
exchange (str) – Select binance.com, binance.com-testnet, binance.com-futures, binance.com-futures-testnet (default: binance.com)
default_refresh_interval (int) – The default refresh interval in seconds, default is None. The depth_cache is reset and reinitialized at this interval.
init_time_window (int (seconds)) – Only one request to the Binance REST API is permitted per depth_cache in this time window (specified in seconds).
high_performance (bool) – If True, access to the depth snapshots via REST in the INIT process is not regulated. Be careful!
depth_cache_update_interval (int) – Update speed of the depth stream in milliseconds. More info: https://github.com/LUCIT-Systems-and-Development/unicorn-binance-local-depth-cache/wiki/update_intervals
websocket_close_timeout (int) – The close_timeout parameter defines a maximum wait time in seconds for completing the closing handshake and terminating the TCP connection. This parameter is passed through to the websockets.client.connect()
websocket_ping_interval (int) – Once the connection is open, a Ping frame is sent every ping_interval seconds. This serves as a keepalive. It helps keeping the connection open, especially in the presence of proxies with short timeouts on inactive connections. Set ping_interval to None to disable this behavior. This parameter is passed through to the websockets.client.connect()
websocket_ping_timeout (int) – If the corresponding Pong frame isn’t received within ping_timeout seconds, the connection is considered unusable and is closed with code 1011. This ensures that the remote endpoint remains responsive. Set ping_timeout to None to disable this behavior. This parameter is passed through to the websockets.client.connect()
disable_colorama (bool) – set to True to disable the use of colorama
ubra_manager (BinanceRestApiManager) – Provide a shared unicorn_binance_rest_api.manager instance
warn_on_update (bool) – set to False to disable the update warning
lucit_api_secret (str) – The api_secret of your UNICORN Binance Suite license from https://shop.lucit.services/software/unicorn-binance-suite
lucit_license_ini (str) – Specify the path including filename to the config file (ex: ~/license_a.ini). If not provided lucitlicmgr tries to load a lucit_license.ini from /home/oliver/.lucit/.
lucit_license_profile (str) – The license profile to use. Default is ‘LUCIT’.
lucit_license_token (str) – The license_token of your UNICORN Binance Suite license from https://shop.lucit.services/software/unicorn-binance-suite
- create_depth_cache(markets: str | list | None = None, refresh_interval: int | None = None) bool [source]¶
Create one or more depth_cache!
- Parameters:
markets (str or list) – Specify the market symbols for caches to be created
refresh_interval (int) – The refresh interval in seconds, default is the default_refresh_interval of BinanceLocalDepthCache. The depth_cache is reset and reinitialized at this interval.
- Returns:
bool
- get_asks(market: str | None = None, limit_count: int | None = None, threshold_volume: float | None = None) list [source]¶
Get the current list of asks with price and quantity.
- Parameters:
market (str) – Specify the market symbol for the used depth_cache
limit_count (int or None (0 is nothing, None is everything)) – List elements threshold to trim the result.
threshold_volume (float or None (0 is nothing, None is everything)) – Volume threshold to trim the result.
- Returns:
list
- get_bids(market: str | None = None, limit_count: int | None = None, threshold_volume: float | None = None) list [source]¶
Get the current list of bids with price and quantity.
- Parameters:
market (str) – Specify the market symbol for the used depth_cache.
limit_count (int or None (0 is nothing, None is everything)) – List elements threshold to trim the result.
threshold_volume (float or None (0 is nothing, None is everything)) – Volume threshold to trim the result.
- Returns:
list
- static get_latest_release_info() dict | None [source]¶
Get info about the latest available release
- Returns:
dict or None
- get_latest_version() str | None [source]¶
Get the version of the latest available release (cache time 1 hour)
- Returns:
str or None
- get_ubra_manager() BinanceRestApiManager [source]¶
Get the used BinanceRestApiManager() instance of BinanceLocalDepthCacheManager()
- Returns:
BinanceRestApiManager
- get_ubwa_manager() BinanceWebSocketApiManager [source]¶
Get the used BinanceWebSocketApiManager() instance of BinanceLocalDepthCacheManager()
- Returns:
BinanceWebSocketApiManager
- get_user_agent() str [source]¶
Get the user_agent string “lib name + lib version + python version”
- Returns:
str
- is_depth_cache_synchronized(market: str | None = None) bool [source]¶
Is a specific depth_cache synchronized?
- Parameters:
market (str) – Specify the market symbol for the used depth_cache
- Returns:
bool
- is_stop_request(market: str | None = None) bool [source]¶
Is there a stop request?
- Parameters:
market (str) – Specify the market symbol for the used depth_cache
- Returns:
bool
- print_summary(add_string: str | None = None, footer: str | None = None, title: str | None = None) None [source]¶
Print an overview of all streams
- Parameters:
add_string (str) – text to add to the output
footer (str) – footer of the output
title (str) – title of the output
- Returns:
None
- print_summary_to_png(print_summary_export_path: str | None = None, height_per_row: float = 12.5, add_string: str | None = None, footer: str | None = None, title: str | None = None)[source]¶
Create a PNG image file with the console output of print_summary()
LINUX ONLY It should not be hard to make it OS independent: https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/issues/61
- Parameters:
print_summary_export_path (str) – If you want to export the output of print_summary() to an image, please provide a path like “/var/www/html/”. View the Wiki!
height_per_row (float) – set the height per row for the image height calculation
add_string (str) – text to add to the output
footer (str) – set a footer (last row) for print_summary output
title (str) – set a title (first row) for print_summary output
- Returns:
bool
- set_refresh_request(markets: str | list | None = None) bool [source]¶
Set refresh requests for one or more depth_caches!
- Parameters:
markets (str or list) – Specify the market symbols for the depth_caches to be refreshed
- Returns:
bool
unicorn_binance_local_depth_cache.unicorn_binance_local_depth_cache_exceptions module¶
- exception unicorn_binance_local_depth_cache.exceptions.DepthCacheAlreadyStopped(market=None)[source]¶
Bases:
Exception
Exception raised when an attempt is made to use a depth_cache that has already been stopped.