fix format symbol in all markets

This commit is contained in:
2025-10-21 13:20:03 +02:00
parent b1aba10c6c
commit 0c83d54b85
3 changed files with 9 additions and 4 deletions

View File

@@ -57,7 +57,9 @@ class BinanceWrapper(MarketWrapper):
"""
Formatta l'asset_id nel formato richiesto da Binance.
"""
return asset_id.replace('-', '') if '-' in asset_id else f"{asset_id}{self.currency}"
i = asset_id.index('-')
if i != -1: asset_id = asset_id[:i]
return f"{asset_id}{self.currency}" if self.currency not in asset_id else asset_id
def get_product(self, asset_id: str) -> ProductInfo:
symbol = self.__format_symbol(asset_id)

View File

@@ -61,7 +61,9 @@ class CoinBaseWrapper(MarketWrapper):
)
def __format(self, asset_id: str) -> str:
return asset_id if '-' in asset_id else f"{asset_id}-{self.currency}"
i = asset_id.index('-')
if i != -1: asset_id = asset_id[:i]
return f"{asset_id}-{self.currency}"
def get_product(self, asset_id: str) -> ProductInfo:
asset_id = self.__format(asset_id)

View File

@@ -47,8 +47,9 @@ class YFinanceWrapper(MarketWrapper):
Formatta il simbolo per yfinance.
Per crypto, aggiunge '-' e la valuta (es. BTC -> BTC-USD).
"""
asset_id = asset_id.upper()
return f"{asset_id}-{self.currency}" if '-' not in asset_id else asset_id
i = asset_id.index('-')
if i != -1: asset_id = asset_id[:i]
return f"{asset_id}-{self.currency}"
def get_product(self, asset_id: str) -> ProductInfo:
symbol = self._format_symbol(asset_id)