Add `.__str__()` to mktpair and symbol types, fix `MktPair.fqme` token order

rekt_pps
Tyler Goodlet 2023-03-22 10:36:52 -04:00
parent 406565f74d
commit fd9e484b55
1 changed files with 9 additions and 1 deletions

View File

@ -221,6 +221,10 @@ class MktPair(Struct, frozen=True):
_atype: str = '' _atype: str = ''
# NOTE: when cast to `str` return fqme
def __str__(self) -> str:
return self.fqme
@classmethod @classmethod
def from_msg( def from_msg(
cls, cls,
@ -358,7 +362,7 @@ class MktPair(Struct, frozen=True):
return maybe_cons_tokens([ return maybe_cons_tokens([
self.key, # final "pair name" (eg. qqq[/usd], btcusdt) self.key, # final "pair name" (eg. qqq[/usd], btcusdt)
self.venue, self.venue,
self.expiry, self.suffix, # includes expiry and other con info
self.broker, self.broker,
]) ])
@ -537,3 +541,7 @@ class Symbol(Struct):
Decimal(f'1.{"0".ljust(digits, "0")}'), Decimal(f'1.{"0".ljust(digits, "0")}'),
rounding=ROUND_HALF_EVEN rounding=ROUND_HALF_EVEN
) )
# NOTE: when cast to `str` return fqme
def __str__(self) -> str:
return self.fqme