From b3bbef30c0aa5b4a276bfc65a8e029b08bb43681 Mon Sep 17 00:00:00 2001 From: Nelson Torres Date: Wed, 6 Nov 2024 14:29:19 +0000 Subject: [PATCH] add class Pair in venues, PAIRTYPES for future uses --- piker/brokers/deribit/venues.py | 38 ++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/piker/brokers/deribit/venues.py b/piker/brokers/deribit/venues.py index cb8f2b62..33d3139c 100644 --- a/piker/brokers/deribit/venues.py +++ b/piker/brokers/deribit/venues.py @@ -56,25 +56,44 @@ def get_api_eps(venue: MarketType) -> tuple[str, str]: }[venue] -class OptionPair(Struct, frozen=True, kw_only=True): +class Pair(Struct, frozen=True, kw_only=True): symbol: str - venue: str # src - quote_currency: str + quote_currency: str # 'BTC' # dst - base_currency: str + settlement_currency: str # "BTC", tick_size: float # 0.0001 - tick_size_steps: list[dict] # [{'above_price': 0.005, 'tick_size': 0.0005}] + tick_size_steps: list[dict[str, str | int | float]] # [{'above_price': 0.005, 'tick_size': 0.0005}] + + @property + def price_tick(self) -> Decimal: + step_size: str = self.tick_size_steps[0].get('above_price') + return Decimal(step_size) + + @property + def size_tick(self) -> Decimal: + step_size: str = self.tick_size_steps[0].get('tick_size') + return Decimal(step_size) + + @property + def bs_fqme(self) -> str: + return self.symbol + + @property + def bs_mktid(self) -> str: + return f'{self.symbol}.{self.venue}' + + +class OptionPair(Struct, frozen=True, kw_only=True): + taker_commission: float # 0.0003 strike: float # 5000.0 settlement_period: str # 'day' - settlement_currency: str # "BTC", rfq: bool # false - quote_currency: str # 'BTC' price_index: str # 'btc_usd' option_type: str # 'call' min_trade_amount: float # 0.1 @@ -110,10 +129,13 @@ class OptionPair(Struct, frozen=True, kw_only=True): @property def bs_dst_asset(self) -> str: - return f'{self.base_currency}' + return f'{self.settlement_currency}' @property def bs_mktid(self) -> str: return f'{self.symbol}.{self.venue}' +PAIRTYPES: dict[MarketType, Pair] = { + 'option': OptionPair, +}