aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/risk/bonds.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/python/risk/bonds.py b/python/risk/bonds.py
index 7e0de99a..4f622355 100644
--- a/python/risk/bonds.py
+++ b/python/risk/bonds.py
@@ -140,7 +140,7 @@ def subprime_risk(date, conn, engine, model_date=None, fund="SERCGMAST"):
yc = YC(evaluation_date=date)
df_calc = df_calc.assign(
- bond_yield=df_calc.modDur.apply(
+ swap_rate=df_calc.modDur.apply(
lambda x: x if np.isnan(x) else float(yc.zero_rate(x))
),
delta_ir=df_calc.delta_ir_io + df_calc.delta_ir_po,
@@ -158,7 +158,7 @@ def subprime_risk(date, conn, engine, model_date=None, fund="SERCGMAST"):
date=pd.Timestamp(date),
)
df_calc = df_calc[(df_calc.usd_market_value != 0)]
- df_calc.bond_yield += (
+ df_calc["bond_yield"] = df_calc.swap_rate + (
np.log(df_calc.pv1 * df_calc.curr_ntl / df_calc.local_market_value)
/ df_calc.modDur
).clip(upper=1.0)
@@ -265,7 +265,7 @@ def crt_risk(date, dawn_conn, crt_engine, fund="SERCGMAST"):
df.rename(columns={"duration_FW": "modDur"}, inplace=True)
df = df[(df.notional != 0)]
df = df.assign(
- bond_yield=df.modDur.apply(
+ swap_rate=df.modDur.apply(
lambda x: x if np.isnan(x) else float(yc.zero_rate(x))
),
curr_ntl=df.notional * df.factor,
@@ -277,7 +277,7 @@ def crt_risk(date, dawn_conn, crt_engine, fund="SERCGMAST"):
* df.factor
),
)
- df.bond_yield += df.DM / 10000
+ df["bond_yield"] = df.swap_rate + df.DM / 10000
delta = pd.read_sql_query(
"SELECT distinct on (strategy) "
"strategy, beta_crt from beta_crt WHERE "
@@ -310,9 +310,10 @@ def clo_risk(date, dawn_conn, et_conn, fund="SERCGMAST"):
curr_ntl=df.notional * df.factor,
hy_equiv=(df.delta * df.notional * df.factor),
)
+ df["swap_rate"] = float(yc.zero_rate(0.25))
df.bond_yield += (
np.log(df.curr_ntl / df.local_market_value) / df.modDur
+ df.curr_cpn / 100
- - float(yc.zero_rate(0.25))
+ - df.swap_rate
).clip(upper=1.0)
return df