BSM期权定价

1. BSM期权定价公式

BSM期权定价_第1张图片

2. 代码实现

import pandas as pd
import numpy as np
from math import sqrt,log
from scipy import stats
def BSM(S0,K,T,r,sigma):
    '''
    S0: 股票价格;
    K: 执行价格;
    T: 期权期限;
    r: 无风险利率
    sigma: 波动率
    '''
    S0 = float(S0)
    d1 = (np.log(S0/K)+(r+sigma**2/2)*T)/(sigma*np.sqrt(T))
    d2 = d1 - sigma*np.sqrt(T)
    C = S0*stats.norm.cdf(d1)-K*np.exp(-r*T)*stats.norm.cdf(d2)
    P = K*np.exp(-r*T)*stats.norm.cdf(-d2)-S0*stats.norm.cdf(-d1)
    return C,P
bsm_price = BSM(50,52,2,0.05,0.3)
bsm_price = list(bsm_price)
print('BSM欧式看涨和看跌期权定价:',np.round(bsm_price,2))

 

 

你可能感兴趣的:(python)