From 07a96c9a7681d6e92e5fe31c2760d656cc2198b2 Mon Sep 17 00:00:00 2001 From: Chris Berkhout Date: Wed, 5 May 2021 17:44:48 +0200 Subject: [PATCH] List symbols for coindesk. --- src/pricehist/sources/coindesk.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/pricehist/sources/coindesk.py b/src/pricehist/sources/coindesk.py index 604e03b..e63b781 100644 --- a/src/pricehist/sources/coindesk.py +++ b/src/pricehist/sources/coindesk.py @@ -30,24 +30,18 @@ class CoinDesk: def notes(): return "" - @staticmethod - def bases(): - return ["BTC"] - - @staticmethod - def quotes(): + def symbols(self): url = "https://api.coindesk.com/v1/bpi/supported-currencies.json" response = requests.get(url) data = json.loads(response.content) - symbols = sorted([item["currency"] for item in data]) + relevant = [i for i in data if i["currency"] not in ["XBT", "BTC"]] + symbols = sorted( + [f"BTC/{i['currency']} Bitcoin against {i['country']}" for i in relevant] + ) return symbols def fetch(self, pair, type, start, end): base, quote = pair.split("/") - if base not in self.bases(): - exit(f"Invalid base {base}") - if quote not in self.quotes(): - exit(f"Invalid quote {quote}") min_start = "2010-07-17" if start < min_start: