From eaedaa96df6b708b22a56a9166e36bab09359ed9 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 13 Feb 2025 11:15:47 -0500 Subject: [PATCH] Drop some bps and style logic to multiline --- piker/accounting/_mktinfo.py | 4 ++-- piker/accounting/calc.py | 29 ++++++++++++++++++++++++----- piker/accounting/cli.py | 3 ++- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/piker/accounting/_mktinfo.py b/piker/accounting/_mktinfo.py index a8c719da..d2284a16 100644 --- a/piker/accounting/_mktinfo.py +++ b/piker/accounting/_mktinfo.py @@ -305,8 +305,8 @@ class MktPair(Struct, frozen=True): # config right? # src_type: AssetTypeName - # for derivs, info describing contract, egs. - # strike price, call or put, swap type, exercise model, etc. + # for derivs, info describing contract, egs. strike price, call + # or put, swap type, exercise model, etc. contract_info: list[str] | None = None # TODO: rename to sectype since all of these can diff --git a/piker/accounting/calc.py b/piker/accounting/calc.py index ac4d9c22..5919c0d6 100644 --- a/piker/accounting/calc.py +++ b/piker/accounting/calc.py @@ -251,10 +251,16 @@ def iter_by_dt( for k in parsers: if ( isdict and k in tx - or getattr(tx, k, None) + or + getattr(tx, k, None) ): - v = tx[k] if isdict else tx.dt - assert v is not None, f'No valid value for `{k}`!?' + v = ( + tx[k] if isdict + else tx.dt + ) + assert v is not None, ( + f'No valid value for `{k}`!?' + ) # only call parser on the value if not None from # the `parsers` table above (when NOT using @@ -269,8 +275,21 @@ def iter_by_dt( return v else: - # XXX: should never get here.. - breakpoint() + # TODO: move to top? + from piker.log import get_logger + log = get_logger(__name__) + + # XXX: we should really never get here.. + # only if a ledger record has no expected sort(able) + # field will we likely hit this.. like with ze IB. + # if no sortable field just deliver epoch? + log.warning( + 'No (time) sortable field for TXN:\n' + f'{tx}\n' + ) + return from_timestamp(0) + # breakpoint() + entry: tuple[str, dict] | Transaction for entry in sorted( diff --git a/piker/accounting/cli.py b/piker/accounting/cli.py index 6a62f294..f68cdfca 100644 --- a/piker/accounting/cli.py +++ b/piker/accounting/cli.py @@ -300,7 +300,8 @@ def disect( assert not df.is_empty() # muck around in pdbp REPL - breakpoint() + # tractor.devx.mk_pdb().set_trace() + # breakpoint() # TODO: we REALLY need a better console REPL for this # kinda thing..