From 0a959c1c74d09e7f3710ddb2609344b99a96d845 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 11 Nov 2022 17:27:49 -0500 Subject: [PATCH] Not all accounts will have API trade transactions this session.. --- piker/brokers/ib/broker.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/piker/brokers/ib/broker.py b/piker/brokers/ib/broker.py index 401ac71c..52b26970 100644 --- a/piker/brokers/ib/broker.py +++ b/piker/brokers/ib/broker.py @@ -575,17 +575,18 @@ async def trades_dialogue( # if new trades are detected from the API, prepare # them for the ledger file and update the pptable. if api_to_ledger_entries: - trade_entries = api_to_ledger_entries[acctid] + trade_entries = api_to_ledger_entries.get(acctid) - # write ledger with all new trades **AFTER** - # we've updated the `pps.toml` from the - # original ledger state! (i.e. this is - # currently done on exit) - ledger.update(trade_entries) + if trade_entries: + # write ledger with all new trades **AFTER** + # we've updated the `pps.toml` from the + # original ledger state! (i.e. this is + # currently done on exit) + ledger.update(trade_entries) - trans = trans_by_acct.get(acctid) - if trans: - table.update_from_trans(trans) + trans = trans_by_acct.get(acctid) + if trans: + table.update_from_trans(trans) # XXX: not sure exactly why it wouldn't be in # the updated output (maybe this is a bug?) but