process = evaluation.get_bsmprocess(daycounter, underlying_ql,
                                    vol_surface_call)
for spot in spot_range:
    underlying_ql.setValue(spot)
    #engine = OptionEngine(process, engineType).engine
    optionql_call.setPricingEngine(
        ql.BinomialVanillaEngine(process, 'crr', 801))
    barrierql.setPricingEngine(ql.BinomialBarrierEngine(process, 'crr', 801))
    delta = optionql_call.delta()
    barrierdelta = barrierql.delta()
    # 全Delta
    delta_total = svi_call.calculate_total_delta(evaluation, option_call,
                                                 engineType, spot,
                                                 spot * 0.0001)
    # Effective Delta
    delta_eff = svi_call.calculate_effective_delta(evaluation, option_call,
                                                   engineType, spot, dS)

    delta1 = round(delta, 4)
    barrierdelta1 = round(barrierdelta, 4)
    delta_t1 = round(delta_total, 4)
    delta_eff1 = round(delta_eff, 4)
    call_barrierdelta.append(barrierdelta)
    call_delta_total.append(delta_total)
    call_delta_cnst.append(delta)
    call_delta_eff.append(delta_eff)
    call_diff.append(delta_total - delta)
    print("%10s %25s %25s %25s %25s %25s" %
          (spot, barrierdelta1, delta1, delta_t1, delta_eff1,
           round(delta_total - delta, 4)))
print('=' * 100)
result['Spot'] = spot_range
Beispiel #2
0
volSurface_call = SviVolSurface(date_ql,paramset_c,daycounter,calendar)
svi_call = SviPricingModel(date_ql,volSurface_call,underlying,daycounter,calendar,util.to_ql_dates(maturity_dates),ql.Option.Call,contractType)

call_delta_total = []
call_delta_cnst = []
call_delta_eff = []
call_diff = []
#index=['data_total','data_const']
result = pd.DataFrame()
for spot in np.arange(2400.0,3200.0,10.0):

    delta = svi_call.get_option(spot,strike,maturitydt,ql.Option.Call).delta()
    # 全Delta
    delta_total = svi_call.calculate_total_delta(spot,strike,maturitydt,ql.Option.Call,spot*0.0001)
    # Effective Delta
    delta_eff = svi_call.calculate_effective_delta(spot,strike,maturitydt,ql.Option.Call, dS)

    delta1 = round(delta, 4)
    delta_t1 = round(delta_total, 4)
    delta_eff1 = round(delta_eff, 4)
    call_delta_total.append(delta_total)
    call_delta_cnst.append(delta)
    call_delta_eff.append(delta_eff)
    call_diff.append(delta_total-delta)
    print("%10s %25s %25s %25s %25s" % (spot,delta_t1,delta_eff1,delta1,round(delta_total-delta,4)))
print('='*100)
result['Spot'] = np.arange(2400.0,3200.0,10.0)
result['TotalDelta_m_call'] = call_delta_total
result['EffectiveDelta_m_call'] = call_delta_eff
result['TotalDelta_k_call'] = call_delta_cnst