Skip to content

Commit

Permalink
Drop symbol section on Position serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
guilledk committed Mar 2, 2023
1 parent d704b15 commit 6be96a9
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions piker/pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,15 @@ def to_pretoml(self) -> tuple[str, dict]:
# listing venue here even when the backend isn't providing
# it via the trades ledger..
# drop symbol obj in serialized form
s = d.get('symbol')
s = d.pop('symbol')
fqsn = s.front_fqsn()

broker, key, suffix = unpack_fqsn(fqsn)
sym_info = s.broker_info[broker]

d['symbol'] = {
'asset_type': sym_info['asset_type'],
'price_tick_size': sym_info['price_tick_size'],
'lot_tick_size': sym_info['lot_tick_size']
}
d['asset_type'] = sym_info['asset_type']
d['price_tick_size'] = sym_info['price_tick_size']
d['lot_tick_size'] = sym_info['lot_tick_size']

if self.expiry is None:
d.pop('expiry', None)
Expand Down Expand Up @@ -935,6 +933,13 @@ def open_pps(
# and update `PpTable` obj entries.
for fqsn, entry in pps.items():
bsuid = entry['bsuid']
symbol = Symbol.from_fqsn(
fqsn, info={
'asset_type': entry['asset_type'],
'price_tick_size': entry['price_tick_size'],
'lot_tick_size': entry['lot_tick_size']
}
)

# convert clears sub-tables (only in this form
# for toml re-presentation) back into a master table.
Expand All @@ -959,8 +964,7 @@ def open_pps(

trans.append(Transaction(
fqsn=bsuid,
sym=Symbol.from_fqsn(
fqsn, entry['symbol']),
sym=symbol,
bsuid=bsuid,
tid=tid,
size=clears_table['size'],
Expand All @@ -981,8 +985,7 @@ def open_pps(
expiry = pendulum.parse(expiry)

pp = pp_objs[bsuid] = Position(
Symbol.from_fqsn(
fqsn, entry['symbol']),
symbol,
size=size,
ppu=ppu,
split_ratio=split_ratio,
Expand Down

0 comments on commit 6be96a9

Please sign in to comment.