aboutsummaryrefslogtreecommitdiffstats
path: root/python/markit/import_quotes.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/markit/import_quotes.py')
-rw-r--r--python/markit/import_quotes.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/python/markit/import_quotes.py b/python/markit/import_quotes.py
index 22339bfe..568252ec 100644
--- a/python/markit/import_quotes.py
+++ b/python/markit/import_quotes.py
@@ -179,6 +179,7 @@ def insert_index(engine, workdate=None):
name_mapping = {
"CDXNAHY": "HY",
+ "CDX NAHYBB": "HYBB",
"CDXNAIG": "IG",
"iTraxx Eur": "EU",
"iTraxx Eur Xover": "XO",
@@ -217,9 +218,7 @@ def insert_index(engine, workdate=None):
for col in cols:
data[col] = data[col].str.replace("%", "").astype("float")
data["tenor"] = data["tenor"].apply(lambda x: x.lower() + "r")
- data["index"] = data["index"].apply(
- lambda x: name_mapping[x] if x in name_mapping else np.NaN
- )
+ data["index"] = data["index"].map(name_mapping)
data = data.dropna(subset=["index"])
data["close_spread"] *= 100
data["model_spread"] *= 100
@@ -227,9 +226,10 @@ def insert_index(engine, workdate=None):
data.loc[data.series.isin([9, 10, 11]) & (data.index == "HY"), "version"] -= 3
# data = data.groupby(['index', 'series', 'tenor', 'date'], as_index=False).last()
data["source"] = "MKIT"
- data[ext_cols].to_sql(
- "index_quotes_pre", engine, if_exists="append", index=False
- )
+ place_holders = ",".join(["%s"] * len(ext_cols))
+ sql_str = (f"INSERT INTO index_quotes_pre({','.join(ext_cols)}) "
+ f"VALUES({place_holders}) ON CONFLICT DO NOTHING")
+ engine.execute(sql_str, list(data[ext_cols].itertuples(index=False)))
def insert_tranche(engine, workdate=None):