Passthrough all **kwargs `Struct.to_dict()`
Since for symcache-ing we don't want to write non-member fields we need to allow passing the appropriate flag; i hate frickin inheritance XDaccount_tests
parent
b9fec091ca
commit
69314e9fca
|
@ -132,8 +132,11 @@ class Asset(Struct, frozen=True):
|
||||||
|
|
||||||
# `None` is not toml-compat so drop info
|
# `None` is not toml-compat so drop info
|
||||||
# if no extra data added..
|
# if no extra data added..
|
||||||
def to_dict(self) -> dict:
|
def to_dict(
|
||||||
dct = super().to_dict()
|
self,
|
||||||
|
**kwargs,
|
||||||
|
) -> dict:
|
||||||
|
dct = super().to_dict(**kwargs)
|
||||||
if (info := dct.pop('info', None)):
|
if (info := dct.pop('info', None)):
|
||||||
dct['info'] = info
|
dct['info'] = info
|
||||||
|
|
||||||
|
@ -145,7 +148,7 @@ class Asset(Struct, frozen=True):
|
||||||
cls,
|
cls,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
) -> Asset:
|
) -> Asset:
|
||||||
return Asset(
|
return cls(
|
||||||
tx_tick=Decimal(str(msg.pop('tx_tick'))),
|
tx_tick=Decimal(str(msg.pop('tx_tick'))),
|
||||||
info=msg.pop('info', None),
|
info=msg.pop('info', None),
|
||||||
**msg,
|
**msg,
|
||||||
|
@ -318,10 +321,13 @@ class MktPair(Struct, frozen=True):
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.fqme
|
return self.fqme
|
||||||
|
|
||||||
def to_dict(self) -> dict:
|
def to_dict(
|
||||||
d = super().to_dict()
|
self,
|
||||||
d['src'] = self.src.to_dict()
|
**kwargs,
|
||||||
d['dst'] = self.dst.to_dict()
|
) -> dict:
|
||||||
|
d = super().to_dict(**kwargs)
|
||||||
|
d['src'] = self.src.to_dict(**kwargs)
|
||||||
|
d['dst'] = self.dst.to_dict(**kwargs)
|
||||||
|
|
||||||
d['price_tick'] = str(self.price_tick)
|
d['price_tick'] = str(self.price_tick)
|
||||||
d['size_tick'] = str(self.size_tick)
|
d['size_tick'] = str(self.size_tick)
|
||||||
|
|
Loading…
Reference in New Issue