aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/markit/cds.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/python/markit/cds.py b/python/markit/cds.py
index a5f58c6f..ee0b0e69 100644
--- a/python/markit/cds.py
+++ b/python/markit/cds.py
@@ -19,7 +19,8 @@ def convertToNone(v):
_MARKIT_CDS_URL = "https://www.cds.ihsmarkit.com/export.jsp"
-def download_cds_data(payload, workdate, report="FIXED_COUPON"):
+def download_cds_data(payload, workdate, report="FIXED_COUPON", file_format="csv"):
+ file_format = payload["format"]
payload.update({"report": report})
r = requests.post(_MARKIT_CDS_URL, params=payload)
content = io.BytesIO(r.content)
@@ -27,12 +28,12 @@ def download_cds_data(payload, workdate, report="FIXED_COUPON"):
if not save_dir.exists():
save_dir.mkdir()
suffix = "fixed" if report == "FIXED_COUPON" else "parspread"
- csv_file = save_dir / f"{workdate}_{suffix}.csv.lz4"
+ data_file = save_dir / f"{workdate}_{suffix}.{file_format}.lz4"
try:
with zipfile.ZipFile(content) as z:
- with lz4.frame.open(csv_file, "wb") as f2:
+ with lz4.frame.open(data_file, "wb") as f2:
for f in z.namelist():
- if f.endswith("csv"):
+ if f.endswith(file_format):
f1 = z.open(f)
if report == "FIXED_COUPON":
next(f1)
@@ -59,7 +60,7 @@ def download_composite_data(
try:
with zipfile.ZipFile(io.BytesIO(r.content)) as z:
for f in z.namelist():
- if f.endswith("csv"):
+ if f.endswith(payload["format"]):
path = z.extract(
f,
path=BASE_DIR