Created
June 1, 2026 13:02
-
-
Save oliver-zehentleitner/f06b52294f274b058ea651847d96a910 to your computer and use it in GitHub Desktop.
Query ASKS from all UBDCC DepthCaches.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pprint import pprint | |
| from unicorn_binance_local_depth_cache import BinanceLocalDepthCacheManager, DepthCacheClusterNotReachableError | |
| import asyncio | |
| debug: bool = False | |
| limit_count: int = 5 | |
| threshold_volume: float = 20000.0 | |
| ubdcc_address: str = "YOUR_UBDCC_IP" | |
| ubdcc_port: int = 80 | |
| async def main(): | |
| dc = await ubldc.cluster.get_depthcache_list_async(debug=debug) | |
| errors = {} | |
| non_working_caches = [] | |
| working_caches = [] | |
| for dcl_exchange in dc['depthcache_list']: | |
| print(f"Testing {len(dc['depthcache_list'][dcl_exchange])} DepthCaches for exchange '{dcl_exchange}' on UBDCC " | |
| f"'{ubdcc_address}'!") | |
| loop = 1 | |
| for market in dc['depthcache_list'][dcl_exchange]: | |
| asks = await ubldc.cluster.get_asks_async(exchange=dcl_exchange, market=market, limit_count=limit_count, | |
| threshold_volume=threshold_volume, debug=debug) | |
| if asks.get('error_id') is not None: | |
| print(f"Asks from DepthCache #{loop} '{market}' failed: {asks.get('error_id')} - {asks.get('message')}") | |
| pprint(asks) | |
| errors[asks.get('error_id')] = 1 if errors.get(asks.get('error_id')) is None else errors.get(asks.get('error_id')) + 1 | |
| non_working_caches.append(market) | |
| else: | |
| print(f"Asks (limit_count={limit_count}, threshold_volume={threshold_volume}) from DepthCache #{loop} " | |
| f"'{market}':") | |
| pprint(asks) | |
| working_caches.append(market) | |
| loop += 1 | |
| print(f"Successful working caches: {len(working_caches)}") | |
| if len(errors) > 0: | |
| print(f"ERRORS:") | |
| pprint(errors) | |
| await asyncio.sleep(1) | |
| try: | |
| with BinanceLocalDepthCacheManager(ubdcc_address=ubdcc_address, ubdcc_port=ubdcc_port) as ubldc: | |
| try: | |
| asyncio.run(main()) | |
| except KeyboardInterrupt: | |
| print("\r\nGracefully stopping ...") | |
| except Exception as error_msg: | |
| print(f"ERROR: {error_msg}") | |
| except DepthCacheClusterNotReachableError as error_msg: | |
| print(f"ERROR: {error_msg}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment