aboutsummaryrefslogtreecommitdiffstats
path: root/python/build_default_table.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/build_default_table.py')
-rw-r--r--python/build_default_table.py36
1 files changed, 22 insertions, 14 deletions
diff --git a/python/build_default_table.py b/python/build_default_table.py
index 5842d2ea..7a91ca83 100644
--- a/python/build_default_table.py
+++ b/python/build_default_table.py
@@ -1,18 +1,26 @@
import pandas as pd
-from bbg_helpers import init_bbg_session, BBG_IP, retrieve_data
+from bbg_helpers import init_bbg_session, retrieve_data
from utils.db import serenitas_engine
-indices = ["CDX HY CDSI S19 5Y", "ITRX XOVER CDSI S25 5Y",
- "CDX HY CDSI S15 5Y", "ITRX XOVER CDSI S20 5Y",
- "CDX HY CDSI S25 5Y",
- "ITRX EUR CDSI S17 10Y"]
-with init_bbg_session(BBG_IP) as session:
- d = retrieve_data(session, [f"{i} Corp" for i in indices], "CDS_INDEX_DEFAULT_INFORMATION")
-df = pd.concat([v["CDS_INDEX_DEFAULT_INFORMATION"] for v in d.values()],
- ignore_index=True)
-df['Company ID'] = df['Company ID'].astype('int')
-df = df[~df.duplicated(['Company ID'])]
+indices = [
+ "CDX HY CDSI S19 5Y",
+ "ITRX XOVER CDSI S25 5Y",
+ "CDX HY CDSI S15 5Y",
+ "ITRX XOVER CDSI S20 5Y",
+ "CDX HY CDSI S25 5Y",
+ "ITRX EUR CDSI S17 10Y",
+]
+with init_bbg_session() as session:
+ d = retrieve_data(
+ session, [f"{i} Corp" for i in indices], "CDS_INDEX_DEFAULT_INFORMATION"
+ )
+
+df = pd.concat(
+ [v["CDS_INDEX_DEFAULT_INFORMATION"] for v in d.values()], ignore_index=True
+)
+df["Company ID"] = df["Company ID"].astype("int")
+df = df[~df.duplicated(["Company ID"])]
breakpoint()
-df = df[['Company ID', 'Auction Date', 'Event Date', 'CDS Recovery Rate']]
-df.columns = ['id', 'auction_date', 'event_date', 'recovery']
-df.to_sql('defaulted', serenitas_engine, if_exists='append', index=False)
+df = df[["Company ID", "Auction Date", "Event Date", "CDS Recovery Rate"]]
+df.columns = ["id", "auction_date", "event_date", "recovery"]
+df.to_sql("defaulted", serenitas_engine, if_exists="append", index=False)