Add `MktPair._atype` for back-compat, always `str(.dst)`

pre_overruns_ctxcancelled
Tyler Goodlet 2023-03-20 20:02:27 -04:00
parent 94cb8fa1b1
commit d6634e9b02
1 changed files with 11 additions and 2 deletions

View File

@ -215,6 +215,8 @@ class MktPair(Struct, frozen=True):
# strike price, call or put, swap type, exercise model, etc.
contract_info: str | None = None
_atype: str = ''
@classmethod
def from_msg(
self,
@ -239,6 +241,8 @@ class MktPair(Struct, frozen=True):
size_tick: float | str,
bs_mktid: str,
**kwargs,
) -> MktPair:
broker, key, suffix = unpack_fqme(fqme)
@ -254,6 +258,8 @@ class MktPair(Struct, frozen=True):
size_tick=size_tick,
bs_mktid=bs_mktid,
broker=broker,
**kwargs,
)
@property
@ -267,7 +273,7 @@ class MktPair(Struct, frozen=True):
"symbol".
'''
return maybe_cons_tokens([self.dst, self.src])
return maybe_cons_tokens([str(self.dst), self.src])
# NOTE: the main idea behind an fqme is to map a "market address"
# to some endpoint from a transaction provider (eg. a broker) such
@ -351,8 +357,11 @@ class MktPair(Struct, frozen=True):
# TODO: BACKWARD COMPAT, TO REMOVE?
@property
def type_key(self) -> str:
if isinstance(self.dst, Asset):
return str(self.dst.atype)
return self._atype
@property
def tick_size_digits(self) -> int:
return float_digits(self.price_tick)