aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/markit/__main__.py15
-rw-r--r--python/markit/rates.py2
2 files changed, 14 insertions, 3 deletions
diff --git a/python/markit/__main__.py b/python/markit/__main__.py
index 211b507b..cfe6e510 100644
--- a/python/markit/__main__.py
+++ b/python/markit/__main__.py
@@ -3,6 +3,7 @@ import logging
import numpy as np
import pandas as pd
import os
+import time
from .cds import download_cds_data, download_composite_data
from .loans import download_facility, insert_facility, download_marks, update_facility
@@ -87,5 +88,15 @@ elif args.cds:
elif args.rates:
for curr in ["USD", "EUR", "JPY"]:
- downloadMarkitIRData(workdate, currency=curr)
- logger.info("Downloaded {} rates".format(curr))
+ retry = 0
+ while retry < 10:
+ try:
+ downloadMarkitIRData(workdate, currency=curr)
+ except ValueError as e:
+ logger.error(e)
+ logger.error(f"Could not download {curr} rates for date {workdate}")
+ time.sleep(30)
+ retry += 1
+ else:
+ logger.info(f"Downloaded {curr} rates")
+ break
diff --git a/python/markit/rates.py b/python/markit/rates.py
index 9f46d9d1..386cea7e 100644
--- a/python/markit/rates.py
+++ b/python/markit/rates.py
@@ -24,7 +24,7 @@ def downloadMarkitIRData(download_date=datetime.date.today(),
with zipfile.ZipFile(BytesIO(r.content)) as z:
z.extractall(path=os.path.join(os.environ['DATA_DIR'], "Yield Curves"))
else:
- return downloadMarkitIRData(download_date - datetime.timedelta(days=1))
+ raise ValueError(r.content.decode().rstrip())
tree = ET.parse(os.path.join(os.environ['DATA_DIR'], "Yield Curves", filename + '.xml'))
deposits = zip([e.text for e in tree.findall('./deposits/*/tenor')],