Fix for TWS created position loading

dict_differ
Tyler Goodlet 2022-08-08 13:47:17 -04:00
parent 5ac5743c66
commit a3812cd169
1 changed files with 6 additions and 2 deletions

View File

@ -533,8 +533,6 @@ async def trades_dialogue(
): ):
trans = norm_trade_records(ledger) trans = norm_trade_records(ledger)
updated = table.update_from_trans(trans) updated = table.update_from_trans(trans)
pp = updated[bsuid]
# update trades ledgers for all accounts from connected # update trades ledgers for all accounts from connected
# api clients which report trades for **this session**. # api clients which report trades for **this session**.
trades = await proxy.trades() trades = await proxy.trades()
@ -562,6 +560,12 @@ async def trades_dialogue(
table.update_from_trans(trans) table.update_from_trans(trans)
updated = table.update_from_trans(trans) updated = table.update_from_trans(trans)
# XXX: not sure exactly why it wouldn't be in
# the updated output (maybe this is a bug?) but
# if you create a pos from TWS and then load it
# from the api trades it seems we get a key
# error from ``update[bsuid]`` ?
pp = table.pps[bsuid]
if msg.size != pp.size: if msg.size != pp.size:
log.error( log.error(
'Position mismatch {pp.symbol.front_fqsn()}:\n' 'Position mismatch {pp.symbol.front_fqsn()}:\n'