Lista di cryptovalute #36

Merged
Berack96 merged 9 commits from 31-lista-di-cryptovalute into main 2025-10-21 15:58:42 +02:00
3 changed files with 9 additions and 4 deletions
Showing only changes of commit 0c83d54b85 - Show all commits

View File

@@ -57,7 +57,9 @@ class BinanceWrapper(MarketWrapper):
"""
copilot-pull-request-reviewer[bot] commented 2025-10-21 13:23:19 +02:00 (Migrated from github.com)
Review

The str.index() method raises a ValueError when the substring is not found, rather than returning -1. This will cause a runtime error when processing symbols without a hyphen. Use asset_id.find('-') instead, which returns -1 when not found, or handle the ValueError exception.

        i = asset_id.find('-')
The `str.index()` method raises a `ValueError` when the substring is not found, rather than returning -1. This will cause a runtime error when processing symbols without a hyphen. Use `asset_id.find('-')` instead, which returns -1 when not found, or handle the `ValueError` exception. ```suggestion i = asset_id.find('-') ```
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):
)
copilot-pull-request-reviewer[bot] commented 2025-10-21 13:23:19 +02:00 (Migrated from github.com)
Review

The str.index() method raises a ValueError when the substring is not found, rather than returning -1. This will cause a runtime error when processing symbols without a hyphen. Use asset_id.find('-') instead, which returns -1 when not found, or handle the ValueError exception.

        i = asset_id.find('-')
The `str.index()` method raises a `ValueError` when the substring is not found, rather than returning -1. This will cause a runtime error when processing symbols without a hyphen. Use `asset_id.find('-')` instead, which returns -1 when not found, or handle the `ValueError` exception. ```suggestion i = asset_id.find('-') ```
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.
copilot-pull-request-reviewer[bot] commented 2025-10-21 13:23:19 +02:00 (Migrated from github.com)
Review

The str.index() method raises a ValueError when the substring is not found, rather than returning -1. This will cause a runtime error when processing symbols without a hyphen. Use asset_id.find('-') instead, which returns -1 when not found, or handle the ValueError exception.

        i = asset_id.find('-')
The `str.index()` method raises a `ValueError` when the substring is not found, rather than returning -1. This will cause a runtime error when processing symbols without a hyphen. Use `asset_id.find('-')` instead, which returns -1 when not found, or handle the `ValueError` exception. ```suggestion i = asset_id.find('-') ```
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)