From f53f4df58368205b7a5e2d4a916a45806b102043 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 1 Mar 2023 17:29:45 -0500 Subject: [PATCH] `ib/kraken`: adjust to new default of not-writing in `open_pps()` --- piker/brokers/ib/broker.py | 11 +++++++++-- piker/brokers/kraken/broker.py | 23 ++--------------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/piker/brokers/ib/broker.py b/piker/brokers/ib/broker.py index 8ceb1602..4537e7f0 100644 --- a/piker/brokers/ib/broker.py +++ b/piker/brokers/ib/broker.py @@ -480,10 +480,17 @@ async def trades_dialogue( # open ledger and pptable wrapper for each # detected account. ledger = ledgers[acctid] = lstack.enter_context( - open_trade_ledger('ib', acctid) + open_trade_ledger( + 'ib', + acctid, + ) ) table = tables[acctid] = lstack.enter_context( - open_pps('ib', acctid) + open_pps( + 'ib', + acctid, + write_on_exit=True, + ) ) for account, proxy in proxies.items(): diff --git a/piker/brokers/kraken/broker.py b/piker/brokers/kraken/broker.py index ef0288b9..9378db17 100644 --- a/piker/brokers/kraken/broker.py +++ b/piker/brokers/kraken/broker.py @@ -470,6 +470,7 @@ async def trades_dialogue( open_pps( 'kraken', acctid, + write_on_exit=True, ) as table, open_trade_ledger( @@ -627,7 +628,7 @@ async def trades_dialogue( cost_scalar=1, ) log.info( - 'Updated {dst} from transfers:\n' + f'Updated {dst} from transfers:\n' f'{pformat(updated)}' ) @@ -1212,23 +1213,3 @@ def norm_trade_records( ) return records - - -@cm -def open_ledger( - acctid: str, - trade_entries: list[dict[str, Any]], - -) -> set[Transaction]: - ''' - Write recent session's trades to the user's (local) ledger file. - - ''' - with open_trade_ledger( - 'kraken', - acctid, - ) as ledger: - yield ledger - - # update on exit - ledger.update(trade_entries)