aboutsummaryrefslogtreecommitdiffstats
path: root/python/reto.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/reto.py')
-rw-r--r--python/reto.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/python/reto.py b/python/reto.py
index 85c48563..bb3b37df 100644
--- a/python/reto.py
+++ b/python/reto.py
@@ -90,16 +90,16 @@ def save_shocks(conn, date, df, fund):
def get_survival_curves(conn, date):
surv_curves = (
- load_all_curves(conn, date)
- .loc[~load_all_curves(conn, date).index.duplicated(keep="first")]
- .assign(
- **{
- f"{cds_tenor}yr_spread": lambda df: df["curve"].apply(
- lambda sc: [h for d, h in sc][cds_tenor]
- * (1 - sc.recovery_rates[cds_tenor])
- )
- for cds_tenor in (1, 3, 5)
- }
+ (
+ load_all_curves(conn, date).assign(
+ **{
+ f"{cds_tenor}yr_spread": lambda df: df["curve"].apply(
+ lambda sc: [h for d, h in sc][cds_tenor]
+ * (1 - sc.recovery_rates[cds_tenor])
+ )
+ for cds_tenor in (1, 3, 5)
+ }
+ )
)
.groupby(level=0)
.first()[["name", "company_id", "1yr_spread", "3yr_spread", "5yr_spread"]]
@@ -132,8 +132,8 @@ def save_jtd(conn, date, df, fund):
)
conn.commit()
c.executemany(
- "INSERT INTO jtd_risks(date, fund, company_id, name, five_year_spread, jtd) "
- "VALUES (%s, %s, %s, %s, %s, %s)",
+ "INSERT INTO jtd_risks(date, fund, company_id, name, 1yr_spread, 3yr_spread, 5yr_spread, jtd) "
+ "VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
[(date, fund, *t) for t in df.itertuples(index=False)],
)
conn.commit()