aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/reto.py4
-rw-r--r--python/risk/portfolio.py9
2 files changed, 11 insertions, 2 deletions
diff --git a/python/reto.py b/python/reto.py
index f3708390..94e259f2 100644
--- a/python/reto.py
+++ b/python/reto.py
@@ -16,7 +16,9 @@ def gen_shocks(portf, shock_date, fund):
# Add in 2020 HY Wides, 2021 HY Tights, 2022 HY Wides scenarios
historic_spreads = np.array([872, 269, 626])
spread_shock = np.append(spread_shock, historic_spreads / ontr_spread - 1.0)
- vol_surface = generate_vol_surface(portf, lookback=10, source="BAML")
+ vol_surface = generate_vol_surface(
+ portf, lookback=10, source_list=["BAML", "MS", "JPM"]
+ )
scens = run_portfolio_scenarios(
portf,
date_range=[pd.Timestamp(shock_date)],
diff --git a/python/risk/portfolio.py b/python/risk/portfolio.py
index 8f438287..8ea8001e 100644
--- a/python/risk/portfolio.py
+++ b/python/risk/portfolio.py
@@ -90,7 +90,7 @@ def build_portfolio(position_date, value_date, fund="SERCGMAST"):
return portf, syn_portf
-def generate_vol_surface(portf, lookback=5, source="MS"):
+def generate_vol_surface(portf, lookback=5, source_list=["MS"]):
vol_surface = {}
for trade in portf.swaptions:
@@ -115,6 +115,13 @@ def generate_vol_surface(portf, lookback=5, source="MS"):
logger.info(f"Trying {portf.value_date - BDay(i)}")
else:
break
+ for source in source_list:
+ if len(vs.list(source, option_type)) >= 1:
+ break
+ else:
+ raise MissingDataError(
+ f"{type(vs).__name__}: No quote for type {option_type} and date {portf.value_date}"
+ )
vol_surface[k] = vs[vs.list(source=source, option_type=option_type)[-1]]
return vol_surface