技術メモ

役に立てる技術的な何か、時々自分用の覚書。幅広く色々なことに興味があります。

ヨーロピアンオプションの価格計算(ブラックショールズモデル)

ブラックショールズモデルを使ってヨーロピアンオプションを計算するpythonコード

ブラックショールズモデル

※無配当の原資産を前提としている

S:スポット価格
x:行使価格
\sigmaボラティリティ
\tau:満期までの期間
r金利

\displaystyle d_1 = \frac{\mathrm{ln}(S/x) + (r  + \sigma^2/2)\tau}{\sigma \sqrt{\tau}}
\displaystyle d_2 = \frac{\mathrm{ln}(S/x) + (r  - \sigma^2/2)\tau}{\sigma \sqrt{\tau}}
として

コールオプション価格:\displaystyle \mathrm{P}_{call} = S\Phi(d_1) - e^{-r\tau}x\Phi(d_2)
プットオプション価格:\displaystyle \mathrm{P}_{put} = e^{-r\tau}x\Phi(-d_2) - S\Phi(-d_1)

となる。
ただし、\Phi()正規分布の累積分布関数を表す。

コード

import numpy as np
from scipy import stats
def bs_model(S,x,r,sigma,T):
    d1 = (np.log(S/x) + (r + 0.5 * sigma ** 2)*T)/(sigma*pow(T, 1/2))
    d2 = (np.log(S/x) + (r - 0.5 * sigma ** 2)*T)/(sigma*pow(T, 1/2))
    call = S * stats.norm.cdf(d1) - x * np.exp(-r*T) * stats.norm.cdf(d2)
    put  = x * np.exp(-r*T) * stats.norm.cdf(-d2) - S * stats.norm.cdf(-d1)
    return call,put
bs_model(50, 50, 0.1, 0.5, 0.5)
(8.131599054232979, 5.693070279268685)

関連
swdrsker.hatenablog.com