From 03ea7664c5a5c4d00db3119f63c8b7b8a44116a0 Mon Sep 17 00:00:00 2001 From: Chris Berkhout Date: Tue, 25 May 2021 11:40:12 +0200 Subject: [PATCH] Source start dates are soft limits. --- src/pricehist/cli.py | 6 ++++++ src/pricehist/sources/coindesk.py | 7 ------- src/pricehist/sources/ecb.py | 4 ---- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/pricehist/cli.py b/src/pricehist/cli.py index 2714592..9d9f127 100644 --- a/src/pricehist/cli.py +++ b/src/pricehist/cli.py @@ -88,6 +88,12 @@ def cmd_fetch(args): output = outputs.by_type[args.output]() start = args.start or source.start() + if start < source.start(): + logging.warn( + f"The start date {start} preceeds the {source.name()} " + f"source start date of {source.start()}." + ) + prices = source.fetch(args.pair, args.type, start, args.end) if args.renamebase or args.renamequote: diff --git a/src/pricehist/sources/coindesk.py b/src/pricehist/sources/coindesk.py index 82bafc5..6fb68aa 100644 --- a/src/pricehist/sources/coindesk.py +++ b/src/pricehist/sources/coindesk.py @@ -51,13 +51,6 @@ class CoinDesk: def fetch(self, pair, type, start, end): base, quote = pair.split("/") - min_start = self.start() - if start < min_start: - exit( - f"start {start} too early. The CoinDesk BPI only covers data" - f"from {min_start} onwards." - ) - url = "https://api.coindesk.com/v1/bpi/historical/close.json" params = { "currency": quote, diff --git a/src/pricehist/sources/ecb.py b/src/pricehist/sources/ecb.py index e226053..104fc18 100644 --- a/src/pricehist/sources/ecb.py +++ b/src/pricehist/sources/ecb.py @@ -49,10 +49,6 @@ class ECB: def fetch(self, pair, type, start, end): base, quote = pair.split("/") - min_start = self.start() - if start < min_start: - exit(f"start {start} too early. Minimum is {min_start}") - almost_90_days_ago = str(datetime.now().date() - timedelta(days=85)) data = self._raw_data(start < almost_90_days_ago) root = etree.fromstring(data)