全部版块 我的主页
论坛 站务区 十一区 新手入门区
2251 1
2018-07-22
求助!很急!有大神会用蒙特卡洛模拟给期权定价的吗?分别根据BSM模型和GARCH模型
有偿!无论是excel, eviews或matlab都可以!求教!
感激不尽!



附件列表

数据.xlsx

大小:745.02 KB

只需: 1 个论坛币  马上下载

S&P 500 options

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2018-7-24 11:51:58
import numpy as np
import numpy.random as npr
import matplotlib.pyplot as plt
S0 = 100
r = 0.05
sigma = 0.25
T = 1.0
I = 50000
M = 50
def gen_sn(M, I, anti_paths=True, mo_match=True):
    '''Function to generate random numbers for simulation
   
    Parameters
    ==========
    M : int
       number of time intervals for discretization
    I : int
       number of paths to be simulated
    anti_paths : Boolean
       use of antithetic variates
    mo_math : Boolean
       use of moment matching
    '''
    if anti_paths is True:
        sn = npr.standard_normal((M+1, int(I/2)))
        sn = np.concatenate((sn, -sn), axis=1)
    else:
        sn = npr.standard_normal((M+1, I))
    if mo_match is True:
        sn = (sn - sn.mean())/sn.std()
    return sn
def gbm_mcs_dyna(K, option='call'):
    '''Valuation of European options in Black-Scholes-Merton by Monte Carlo simulation (of index level paths)
   
    Parameters
    ==========
    K : float
        (positive) strike price of the option
    option : string
    type of the option to be valued('call', 'put')
   
    Returns
    =======
    C0 : float
         estimated present value of European call option
    '''
    dt = T/M
    #simulation of index level paths
    S = np.zeros((M+1, I))
    S[0] = S0
    sn = gen_sn(M, I)
    for t in range(1, M+1):
        S[t] = S[t-1]*np.exp((r-0.5*sigma**2)*dt+sigma*np.sqrt(dt)*sn[t])
    if option == 'call':
        hT = np.maximum(S[-1]-K, 0)
    else:
        hT = np.maximum(K-S[-1], 0)
    C0 = np.exp(-r*T)*1/I*np.sum(hT)
    return C0

gbm_mcs_dyna(K=110, option='call')
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群