From fd9e484b55db61526fab218ed76b8537a18d054a Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 22 Mar 2023 10:36:52 -0400 Subject: [PATCH] Add `.__str__()` to mktpair and symbol types, fix `MktPair.fqme` token order --- piker/accounting/_mktinfo.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/piker/accounting/_mktinfo.py b/piker/accounting/_mktinfo.py index 4c94962d..19657541 100644 --- a/piker/accounting/_mktinfo.py +++ b/piker/accounting/_mktinfo.py @@ -221,6 +221,10 @@ class MktPair(Struct, frozen=True): _atype: str = '' + # NOTE: when cast to `str` return fqme + def __str__(self) -> str: + return self.fqme + @classmethod def from_msg( cls, @@ -358,7 +362,7 @@ class MktPair(Struct, frozen=True): return maybe_cons_tokens([ self.key, # final "pair name" (eg. qqq[/usd], btcusdt) self.venue, - self.expiry, + self.suffix, # includes expiry and other con info self.broker, ]) @@ -537,3 +541,7 @@ class Symbol(Struct): Decimal(f'1.{"0".ljust(digits, "0")}'), rounding=ROUND_HALF_EVEN ) + + # NOTE: when cast to `str` return fqme + def __str__(self) -> str: + return self.fqme