diff options
Diffstat (limited to 'python/risk/bonds.py')
| -rw-r--r-- | python/risk/bonds.py | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/python/risk/bonds.py b/python/risk/bonds.py index 4bb3ad2d..9e1e3d3a 100644 --- a/python/risk/bonds.py +++ b/python/risk/bonds.py @@ -102,8 +102,6 @@ def subprime_risk(date, conn, engine): ) df_calc = df_pos.join(df_risk) - df_calc = df_calc[~df_calc["strategy"].str.contains("CRT")].dropna() - yc = YC(evaluation_date=date) df_calc = df_calc.assign( @@ -112,16 +110,14 @@ def subprime_risk(date, conn, engine): curr_ntl=df_calc.notional * df_calc.factor, ) - df_calc.b_yield += np.minimum( - (df_calc.pv1 * df_calc.curr_ntl / df_calc.local_market_value) - ** (1 / df_calc.modDur) - - 1, - 1, - ).dropna() - df_calc.delta_yield *= df_calc.local_market_value / df_calc.pv3 - df_calc.delta_ir *= ( - (df_calc.local_market_value / df_calc.curr_ntl) / df_calc.pv3 * df_calc.curr_ntl + df_calc.b_yield += ( + ((df_calc.pv1 * df_calc.curr_ntl / df_calc.local_market_value).log() / + df_calc.modDur). + clip_upper(1.0) ) + # delta scaled by ratio of market_value to model value + df_calc.delta_yield *= df_calc.local_market_value / df_calc.pv3 + df_calc.delta_ir *= df_calc.local_market_value / df_calc.pv3 return df_calc |
