Exemplo n.º 1
0
barrier = 2.6
strike = 2.8
# optionType = ql.Option.Call
# barrierType = ql.Barrier.UpOut
optionType = ql.Option.Put
barrierType = ql.Barrier.DownOut
contractType = '50etf'
engineType = 'BinomialBarrierEngine'
barrier_type = 'downout'
# barrier_type = 'upin'

evaluation = Evaluation(evalDate, daycounter, calendar)
spot, black_var_surface, const_vol = get_vol_data(evalDate, daycounter,
                                                  calendar,
                                                  contractType)  # 收盘价
optionBarrierEuropean = OptionBarrierEuropean(strike, maturitydt, optionType,
                                              barrier, barrierType)
barrier_option = optionBarrierEuropean.option_ql
option_call = OptionPlainEuropean(strike, maturitydt, ql.Option.Call)
plain_option = option_call.option_ql
underlying = ql.SimpleQuote(S0)
spot_range = np.arange(
    min(strike, barrier) - 0.1,
    max(strike, barrier) + 0.05, 0.0005)

# barrier_prices = []
# plain_prices = []
# barrier_deltas = []
# plain_deltas = []
# barrier_gammas = []
# plain_gammas = []
#
Exemplo n.º 2
0
#spot_range = np.arange(2,3.5,0.05)
spot_range = np.arange(2.0, 2.5, 0.0025)
contractType = '50etf'
engineType = 'AnalyticEuropeanEngine'

print('strike = ', strike, ', option type : call')
print('=' * 100)
print("%10s %25s %25s %25s %25s %25s" %
      ("Spot", "barrier_delta", "european_delta", "delta_total", "delta_eff",
       "diff"))
print('-' * 100)
barrier = 2.1
#barrier = 2.6
option_call = OptionPlainEuropean(strike, maturitydt, ql.Option.Call)
optionql_call = option_call.option_ql
barrier_option = OptionBarrierEuropean(strike, maturitydt, ql.Option.Call,
                                       barrier, ql.Barrier.DownOut)
barrierql = barrier_option.option_ql
volSurface_call = SviVolSurface(date_ql, paramset_c, daycounter, calendar)
svi_call = SviPricingModel(volSurface_call, underlying, daycounter, calendar,
                           util.to_ql_dates(maturity_dates), ql.Option.Call,
                           contractType)
vol_surface_call = svi_call.black_var_surface()

call_delta_total = []
call_delta_cnst = []
call_delta_eff = []
call_diff = []
call_barrierdelta = []
#index=['data_total','data_const']
result = pd.DataFrame()
underlying_ql = ql.SimpleQuote(0.0)