aboutsummaryrefslogtreecommitdiffstats
path: root/python/markit/cds.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/markit/cds.py')
-rw-r--r--python/markit/cds.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/python/markit/cds.py b/python/markit/cds.py
index d039b474..da2ca5c5 100644
--- a/python/markit/cds.py
+++ b/python/markit/cds.py
@@ -17,21 +17,24 @@ def convertToNone(v):
return v if v else None
-def download_cds_data(payload, workdate):
+def download_cds_data(payload, workdate, report="FIXED_COUPON"):
+ payload.update({"report": report})
r = requests.post("https://www.markit.com/export.jsp", params=payload)
content = io.BytesIO(r.content)
save_dir = BASE_DIR / "Tranche_data" / "CDS" / f"{workdate:%Y}"
if not save_dir.exists():
save_dir.mkdir()
- csv_file = save_dir / f"{workdate}_fixed.csv.lz4"
+ suffix = "fixed" if report == "FIXED_COUPON" else "parspread"
+ csv_file = save_dir / f"{workdate}_{suffix}.csv.lz4"
try:
with zipfile.ZipFile(content) as z:
with lz4.frame.open(csv_file, "wb") as f2:
for f in z.namelist():
if f.endswith("csv"):
f1 = z.open(f)
- next(f1)
- next(f1)
+ if report == "FIXED_COUPON":
+ next(f1)
+ next(f1)
shutil.copyfileobj(f1, f2)
f1.close()
except zipfile.BadZipFile: