aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/exploration/test_scenarios.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/python/exploration/test_scenarios.py b/python/exploration/test_scenarios.py
new file mode 100644
index 00000000..f48a8d8d
--- /dev/null
+++ b/python/exploration/test_scenarios.py
@@ -0,0 +1,21 @@
+import numpy as np
+import pandas as pd
+from analytics import Index, BlackSwaption, Portfolio, BlackSwaptionVolSurface
+from pandas.tseries.offsets import BDay
+from analytics.scenarios import run_portfolio_scenarios
+
+option_delta = Index.from_tradeid(874)
+option1 = BlackSwaption.from_tradeid(7, option_delta)
+option2 = BlackSwaption.from_tradeid(8, option_delta)
+portf = Portfolio([option1, option2, option_delta], ['opt1', 'opt2', 'delta'])
+date_range = pd.bdate_range(option_delta.value_date,
+ pd.Timestamp('2017-05-17') - BDay(), freq='5B')
+vol_shock = np.arange(-0.15, 0.3, 0.01)
+spread_shock = np.arange(-0.2, 0.3, 0.01)
+vs = BlackSwaptionVolSurface("IG", 28, value_date=option_delta.value_date)
+vol_surface = vs[vs.list(source="BAML")[-1]]
+df = run_portfolio_scenarios(portf, date_range,
+ params=['pnl', 'delta', 'spread'],
+ spread_shock=spread_shock,
+ vol_shock=vol_shock,
+ vol_surface=vol_surface)