From d7f6a5ab63a7e44f995c5048716c8dd7c180baa1 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 12 Feb 2025 16:31:57 -0500 Subject: [PATCH] Update to latest `KucoinMktPair` spec --- piker/brokers/kucoin.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/piker/brokers/kucoin.py b/piker/brokers/kucoin.py index 1dda64e7..bdd551c9 100755 --- a/piker/brokers/kucoin.py +++ b/piker/brokers/kucoin.py @@ -62,7 +62,7 @@ from piker._cacheables import ( ) from piker.log import get_logger from piker.data.validate import FeedInit -from piker.types import Struct +from piker.types import Struct # NOTE, this is already a `tractor.msg.Struct` from piker.data import ( def_iohlcv_fields, match_from_pairs, @@ -98,9 +98,18 @@ class KucoinMktPair(Struct, frozen=True): def size_tick(self) -> Decimal: return Decimal(str(self.quoteMinSize)) + callauctionFirstStageStartTime: None|float + callauctionIsEnabled: bool + callauctionPriceCeiling: float|None + callauctionPriceFloor: float|None + callauctionSecondStageStartTime: float|None + callauctionThirdStageStartTime: float|None + enableTrading: bool + feeCategory: int feeCurrency: str isMarginEnabled: bool + makerFeeCoefficient: float market: str minFunds: float name: str @@ -110,11 +119,10 @@ class KucoinMktPair(Struct, frozen=True): quoteIncrement: float quoteMaxSize: float quoteMinSize: float - symbol: str # our bs_mktid, kucoin's internal id - feeCategory: int - makerFeeCoefficient: float - takerFeeCoefficient: float st: bool + symbol: str # our bs_mktid, kucoin's internal id + takerFeeCoefficient: float + tradingStartTime: float|None class AccountTrade(Struct, frozen=True): @@ -396,7 +404,13 @@ class Client: pairs: dict[str, KucoinMktPair] = {} fqmes2mktids: bidict[str, str] = bidict() for item in entries: - pair = pairs[item['name']] = KucoinMktPair(**item) + try: + pair = pairs[item['name']] = KucoinMktPair(**item) + except TypeError as te: + raise TypeError( + '`KucoinMktPair` and reponse fields do not match ??\n' + f'{KucoinMktPair.fields_diff(item)}\n' + ) from te fqmes2mktids[ item['name'].lower().replace('-', '') ] = pair.name