aboutsummaryrefslogtreecommitdiffstats
path: root/python/bbg_index_quotes.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/bbg_index_quotes.py')
-rw-r--r--python/bbg_index_quotes.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/python/bbg_index_quotes.py b/python/bbg_index_quotes.py
index 92e3d180..349762f9 100644
--- a/python/bbg_index_quotes.py
+++ b/python/bbg_index_quotes.py
@@ -14,8 +14,14 @@ for series in range(10, 30):
securities[f"ITRX {index_type} CDSI S{series} {t}Y Corp"] = \
(series, index_type, f"{t}yr")
-sql_str = (f"INSERT INTO bbg_index_quotes VALUES({','.join(['%s'] * 8)}) "
- "ON CONFLICT DO NOTHING")
+place_holders = ",".join(['%s'] * 7)
+sql_str_price = ("INSERT INTO index_quotes_pre"
+ "(date, index, series, version, tenor, close_price, source)"
+ f" VALUES({place_holders}) ON CONFLICT DO NOTHING")
+sql_str_spread = ("INSERT INTO index_quotes_pre"
+ "(date, index, series, version, tenor, close_spread, source)"
+ f" VALUES({place_holders}) ON CONFLICT DO NOTHING")
+
start_date = datetime.date.today() - datetime.timedelta(days=7) # one weeek of overlap
conn = dbconn('serenitasdb')
with init_bbg_session(BBG_IP) as session:
@@ -34,8 +40,12 @@ with init_bbg_session(BBG_IP) as session:
index = "EU"
if index == "XOVER":
index = "XO"
+ if index == "HY":
+ sql_str = sql_str_price
+ else:
+ sql_str = sql_str_spread
if not v.empty:
c.executemany(sql_str,
- [(t[0], ticker, index, series, tenor, version, t[1], pcs)
+ [(t[0], index, series, version, tenor, t[1], pcs)
for t in v.itertuples()])
conn.commit()