diff --git a/piker/accounting/_ledger.py b/piker/accounting/_ledger.py index 82a77107..d2e56bf0 100644 --- a/piker/accounting/_ledger.py +++ b/piker/accounting/_ledger.py @@ -40,7 +40,7 @@ import tomli_w # for fast ledger writing from piker.types import Struct from piker import config -from ..log import get_logger +from piker.log import get_logger from .calc import ( iter_by_dt, ) @@ -239,7 +239,9 @@ class TransactionLedger(UserDict): symcache: SymbologyCache = self._symcache towrite: dict[str, Any] = {} - for tid, txdict in self.tx_sort(self.data.copy()): + for tid, txdict in self.tx_sort( + self.data.copy() + ): # write blank-str expiry for non-expiring assets if ( 'expiry' in txdict @@ -377,7 +379,7 @@ def open_trade_ledger( account, dirpath=_fp, ) - cpy = ledger_dict.copy() + cpy: dict = ledger_dict.copy() # XXX NOTE: if not provided presume we are being called from # sync code and need to maybe run `trio` to generate.. @@ -406,7 +408,13 @@ def open_trade_ledger( account=account, mod=mod, symcache=symcache, - tx_sort=getattr(mod, 'tx_sort', tx_sort), + + # NOTE: allow backends to provide custom ledger sorting + tx_sort=getattr( + mod, + 'tx_sort', + tx_sort, + ), ) try: yield ledger