diff options
Diffstat (limited to 'python/exploration/curve_trades.py')
| -rw-r--r-- | python/exploration/curve_trades.py | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/python/exploration/curve_trades.py b/python/exploration/curve_trades.py index 963aac27..a8c791a4 100644 --- a/python/exploration/curve_trades.py +++ b/python/exploration/curve_trades.py @@ -145,13 +145,6 @@ def forward_loss(index='IG'): # annual change, to take out some noise df['fwd_loss_rate'] = df.indexel.diff(2)/df.duration.diff(2) -def read_IG_curve_pos(): - trade_1 = Index.from_tradeid(886) - trade_2 = Index.from_tradeid(885) - trade_1.notional = 132_900_000 - trade_2.notional = 75_000_000 - return Portfolio([trade_1, trade_2]) - def curve_model(tenor_1='5yr', tenor_2='10yr'): #OLS model df = ratio_within_series(param='closespread') @@ -180,25 +173,10 @@ def curve_model_results(df, model): df['dr_dspread'] = np.exp(model.params[0]) * model.params[2] * df.duration1 ** model.params[1] * df.closespread ** (model.params[2] - 1) return df -def curve_var(): - portf = read_IG_curve_pos() - df = curve_model_results(curve_model()[0], curve_model()[1]) - portf.trade_date = pd.datetime.today() - pd.tseries.offsets.BDay(1) - portf.mark() - portf_orig_pv = portf.pv - portf.indices[1].spread = portf.indices[0].spread * df.ratio.quantile(.05) - stress_1 = portf_orig_pv - portf.pv - portf.indices[1].spread = portf.indices[0].spread * df.predicted[-1] - stress_2 = portf_orig_pv - portf.pv - portf.indices[1].spread = portf.indices[0].spread * df.down_2_stdev[-1] - stress_3 = portf_orig_pv - portf.pv - - return stress_1, stress_2, stress_3 - def spread_fin_crisis(index='IG'): - on_the_run = on_the_run(index) + otr = on_the_run(index) ## look at spreads - df = get_index_quotes(index, list(range(8, on_the_run + 1)), + df = get_index_quotes(index, list(range(8, otr + 1)), tenor=['3yr', '5yr', '7yr', '10yr'], years=20) spreads = df.groupby(level=['date', 'tenor']).nth(-1)['closespread'].unstack(-1) spreads_diff = spreads.diff(axis=1) |
