From 4c4787ce583ca674b75efa01b962bd785675159d Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 13 Jun 2023 15:20:27 -0400 Subject: [PATCH] Add a "perpetual_future" mkt info type --- piker/accounting/__init__.py | 2 ++ piker/accounting/_mktinfo.py | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/piker/accounting/__init__.py b/piker/accounting/__init__.py index 778bdd4e..8f55217c 100644 --- a/piker/accounting/__init__.py +++ b/piker/accounting/__init__.py @@ -40,6 +40,7 @@ from ._mktinfo import ( MktPair, Symbol, unpack_fqme, + _derivs as DerivTypes, ) from ._allocate import ( mk_allocator, @@ -65,6 +66,7 @@ __all__ = [ 'open_pps', 'open_trade_ledger', 'unpack_fqme', + 'DerivTypes', ] diff --git a/piker/accounting/_mktinfo.py b/piker/accounting/_mktinfo.py index be1cc535..1ac85369 100644 --- a/piker/accounting/_mktinfo.py +++ b/piker/accounting/_mktinfo.py @@ -39,6 +39,7 @@ from typing import ( from ..data.types import Struct +# TODO: make these literals.. _underlyings: list[str] = [ 'stock', 'bond', @@ -52,6 +53,7 @@ _derivs: list[str] = [ 'swap', 'future', 'continuous_future', + 'perpetual_future', 'option', 'futures_option', @@ -540,10 +542,15 @@ class MktPair(Struct, frozen=True): # TODO: BACKWARD COMPAT, TO REMOVE? @property def type_key(self) -> str: + + # if set explicitly then use it! + if self._atype: + return self._atype + if isinstance(self.dst, Asset): return str(self.dst.atype) - return self._atype + return 'unknown' @property def price_tick_digits(self) -> int: