Source start dates are soft limits.

This commit is contained in:
Chris Berkhout 2021-05-25 11:40:12 +02:00
parent a703b83b00
commit 03ea7664c5
3 changed files with 6 additions and 11 deletions

View file

@ -88,6 +88,12 @@ def cmd_fetch(args):
output = outputs.by_type[args.output]() output = outputs.by_type[args.output]()
start = args.start or source.start() 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) prices = source.fetch(args.pair, args.type, start, args.end)
if args.renamebase or args.renamequote: if args.renamebase or args.renamequote:

View file

@ -51,13 +51,6 @@ class CoinDesk:
def fetch(self, pair, type, start, end): def fetch(self, pair, type, start, end):
base, quote = pair.split("/") 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" url = "https://api.coindesk.com/v1/bpi/historical/close.json"
params = { params = {
"currency": quote, "currency": quote,

View file

@ -49,10 +49,6 @@ class ECB:
def fetch(self, pair, type, start, end): def fetch(self, pair, type, start, end):
base, quote = pair.split("/") 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)) almost_90_days_ago = str(datetime.now().date() - timedelta(days=85))
data = self._raw_data(start < almost_90_days_ago) data = self._raw_data(start < almost_90_days_ago)
root = etree.fromstring(data) root = etree.fromstring(data)