stop = timeit.default_timer() print('calibration time : ', stop - start) print('daily_hedge_errors = ', daily_hedge_errors) print('daily_pct_hedge_errors = ', daily_pct_hedge_errors) with open( os.path.abspath('..') + '/intermediate_data/hedging_daily_hedge_errors_svi_put_5day.pickle', 'wb') as f: pickle.dump([daily_hedge_errors, daily_pct_hedge_errors], f) print(daily_pct_hedge_errors.keys()) p1 = hedge_util.get_1st_percentile_dates(daily_pct_hedge_errors) p2 = hedge_util.get_2nd_percentile_dates(daily_pct_hedge_errors) p3 = hedge_util.get_3rd_percentile_dates(daily_pct_hedge_errors) p4 = hedge_util.get_4th_percentile_dates(daily_pct_hedge_errors) container = [p1, p2, p3, p4] samples = ['2015.9-2016.1', '2016.2-2016.7', '2016.8-2017.1', '2017.2-2017.7'] print("=" * 100) print( "SVI Model Average Hedging Percent Error,PUT (SVI VOL SURFACE 5-Day SMOOTHING) : " ) print("=" * 100) print("%20s %20s %20s %30s" % ("sample dates", "contract month", "moneyness", "avg hedging error(%)")) for idx_c, r in enumerate(container): mny_0, mny_1, mny_2, mny_3 = hedge_util.hedging_performance(r, r.keys()) print("-" * 100) for i in range(4): if len(mny_0.get(i)) > 0:
key_date1 = datetime.date(liquidition_date.year(),liquidition_date.month(),liquidition_date.dayOfMonth()) daily_hedge_errors.update({key_date1: hedge_error_Ms}) daily_pct_hedge_errors_ed.update({key_date1: hedge_error_pct_Ms}) except Exception as e: print(e) continue print("=" * 110) print("SVI Model Average Hedging Percent Error, PUT (NO SMOOTHING) : ") print("=" * 110) print("%20s %15s %15s %25s %25s" % ("sample dates", "month", "moneyness", "total delta PnL(%)","eff delta PnL(%)")) samples = ['2015.9-2016.1', '2016.2-2016.7', '2016.8-2017.1', '2017.2-2017.7'] p1_td = hedge_util.get_1st_percentile_dates(daily_pct_hedge_errors_td) p2_td = hedge_util.get_2nd_percentile_dates(daily_pct_hedge_errors_td) p3_td = hedge_util.get_3rd_percentile_dates(daily_pct_hedge_errors_td) p4_td = hedge_util.get_4th_percentile_dates(daily_pct_hedge_errors_td) container_td = [p1_td, p2_td, p3_td, p4_td] p1_ed = hedge_util.get_1st_percentile_dates(daily_pct_hedge_errors_ed) p2_ed = hedge_util.get_2nd_percentile_dates(daily_pct_hedge_errors_ed) p3_ed = hedge_util.get_3rd_percentile_dates(daily_pct_hedge_errors_ed) p4_ed = hedge_util.get_4th_percentile_dates(daily_pct_hedge_errors_ed) container = [p1_ed, p2_ed, p3_ed, p4_ed] results = {} index = ["sample dates", "contract month", "moneyness", "total delta PnL(%)","eff delta PnL(%)"] count = 0 for idx_c, r_ed in enumerate(container): r_td = container_td[idx_c] mny_td = hedge_util.hedging_performance_atm(r_td, r_td.keys()) mny_ed = hedge_util.hedging_performance_atm(r_ed, r_ed.keys()) print("-" * 110)