From cbbf6747371efc766077eb14c237740aa6d53dd9 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 21 Apr 2025 13:34:12 -0400 Subject: [PATCH] Finally drop `Symbol` It was replaced by `MktPair` long ago in, https://github.com/pikers/piker/pull/489 with follow up for final removal in, https://github.com/pikers/piker/issues/517 Resolves #517 --- piker/accounting/__init__.py | 2 - piker/accounting/_mktinfo.py | 91 +----------------------------------- 2 files changed, 2 insertions(+), 91 deletions(-) diff --git a/piker/accounting/__init__.py b/piker/accounting/__init__.py index e27dc4bf..1b776714 100644 --- a/piker/accounting/__init__.py +++ b/piker/accounting/__init__.py @@ -42,7 +42,6 @@ from ._mktinfo import ( dec_digits, digits_to_dec, MktPair, - Symbol, unpack_fqme, _derivs as DerivTypes, ) @@ -60,7 +59,6 @@ __all__ = [ 'Asset', 'MktPair', 'Position', - 'Symbol', 'Transaction', 'TransactionLedger', 'dec_digits', diff --git a/piker/accounting/_mktinfo.py b/piker/accounting/_mktinfo.py index a8c719da..b03635f1 100644 --- a/piker/accounting/_mktinfo.py +++ b/piker/accounting/_mktinfo.py @@ -390,8 +390,8 @@ class MktPair(Struct, frozen=True): cls, fqme: str, - price_tick: float | str, - size_tick: float | str, + price_tick: float|str, + size_tick: float|str, bs_mktid: str, broker: str | None = None, @@ -677,90 +677,3 @@ def unpack_fqme( # '.'.join([mkt_ep, venue]), suffix, ) - - -class Symbol(Struct): - ''' - I guess this is some kinda container thing for dealing with - all the different meta-data formats from brokers? - - ''' - key: str - - broker: str = '' - venue: str = '' - - # precision descriptors for price and vlm - tick_size: Decimal = Decimal('0.01') - lot_tick_size: Decimal = Decimal('0.0') - - suffix: str = '' - broker_info: dict[str, dict[str, Any]] = {} - - @classmethod - def from_fqme( - cls, - fqsn: str, - info: dict[str, Any], - - ) -> Symbol: - broker, mktep, venue, suffix = unpack_fqme(fqsn) - tick_size = info.get('price_tick_size', 0.01) - lot_size = info.get('lot_tick_size', 0.0) - - return Symbol( - broker=broker, - key=mktep, - tick_size=tick_size, - lot_tick_size=lot_size, - venue=venue, - suffix=suffix, - broker_info={broker: info}, - ) - - @property - def type_key(self) -> str: - return list(self.broker_info.values())[0]['asset_type'] - - @property - def tick_size_digits(self) -> int: - return float_digits(self.tick_size) - - @property - def lot_size_digits(self) -> int: - return float_digits(self.lot_tick_size) - - @property - def price_tick(self) -> Decimal: - return Decimal(str(self.tick_size)) - - @property - def size_tick(self) -> Decimal: - return Decimal(str(self.lot_tick_size)) - - @property - def broker(self) -> str: - return list(self.broker_info.keys())[0] - - @property - def fqme(self) -> str: - return maybe_cons_tokens([ - self.key, # final "pair name" (eg. qqq[/usd], btcusdt) - self.venue, - self.suffix, # includes expiry and other con info - self.broker, - ]) - - def quantize( - self, - size: float, - ) -> Decimal: - digits = float_digits(self.lot_tick_size) - return Decimal(size).quantize( - Decimal(f'1.{"0".ljust(digits, "0")}'), - rounding=ROUND_HALF_EVEN - ) - - # NOTE: when cast to `str` return fqme - def __str__(self) -> str: - return self.fqme