# Evaluation Settings begDate = ql.Date(14, 7, 2017) maturityDate = ql.Date(27, 12, 2017) calendar = ql.China() daycounter = ql.ActualActual() spot = 2.45 S0 = 2.45 * 100 strike = S0 calibrated_params = daily_params.get(to_dt_date(begDate)) # on calibrate_date cal_vols_c, put_vols_c, maturity_dates_c, spot_c, rf_c = daily_svi_dataset.get( to_dt_date(begDate)) black_var_surface = hedge_util.get_local_volatility_surface( calibrated_params, to_ql_dates(maturity_dates_c), begDate, daycounter, calendar, spot_c, rf_c) rf = rf_c.get(3) # SVI model params params = calibrated_params[3] # Monte Carlo Simulation N = 500 delta_t = 1.0 / 365 dates = [] evalDate = begDate while evalDate <= maturityDate: dates.append( datetime.date(evalDate.year(), evalDate.month(), evalDate.dayOfMonth()))
daycounter = ql.ActualActual() #simulation_no = 1000 #noise = np.random.normal(0,1,(simulation_no,len(dates))) #delta_t = 1.0/365 i = 3 # Down and out Call optiontype = ql.Option.Call barrierType = ql.Barrier.DownIn curve = svi_data.get_curve_treasury_bond(today, daycounter) calibrated_params = daily_params.get(to_dt_date(today)) # on calibrate_date cal_vols, put_vols, maturity_dates, spot, risk_free_rates = daily_svi_dataset.get( to_dt_date(today)) black_var_surface = hedge_util.get_local_volatility_surface( calibrated_params, to_ql_dates(maturity_dates), today, daycounter, calendar, spot, risk_free_rates) maturityDate = to_ql_date(maturity_dates[i]) rf = risk_free_rates.get(i) params = calibrated_params[i] #maturityDate = calendar.advance(today,ql.Period(6,ql.Months)) print(maturityDate) print(rf) #rf = 0.0 #spot = 100 barrier = spot - 0.05 strike = spot ttm = daycounter.yearFraction(today, maturityDate) strike = ((barrier * np.exp(rf * ttm))**2) / strike