diff --git a/piker/brokers/binance/venues.py b/piker/brokers/binance/venues.py index fe822dd0..08e1f050 100644 --- a/piker/brokers/binance/venues.py +++ b/piker/brokers/binance/venues.py @@ -1,8 +1,5 @@ # piker: trading gear for hackers -# Copyright (C) -# Guillermo Rodriguez (aka ze jefe) -# Tyler Goodlet -# (in stewardship for pikers) +# Copyright (C) Tyler Goodlet (in stewardship for pikers) # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -65,7 +62,7 @@ MarketType = Literal[ 'spot', # 'margin', 'usdtm_futes', - # 'coin_futes', + # 'coinm_futes', ] @@ -144,6 +141,13 @@ class SpotPair(Pair, frozen=True): def bs_fqme(self) -> str: return f'{self.symbol}.SPOT' + @property + def bs_src_asset(self) -> str: + return f'{self.quoteAsset}' + + @property + def bs_dst_asset(self) -> str: + return f'{self.baseAsset}' class FutesPair(Pair): @@ -176,32 +180,51 @@ class FutesPair(Pair): return self.quotePrecision @property - def bs_fqme(self) -> str: + def venue(self) -> str: symbol: str = self.symbol ctype: str = self.contractType margin: str = self.marginAsset match ctype: case 'PERPETUAL': - return f'{symbol}.{margin}M.PERP' + return f'{margin}M.PERP' case 'CURRENT_QUARTER': - pair, _, expiry = symbol.partition('_') - return f'{pair}.{margin}M.{expiry}' + _, _, expiry = symbol.partition('_') + return f'{margin}M.{expiry}' case '': subtype: list[str] = self.underlyingSubType if not subtype: if self.status == 'PENDING_TRADING': - return f'{symbol}.{margin}M.PENDING' + return f'{margin}M.PENDING' - match subtype[0]: - case 'DEFI': - return f'{symbol}.{subtype}.PERP' + match subtype: + case ['DEFI']: + return f'{subtype[0]}.PERP' # XXX: yeah no clue then.. - return f'{symbol}.WTF.PWNED.BBQ' + return 'WTF.PWNED.BBQ' + @property + def bs_fqme(self) -> str: + symbol: str = self.symbol + ctype: str = self.contractType + venue: str = self.venue + + match ctype: + case 'CURRENT_QUARTER': + symbol, _, expiry = symbol.partition('_') + + return f'{symbol}.{venue}' + + @property + def bs_src_asset(self) -> str: + return f'{self.quoteAsset}' + + @property + def bs_dst_asset(self) -> str: + return f'{self.baseAsset}.{self.venue}' PAIRTYPES: dict[MarketType, Pair] = {