From d2f3a79c09db3c8d203cf77b05e717b147d9123d Mon Sep 17 00:00:00 2001 From: jaredgoldman Date: Wed, 12 Apr 2023 19:48:35 -0400 Subject: [PATCH] Use pendulum for header timestamp, type hint cleanup --- piker/brokers/binance.py | 2 +- piker/brokers/kucoin.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/piker/brokers/binance.py b/piker/brokers/binance.py index 37377136..64c69efb 100644 --- a/piker/brokers/binance.py +++ b/piker/brokers/binance.py @@ -485,7 +485,7 @@ async def stream_quotes( si['asset_type'] = 'crypto' symbol = symbols[0] - + breakpoint() init_msgs = { # pass back token, and bool, signalling if we're the writer # and that history has been written diff --git a/piker/brokers/kucoin.py b/piker/brokers/kucoin.py index b6fef60f..651b5d90 100644 --- a/piker/brokers/kucoin.py +++ b/piker/brokers/kucoin.py @@ -167,7 +167,7 @@ class BrokerConfig(Struct, frozen=True): def get_config() -> BrokerConfig | None: - conf, path = config.load() + conf, _= config.load() section = conf.get('kucoin') @@ -200,7 +200,7 @@ class Client: signature = base64.b64encode( hmac.new( - self._key_secret.encode('utf-8'), + self._config.key_secret.encode('utf-8'), str_to_sign.encode('utf-8'), hashlib.sha256, ).digest() @@ -216,7 +216,7 @@ class Client: return { 'KC-API-SIGN': signature, - 'KC-API-TIMESTAMP': str(now), + 'KC-API-TIMESTAMP': str(pendulum.now().int_timestamp * 1000), 'KC-API-KEY': self._key_id, 'KC-API-PASSPHRASE': passphrase, # XXX: Even if using the v1 api - this stays the same @@ -422,7 +422,7 @@ async def stream_quotes( send_chan: trio.abc.SendChannel, symbols: list[str], feed_is_live: trio.Event, - loglevel: str = None, + loglevel: str = '', # startup sync task_status: TaskStatus[tuple[dict, dict]] = trio.TASK_STATUS_IGNORED, ) -> None: @@ -523,7 +523,7 @@ async def stream_quotes( await send_chan.send({sym: msg}) -def make_sub(sym, connect_id, level='l1') -> dict[str, str | bool]: +def make_sub(sym, connect_id, level='l1') -> dict[str, str | bool] | None: match level: case 'l1': return {