def check_coin(coin_id: str): coins = read_file_data("coingecko_coins.json") for coin in coins: if coin["id"] == coin_id: return coin["id"] if coin["symbol"] == coin_id: return coin["id"] return None
def __init__(self, symbol: str, load_from_api: bool = False): self.client = CoinGeckoAPI() if load_from_api: self._coin_list = self.client.get_coins_list() else: self._coin_list = read_file_data("coingecko_coins.json") self.coin_symbol, self.symbol = self._validate_coin(symbol) if self.coin_symbol: self.coin: Dict[Any, Any] = self._get_coin_info()
def __init__(self, symbol: str, load_from_api: bool = False): self.client = CoinGeckoAPI() if load_from_api: self._coin_list = self.client.get_coins_list() else: self._coin_list = read_file_data("coingecko_coins.json") self.coin_symbol, self.symbol = self._validate_coin(symbol) if self.coin_symbol: self.coin: Dict[Any, Any] = self._get_coin_info() else: console.print( f"[red]Could not find coin with the given id: {symbol}\n[/red]" )