Use pendulum for header timestamp,

type hint cleanup
small_kucoin_fixes
jaredgoldman 2023-04-12 19:48:35 -04:00
parent bedbbc3025
commit d2f3a79c09
2 changed files with 6 additions and 6 deletions

View File

@ -485,7 +485,7 @@ async def stream_quotes(
si['asset_type'] = 'crypto' si['asset_type'] = 'crypto'
symbol = symbols[0] symbol = symbols[0]
breakpoint()
init_msgs = { init_msgs = {
# pass back token, and bool, signalling if we're the writer # pass back token, and bool, signalling if we're the writer
# and that history has been written # and that history has been written

View File

@ -167,7 +167,7 @@ class BrokerConfig(Struct, frozen=True):
def get_config() -> BrokerConfig | None: def get_config() -> BrokerConfig | None:
conf, path = config.load() conf, _= config.load()
section = conf.get('kucoin') section = conf.get('kucoin')
@ -200,7 +200,7 @@ class Client:
signature = base64.b64encode( signature = base64.b64encode(
hmac.new( hmac.new(
self._key_secret.encode('utf-8'), self._config.key_secret.encode('utf-8'),
str_to_sign.encode('utf-8'), str_to_sign.encode('utf-8'),
hashlib.sha256, hashlib.sha256,
).digest() ).digest()
@ -216,7 +216,7 @@ class Client:
return { return {
'KC-API-SIGN': signature, '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-KEY': self._key_id,
'KC-API-PASSPHRASE': passphrase, 'KC-API-PASSPHRASE': passphrase,
# XXX: Even if using the v1 api - this stays the same # XXX: Even if using the v1 api - this stays the same
@ -422,7 +422,7 @@ async def stream_quotes(
send_chan: trio.abc.SendChannel, send_chan: trio.abc.SendChannel,
symbols: list[str], symbols: list[str],
feed_is_live: trio.Event, feed_is_live: trio.Event,
loglevel: str = None, loglevel: str = '',
# startup sync # startup sync
task_status: TaskStatus[tuple[dict, dict]] = trio.TASK_STATUS_IGNORED, task_status: TaskStatus[tuple[dict, dict]] = trio.TASK_STATUS_IGNORED,
) -> None: ) -> None:
@ -523,7 +523,7 @@ async def stream_quotes(
await send_chan.send({sym: msg}) 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: match level:
case 'l1': case 'l1':
return { return {