Calibration Heston Model via Python

本文介绍了使用Python进行Heston模型的半封闭形式定价公式,通过优化方法确定模型参数。
摘要由CSDN通过智能技术生成

Semi-Closed-Form of Pricing Formula

import numpy as np

import scipy.integrate as spi

def Heston_Call_Value_Int(kappa, theta, sigma, rho, v0, r, T, s0, K):
    a = s0*Heston_P_Value(kappa, theta, sigma, rho, v0, r, T, s0, K, 1)
    b = K*np.exp(-r*T)*Heston_P_Value(kappa, theta, sigma, rho, v0, r, T, s0, K, 2)
    #print (a,b)    
    return a-b
    
def Heston_P_Value(kappa, theta, sigma, rho, v0, r, T, s0, K, type):
    ifun = lambda phi: Int_Function_1(phi, kappa, theta, sigma, rho, v0, r, T, s0, K, type)
    return 0.5 + (1/np.pi)*spi.quad(ifun, 0, 100)[0]
    
def Int_Function_1(phi, kappa, theta, sigma, rho, v0, r, T, s0, K, type):
    temp = (np.exp(-1*1j*phi*np.log(K))*Int_Function_2(phi, kappa, theta, sigma, rho, v0, r, T, s0, K, type))    
    return temp
    
def Int_Function_2(phi, kappa, theta, sigma, rho, v0, r, T, s0, K, type):
    if type==1:
        u = 0.5
        b = kappa
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值