diff options
Diffstat (limited to 'python/notebooks/VaR.ipynb')
| -rw-r--r-- | python/notebooks/VaR.ipynb | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/python/notebooks/VaR.ipynb b/python/notebooks/VaR.ipynb index 178d72b3..2fa3ee1d 100644 --- a/python/notebooks/VaR.ipynb +++ b/python/notebooks/VaR.ipynb @@ -28,7 +28,7 @@ "metadata": {}, "outputs": [], "source": [ - "date = (datetime.date.today() - pd.tseries.offsets.BDay(3)).date()\n", + "date = (datetime.date.today() - pd.tseries.offsets.BDay(1)).date()\n", "report_date = (date + pd.tseries.offsets.BMonthEnd(-1)).date()\n", "index_type = \"IG\"\n", "quantile = .025" @@ -134,7 +134,7 @@ " \"AND trade_date <= %s\")\n", "swaption_sql_string = (\"select id, security_desc from swaptions where date(expiration_date) \"\n", " \"> %s and swap_type = 'CD_INDEX_OPTION' \"\n", - " \"AND trade_date <= %s\")\n", + " \"AND trade_date <= %s AND termination_date iS NULL\")\n", "index_sql_string = (\"SELECT id, sum(notional * case when protection='Buyer' then -1 else 1 end) \"\n", " \"OVER (partition by security_id, attach) AS ntl_agg \"\n", " \"FROM cds WHERE swap_type='CD_INDEX' AND termination_cp IS null \"\n", @@ -166,14 +166,14 @@ "portf.add_trade(CreditIndex('HY', on_the_run('HY'), '5yr', value_date = date, notional = -non_trancheSwap_risk_notional), 'bond')\n", " \n", "portf.value_date = date\n", - "portf.mark(interp_method=\"bivariate_spline\")\n", + "portf.mark(interp_method=\"bivariate_linear\")\n", "portf.reset_pv()\n", - " \n", - "vs = BlackSwaptionVolSurface(portf.swaptions[0].index.index_type, \n", - " portf.swaptions[0].index.series, \n", - " value_date=date, \n", - " interp_method = \"bivariate_spline\")\n", - "vol_surface = vs[vs.list(option_type='payer')[-1]]\n", + "\n", + "vol_surface = {}\n", + "for trade in portf.swaptions:\n", + " vs = BlackSwaptionVolSurface(trade.index.index_type, trade.index.series, \n", + " value_date=date, interp_method = \"bivariate_linear\")\n", + " vol_surface[trade.index.index_type + trade.index.series] = vs[vs.list(option_type='payer')[-1]]\n", "vol_shock = [0]\n", "corr_shock = [0]\n", "spread_shock = widen + tighten\n", |
