Lista di cryptovalute #36

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

View File

@@ -57,7 +57,7 @@ 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. Formatta l'asset_id nel formato richiesto da Binance.
""" """
i = asset_id.index('-') i = asset_id.find('-')
if i != -1: asset_id = asset_id[:i] if i != -1: asset_id = asset_id[:i]
return f"{asset_id}{self.currency}" if self.currency not in asset_id else asset_id return f"{asset_id}{self.currency}" if self.currency not in asset_id else asset_id

View File

@@ -61,7 +61,7 @@ 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: def __format(self, asset_id: str) -> str:
i = asset_id.index('-') i = asset_id.find('-')
if i != -1: asset_id = asset_id[:i] if i != -1: asset_id = asset_id[:i]
return f"{asset_id}-{self.currency}" return f"{asset_id}-{self.currency}"

View File

@@ -47,7 +47,7 @@ class YFinanceWrapper(MarketWrapper):
Formatta il simbolo per yfinance. 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). Per crypto, aggiunge '-' e la valuta (es. BTC -> BTC-USD).
""" """
i = asset_id.index('-') i = asset_id.find('-')
if i != -1: asset_id = asset_id[:i] if i != -1: asset_id = asset_id[:i]
return f"{asset_id}-{self.currency}" return f"{asset_id}-{self.currency}"

View File

@@ -44,7 +44,7 @@ class CryptoSymbolsTools(Toolkit):
Args: Args:
query (str): Query di ricerca. query (str): Query di ricerca.
Returns: Returns:
list[str]: Lista di simboli che contengono la query. list[tuple[str, str]]: Lista di tuple (simbolo, nome) che contengono la query.
""" """
query_lower = query.lower() query_lower = query.lower()
positions = self.final_table['Name'].str.lower().str.contains(query_lower) positions = self.final_table['Name'].str.lower().str.contains(query_lower)
@@ -59,7 +59,7 @@ class CryptoSymbolsTools(Toolkit):
if not force_refresh and not self.final_table.empty: if not force_refresh and not self.final_table.empty:
return return
num_currencies = 250 # It looks like is the max per page otherwise yahoo returns 26 num_currencies = 250 # It looks like this is the max per page otherwise yahoo returns 26
offset = 0 offset = 0
stop = not self.final_table.empty stop = not self.final_table.empty
table = self.final_table.copy() table = self.final_table.copy()