ensure that paper pps are pulled on open

explicit_write_pps_on_exit
algorandpa 2023-01-28 18:14:59 -05:00 committed by jaredgoldman
parent 9c28d7086e
commit 8cd2354d73
1 changed files with 9 additions and 0 deletions

View File

@ -288,6 +288,8 @@ class PaperBoi(Struct):
# Write to pps toml # Write to pps toml
with open_pps(self.broker, 'paper-id') as table: with open_pps(self.broker, 'paper-id') as table:
table.update_from_trans(self._txn_dict) table.update_from_trans(self._txn_dict)
# save pps in local state
self._positions.update(table.pps)
pp.add_clear(t) pp.add_clear(t)
@ -551,9 +553,16 @@ async def trades_dialogue(
) as feed, ) as feed,
): ):
with open_pps(broker, 'paper-id') as table:
# save pps in local state
_positions.update(table.pps)
pp_msgs: list[BrokerdPosition] = [] pp_msgs: list[BrokerdPosition] = []
pos: Position pos: Position
token: str # f'{symbol}.{self.broker}' token: str # f'{symbol}.{self.broker}'
print("POSITIONS::")
print(_positions.items())
for token, pos in _positions.items(): for token, pos in _positions.items():
pp_msgs.append(BrokerdPosition( pp_msgs.append(BrokerdPosition(
broker=broker, broker=broker,