diff options
Diffstat (limited to 'python/exploration')
| -rw-r--r-- | python/exploration/swaption_calendar_spread.py | 2 | ||||
| -rw-r--r-- | python/exploration/tranches.py | 15 |
2 files changed, 6 insertions, 11 deletions
diff --git a/python/exploration/swaption_calendar_spread.py b/python/exploration/swaption_calendar_spread.py index 834fa9e6..d703bbe7 100644 --- a/python/exploration/swaption_calendar_spread.py +++ b/python/exploration/swaption_calendar_spread.py @@ -65,7 +65,7 @@ def plot_color_map(df, spread_shock, vol_shock, attr="pnl", path=".", index ='IG def plot_trade_scenarios(portf, shock_min=-.15, shock_max=.2, period = -1, vol_time_roll=True): portf.reset_pv() - earliest_date = min(portf.swaptions, key=lambda x: x.exercise_date)).exercise_date + earliest_date = min(portf.swaptions, key=lambda x: x.exercise_date).exercise_date #earliest_date = max(portf.swaptions,key=attrgetter('exercise_date')).exercise_date date_range = pd.bdate_range(portf.indices[0].trade_date, earliest_date - BDay(), freq = '3B') vol_shock = np.arange(-0.15, 0.3, 0.01) diff --git a/python/exploration/tranches.py b/python/exploration/tranches.py index 663daf25..094c3e9b 100644 --- a/python/exploration/tranches.py +++ b/python/exploration/tranches.py @@ -48,15 +48,15 @@ def rv_calc1(): tranche2.trade_date = trade_date tranche.build_skew() tranche.rho = tranche.map_skew(tranche, method, 4) - pv = tranche1.tranche_pvs().bond_price + pv = tranche.tranche_pvs().bond_price rho_tlp.append(tranche.rho[1:-1]) pv_tlp.append(pv) tranche2.build_skew() rho_prev_index.append(tranche2.rho[1:-1]) - tranche1.rho = tranche2.rho - pv = tranche1.tranche_pvs(shortened=4).bond_price + tranche.rho = tranche2.rho + pv = tranche.tranche_pvs(shortened=4).bond_price pv_prev_index.append(pv) temp1 = pd.DataFrame(rho_tlp, index=df.date, columns=['3_rho_tlp','7_rho_tlp','15_rho_tlp']) @@ -151,13 +151,11 @@ def run_scen(trade_date = pd.Timestamp.today().normalize()- pd.offsets.BDay()): option1 = BlackSwaption.from_tradeid(13, option_delta) option2 = BlackSwaption.from_tradeid(12, option_delta) portf = Portfolio([option1, option2, option_delta]) - trade_date = pd.Timestamp.today().normalize() - trade_date = trade_date - pd.offsets.BDay() #Start with swaptions portf.reset_pv() portf.mark() - earliest_date = min(portf.swaptions,key=attrgetter('exercise_date')).exercise_date + earliest_date = min(portf.swaptions, key=lambda x: x.exercise_date).exercise_date #date_range = pd.bdate_range(portf.indices[0].trade_date, earliest_date - BDay(), freq = '3B') date_range = pd.date_range(trade_date, periods=4, freq = '5B') vol_shock = np.arange(-0.01, 0.01, 0.01) @@ -176,10 +174,7 @@ def run_scen(trade_date = pd.Timestamp.today().normalize()- pd.offsets.BDay()): df['days'] = ((df.index - trade_date)/ np.timedelta64(1, 'D')).astype(int) #now do the tranches - index = 'IG' - series = 29 - tenor = '5yr' - tranche = bkt.TrancheBasket('IG', series, '5yr', trade_date=trade_date) + tranche = bkt.TrancheBasket('IG', 29, '5yr', trade_date=trade_date) shock_range = (1 + spread_shock) * portf.indices[0].spread results = scenarios(tranche, shock_range, date_range) |
