| 437 | |
| 438 | |
| 439 | class ThreadedDepthCacheManager(ThreadedApiManager): |
| 440 | def __init__( |
| 441 | self, |
| 442 | api_key: Optional[str] = None, |
| 443 | api_secret: Optional[str] = None, |
| 444 | requests_params: Optional[Dict[str, str]] = None, |
| 445 | tld: str = "com", |
| 446 | testnet: bool = False, |
| 447 | ): |
| 448 | super().__init__(api_key, api_secret, requests_params, tld, testnet) |
| 449 | |
| 450 | def _start_depth_cache( |
| 451 | self, |
| 452 | dcm_class, |
| 453 | callback: Callable, |
| 454 | symbol: str, |
| 455 | refresh_interval=None, |
| 456 | bm=None, |
| 457 | limit=10, |
| 458 | conv_type=float, |
| 459 | **kwargs, |
| 460 | ) -> str: |
| 461 | while not self._client: |
| 462 | time.sleep(0.01) |
| 463 | |
| 464 | dcm = dcm_class( |
| 465 | client=self._client, |
| 466 | symbol=symbol, |
| 467 | loop=self._loop, |
| 468 | refresh_interval=refresh_interval, |
| 469 | bm=bm, |
| 470 | limit=limit, |
| 471 | conv_type=conv_type, |
| 472 | **kwargs, |
| 473 | ) |
| 474 | path = symbol.lower() + "@depth" + str(limit) |
| 475 | self._socket_running[path] = True |
| 476 | self._loop.call_soon( |
| 477 | asyncio.create_task, self.start_listener(dcm, path, callback) |
| 478 | ) |
| 479 | return path |
| 480 | |
| 481 | def start_depth_cache( |
| 482 | self, |
| 483 | callback: Callable, |
| 484 | symbol: str, |
| 485 | refresh_interval=None, |
| 486 | bm=None, |
| 487 | limit=10, |
| 488 | conv_type=float, |
| 489 | ws_interval=0, |
| 490 | ) -> str: |
| 491 | return self._start_depth_cache( |
| 492 | dcm_class=DepthCacheManager, |
| 493 | callback=callback, |
| 494 | symbol=symbol, |
| 495 | refresh_interval=refresh_interval, |
| 496 | bm=bm, |
no outgoing calls
no test coverage detected
searching dependent graphs…