diff options
Diffstat (limited to 'python/markit/cds.py')
| -rw-r--r-- | python/markit/cds.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/python/markit/cds.py b/python/markit/cds.py index da2ca5c5..8aecb904 100644 --- a/python/markit/cds.py +++ b/python/markit/cds.py @@ -38,18 +38,21 @@ def download_cds_data(payload, workdate, report="FIXED_COUPON"): shutil.copyfileobj(f1, f2)
f1.close()
except zipfile.BadZipFile:
- logger.error(content.getvalue().decode())
+ logger.error(content.getvalue().decode().strip())
-def download_composite_data(payload, workdate, historical=False):
+def download_composite_data(
+ payload, workdate, historical=False, reports=("COMPOSITES", "TRANCHE_COMPOSITES")
+):
# if historical, we want to maintain the invariant mtime(f)== payload['date'] + BDay(1)
if historical:
ts = (workdate + BDay(1)).timestamp()
- for report in ["COMPOSITES", "TRANCHE_COMPOSITES"]:
+ for report in reports:
for family in ["CDX", "ITRAXX-EUROPE"]:
payload.update({"family": family, "report": report})
- while True:
+ retry = 0
+ while retry < 10:
r = requests.post("https://www.markit.com/export.jsp", params=payload)
try:
with zipfile.ZipFile(io.BytesIO(r.content)) as z:
@@ -66,8 +69,9 @@ def download_composite_data(payload, workdate, historical=False): if historical:
os.utime(path, (ts, ts))
except zipfile.BadZipfile:
- logger.error(r.content.decode())
+ logger.error(r.content.decode().strip())
time.sleep(5)
+ retry += 1
continue
else:
break
|
