aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics')
-rw-r--r--python/analytics/scenarios.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/python/analytics/scenarios.py b/python/analytics/scenarios.py
index 334a27a1..1cc4fb7f 100644
--- a/python/analytics/scenarios.py
+++ b/python/analytics/scenarios.py
@@ -63,7 +63,7 @@ def MaybePool(nproc):
yield Pool(nproc) if nproc > 0 else None
def run_portfolio_scenarios(portf, date_range, spread_shock, vol_shock,
- vol_surface, params=["pnl"], nproc=-1):
+ vol_surface, params=["pnl"], nproc=-1, vol_time_roll=True):
"""computes the pnl of a portfolio for a range of scenarios
Parameters
@@ -80,13 +80,14 @@ def run_portfolio_scenarios(portf, date_range, spread_shock, vol_shock,
"""
portf = deepcopy(portf)
spreads = np.hstack([index.spread * (1 + spread_shock) for index in portf.indices])
-
+ t = [swaption.T for swaption in portf.swaptions]
r = []
with MaybePool(nproc) as pool:
pmap = pool.map if pool else map
for date in date_range:
portf.trade_date = date.date()
- t = [swaption.T for swaption in portf.swaptions]
+ if vol_time_roll:
+ t = [swaption.T for swaption in portf.swaptions]
for s in spreads:
portf.ref = s
mon = [swaption.moneyness for swaption in portf.swaptions]