aboutsummaryrefslogtreecommitdiffstats
path: root/python/reto.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/reto.py')
-rw-r--r--python/reto.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/python/reto.py b/python/reto.py
index 6350a0a3..36a9a345 100644
--- a/python/reto.py
+++ b/python/reto.py
@@ -26,13 +26,23 @@ def parse_args():
return parser.parse_args()
+def vol_surface(portf, try_days_back):
+ for source in ("BAML", "GS", "MS", "JPM"):
+ try:
+ vol_surface = generate_vol_surface(portf, 10, source)
+ except IndexError:
+ pass
+ else:
+ return vol_surface
+
+
def gen_spreads(shock_date, fund):
Trade.init_ontr(shock_date)
ana._local = False
spread_shock = np.array([-100.0, -25.0, 1.0, +25.0, 100.0, 200.0, 500, 1000])
spread_shock /= Trade._ontr["HY"].spread
portf, _ = build_portfolio(shock_date, shock_date, fund)
- vol_surface = generate_vol_surface(portf, 10, "BAML")
+ vol_surface = generate_vol_surface(portf, 10)
portf.reset_pv()
scens = run_portfolio_scenarios(
portf,
@@ -83,7 +93,7 @@ def gen_spreads(shock_date, fund):
for i, g in scens.groupby(level="scen_type", axis=1):
temp = g.groupby(level="strategy", axis=1).sum()
for key, item in strategies.items():
- exist_columns = set(temp.columns).intersection(item)
+ exist_columns = list(set(temp.columns).intersection(item))
temp[key] = temp[exist_columns].sum(axis=1)
temp.drop(exist_columns, axis=1, inplace=True)
temp["total"] = temp.sum(axis=1)