From f52f3fc7a7cbd055e681a0bf9451d2cb53cc0c01 Mon Sep 17 00:00:00 2001 From: Edward 'Toy' Facundo Date: Sun, 19 Nov 2023 16:09:18 +0000 Subject: [PATCH] upd: resolving a typo in a directory name --- .../coinbase/.gitignore | 0 .../coinbase/Coinbase.py | 25 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) rename {investements => investments}/coinbase/.gitignore (100%) rename {investements => investments}/coinbase/Coinbase.py (77%) diff --git a/investements/coinbase/.gitignore b/investments/coinbase/.gitignore similarity index 100% rename from investements/coinbase/.gitignore rename to investments/coinbase/.gitignore diff --git a/investements/coinbase/Coinbase.py b/investments/coinbase/Coinbase.py similarity index 77% rename from investements/coinbase/Coinbase.py rename to investments/coinbase/Coinbase.py index c15dc51..ebb35ee 100644 --- a/investements/coinbase/Coinbase.py +++ b/investments/coinbase/Coinbase.py @@ -1,12 +1,13 @@ +import requests +from coinbase.wallet.client import Client import json import locale -locale.setlocale(locale.LC_ALL,'en_GB.UTF-8') +locale.setlocale(locale.LC_ALL, 'en_GB.UTF-8') -from coinbase.wallet.client import Client -import requests # Function to get cryptocurrency values + def get_cryptocurrency_value(crypto_symbol, currency='usd'): try: url = f'https://api.coingecko.com/api/v3/simple/price?ids={crypto_symbol}&vs_currencies={currency}' @@ -22,6 +23,7 @@ def get_cryptocurrency_value(crypto_symbol, currency='usd'): print(f"Error: {e}") return None + def convert_cryptocurrency(crypto_symbol, amount, currency='usd'): crypto_value = get_cryptocurrency_value(crypto_symbol, currency) if crypto_value is not None: @@ -29,7 +31,8 @@ def convert_cryptocurrency(crypto_symbol, amount, currency='usd'): return converted_value else: return None - + + class Coinbase: _client = '' # Coinbase Client Handler @@ -51,9 +54,11 @@ def test(self): accounts = self._client.get_accounts() for account in accounts["data"]: if float(account["balance"]["amount"]) != 0.0: - currency = account["currency"] - if currency == 'ETH2': - currency = 'ethereum' - price = convert_cryptocurrency(currency, float(account["balance"]["amount"]), 'gbp') - if price != None: - print(f'{account["currency"]} : {account["balance"]["amount"]} ({locale.currency(price)})') + currency = account["currency"] + if currency == 'ETH2': + currency = 'ethereum' + price = convert_cryptocurrency( + currency, float(account["balance"]["amount"]), 'gbp') + if price != None: + print( + f'{account["currency"]} : {account["balance"]["amount"]} ({locale.currency(price)})')