0

当发生跳转时,我正在尝试优化第二个选项的单位,但我无法在 python(或任何其他代码)中面对这些东西。如您所知,我有这种初始情况:

\Pi[:,0] = C(0,K,s0) - (initial delta of first call + units of gamma * (initial delta of second option))* S[:,0] - gamma units * the second option

但我不知道如何最小化 for 循环中的 gamma 单位。

只有看涨期权和底层证券的投资组合算法是:

C = lambda t,K,S0: BS_Call_Put_Option_Price(CP,S0,K,sigma,t,T,r)

Delta = lambda t,K,S0: BS_Delta(CP,S0,K,sigma,t,T,r)



# Setting up initial portfolio



PnL = np.zeros([NoOfPaths,NoOfSteps+1])

delta_init= Delta(0.0,K,s0)

PnL[:,0] = C(0.0,K,s0) - (delta_init+gamma_unit*delta_initOpt2) * s0 - gamma_unit* COpt2(0.0,K,s0)



CallM      = np.zeros([NoOfPaths,NoOfSteps+1])

CallM[:,0] = C(0.0,K,s0)

DeltaM     = np.zeros([NoOfPaths,NoOfSteps+1])

DeltaM[:,0] = Delta(0,K,s0)



for i in range(1,NoOfSteps+1):

    dt = time[i] - time[i-1]

    delta_old  = Delta(time[i-1],K,S[:,i-1])

    delta_curr = Delta(time[i],K,S[:,i])



    PnL[:,i] =  PnL[:,i-1]*np.exp(r*dt) - (delta_curr-delta_old + delta_currOpt2*gamma_curr-delta_oldOpt2)*S[:,i] - (gamma_curr-gamma_old)*CallMOpt2 # PnL

    CallM[:,i] = C(time[i],K,S[:,i])

    DeltaM[:,i]   =Delta(time[i],K,S[:,i])



# Final transaction, payment of the option (if in the money) and selling the hedge



PnL[:,-1] = PnL[:,-1] -np.maximum(S[:,-1]-K,0) +  (DeltaM[:,-1]+ DeltaMOpt2[:,-1]*GammaM[:,-1])*S[:,-1] + GammaM[:,-1]*np.maximum(S[:,-1]-K,0)

但是,当我想对冲我的头寸以应对跳跃增加的新风险来源时,根据 ch。Rebonato 编写的“波动性和相关性”的第 14 章,我必须包含一个新选项,但我无法最小化 for...loop 中的伽马单位

C = lambda t,K,S0: BS_Call_Put_Option_Price(CP,S0,K,sigma,t,T,r)

Delta = lambda t,K,S0: BS_Delta(CP,S0,K,sigma,t,T,r)



# Setting up initial portfolio



PnL = np.zeros([NoOfPaths,NoOfSteps+1])

delta_init= Delta(0.0,K,s0)

PnL[:,0] = C(0.0,K,s0) - (delta_init+gamma_unit*delta_initOpt2) * s0 - gamma_unit* COpt2(0.0,K,s0)



CallM      = np.zeros([NoOfPaths,NoOfSteps+1])

CallM[:,0] = C(0.0,K,s0)

DeltaM     = np.zeros([NoOfPaths,NoOfSteps+1])

DeltaM[:,0] = Delta(0,K,s0)



for i in range(1,NoOfSteps+1):

    dt = time[i] - time[i-1]

    delta_old  = Delta(time[i-1],K,S[:,i-1])

    delta_curr = Delta(time[i],K,S[:,i])



    PnL[:,i] =  PnL[:,i-1]*np.exp(r*dt) - (delta_curr-delta_old + delta_currOpt2*gamma_curr-delta_oldOpt2)*S[:,i] - (gamma_curr-gamma_old)*CallMOpt2 # PnL

    CallM[:,i] = C(time[i],K,S[:,i])

    DeltaM[:,i]   =Delta(time[i],K,S[:,i])



# Final transaction, payment of the option (if in the money) and selling the hedge



PnL[:,-1] = PnL[:,-1] -np.maximum(S[:,-1]-K,0) +  (DeltaM[:,-1]+ DeltaMOpt2[:,-1]*GammaM[:,-1])*S[:,-1] + GammaM[:,-1]*np.maximum(S[:,-1]-K,0)
4

0 回答 0