()
| 14 | |
| 15 | |
| 16 | def main(): |
| 17 | dcm = ThreadedDepthCacheManager() |
| 18 | dcm.start() |
| 19 | |
| 20 | def handle_depth_cache(depth_cache): |
| 21 | if isinstance(depth_cache, dict) and depth_cache.get("e") == "error": |
| 22 | logger.error(f"Received depth cache error in callback: {depth_cache}") |
| 23 | type = depth_cache.get("type") |
| 24 | if type == "BinanceWebsocketClosed": |
| 25 | # Automatically attempts to reconnect |
| 26 | return |
| 27 | logger.error(f"Error received - Closing depth cache: {depth_cache}") |
| 28 | dcm.stop() |
| 29 | return |
| 30 | |
| 31 | logger.info(f"symbol {depth_cache.symbol}") # type: ignore[union-attr] |
| 32 | logger.info(depth_cache.get_bids()[:5]) # type: ignore[union-attr] |
| 33 | |
| 34 | dcm.start_depth_cache(handle_depth_cache, symbol="BNBBTC") |
| 35 | dcm.join() |
| 36 | |
| 37 | |
| 38 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…