aboutsummaryrefslogtreecommitdiffstats
path: root/python/exploration/swaption_calendar_spread.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/exploration/swaption_calendar_spread.py')
-rw-r--r--python/exploration/swaption_calendar_spread.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/python/exploration/swaption_calendar_spread.py b/python/exploration/swaption_calendar_spread.py
index f3c1aaf0..d26ad0ee 100644
--- a/python/exploration/swaption_calendar_spread.py
+++ b/python/exploration/swaption_calendar_spread.py
@@ -114,7 +114,7 @@ def plot_color_map(df, spread_shock, vol_shock, attr="pnl", path=".", index ='IG
fig.colorbar(chart, shrink=.8)
#fig.savefig(os.path.join(path, "vol_spread_color_map"+ attr+ "_{}.png".format(val_date)))
-def plot_time_color_map(df, spread_shock, attr="pnl", path=".", color_map = cm.RdYlGn, index ='IG'):
+def plot_time_color_map(df, spread_shock, attr="pnl", path=".", color_map=cm.RdYlGn, index='IG'):
val_date = df.index[0].date()
df = df.reset_index()
@@ -143,7 +143,7 @@ def plot_time_color_map(df, spread_shock, attr="pnl", path=".", color_map = cm.R
fig.colorbar(chart, shrink=.8)
#fig.savefig(os.path.join(path, "spread_time_color_map_"+ attr+ "_{}.png".format(val_date)))
-def plot_trade_scenarios(portf, shock_min = -.15, shock_max = .2):
+def plot_trade_scenarios(portf, shock_min=-.15, shock_max=.2):
portf.reset_pv()
earliest_date = min(portf.swaptions,key=attrgetter('exercise_date')).exercise_date
@@ -156,9 +156,11 @@ def plot_trade_scenarios(portf, shock_min = -.15, shock_max = .2):
vol_select = vs.list(option_type='payer', model='black')[-1]
vol_surface = vs[vol_select]
- df = run_portfolio_scenarios(portf, date_range, spread_shock, vol_shock, vol_surface, params=["pnl","delta"], vol_time_roll=True)
+ df = run_portfolio_scenarios(portf, date_range, spread_shock, vol_shock, vol_surface,
+ params=["pnl","delta"], vol_time_roll=True)
- hy_plot_range = 100 + (500- portf.indices[0].spread * (1 + spread_shock))*abs(portf.indices[0].DV01)/portf.indices[0].notional*100
+ hy_plot_range = 100 + (500 - portf.indices[0].spread * (1 + spread_shock)) * \
+ abs(portf.indices[0].DV01) / portf.indices[0].notional * 100
shock = hy_plot_range if index == 'HY' else portf.indices[0].spread * (1 + spread_shock)
@@ -232,4 +234,4 @@ def exercise_probability():
vol_surface = vs[vol_select]
prob = vs.prob_surf(vol_select)
- vs.prob_plot(vol_select) \ No newline at end of file
+ vs.prob_plot(vol_select)