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.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/python/markit/import_quotes.py b/python/markit/import_quotes.py
index ed76941f..ce7049fa 100644
--- a/python/markit/import_quotes.py
+++ b/python/markit/import_quotes.py
@@ -11,7 +11,6 @@ from serenitas.utils.env import BASE_DIR
from itertools import chain, product
from pandas.tseries.offsets import BDay
from pyisda.curve import SpreadCurve, DocClause, Seniority
-from psycopg2.extras import execute_values
from typing import Dict, List, Set, Tuple
from serenitas.analytics.yieldcurve import get_curve
@@ -394,12 +393,13 @@ def insert_index(conn, 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"
+ place_holders = ",".join(["%s"] * len(ext_cols))
sql_str = (
f"INSERT INTO index_quotes_pre({','.join(ext_cols)}) "
- "VALUES %s ON CONFLICT DO NOTHING"
+ f"VALUES ({place_holders}) ON CONFLICT DO NOTHING"
)
with conn.cursor() as c:
- execute_values(c, sql_str, list(data[ext_cols].itertuples(index=False)))
+ c.executemany(sql_str, list(data[ext_cols].itertuples(index=False)))
conn.commit()
@@ -457,10 +457,11 @@ def insert_tranche(conn, workdate=None):
"index_price",
]
)
+ place_holders = ",".join(["%s"] * len(df.columns))
sql_str = (
f"INSERT INTO markit_tranche_quotes({','.join(df.columns)}) "
- "VALUES %s ON CONFLICT DO NOTHING"
+ f"VALUES ({place_holders}) ON CONFLICT DO NOTHING"
)
with conn.cursor() as c:
- execute_values(c, sql_str, list(df.itertuples(index=False)))
+ c.executemany(sql_str, list(df.itertuples(index=False)))
conn.commit()