diff --git a/piker/accounting/__init__.py b/piker/accounting/__init__.py index 167dbcc2..d6e1c3b6 100644 --- a/piker/accounting/__init__.py +++ b/piker/accounting/__init__.py @@ -88,7 +88,7 @@ def get_likely_pair( ''' try: - src_name_start = bs_mktid.rindex(src) + src_name_start: str = bs_mktid.rindex(src) except ( ValueError, # substr not found ): @@ -99,8 +99,8 @@ def get_likely_pair( # log.warning( # f'No src fiat {src} found in {bs_mktid}?' # ) - return + return None - likely_dst = bs_mktid[:src_name_start] + likely_dst: str = bs_mktid[:src_name_start] if likely_dst == dst: return bs_mktid diff --git a/piker/accounting/_ledger.py b/piker/accounting/_ledger.py index b6f0ee74..f4cb3f38 100644 --- a/piker/accounting/_ledger.py +++ b/piker/accounting/_ledger.py @@ -28,6 +28,7 @@ from typing import ( Any, Callable, Generator, + Literal, TYPE_CHECKING, ) @@ -51,6 +52,18 @@ if TYPE_CHECKING: log = get_logger(__name__) +TxnType = Literal[ + 'clear', + 'transfer', + + # TODO: see https://github.com/pikers/piker/issues/510 + # 'split', + # 'rename', + # 'resize', + # 'removal', +] + + class Transaction(Struct, frozen=True): # NOTE: this is a unified acronym also used in our `MktPair` @@ -70,10 +83,9 @@ class Transaction(Struct, frozen=True): cost: float # commisions or other additional costs dt: DateTime - # the "event type" in terms of "market events" see - # https://github.com/pikers/piker/issues/510 for where we're - # probably going with this. - etype: str = 'clear' + # the "event type" in terms of "market events" see above and + # https://github.com/pikers/piker/issues/510 + etype: TxnType = 'clear' # TODO: we can drop this right since we # can instead expect the backend to provide this