black_scholes_price_payout_call.cc
来自「Financial Recipes」· CC 代码 · 共 17 行
CC
17 行
#include <cmath> // mathematical library#include "normdist.h" // this defines the normal distribution double option_price_european_call_payout( double S, // spot price double X, // Strike (exercise) price, double r, // interest rate double q, // yield on underlying double sigma, // volatility double time) { // time to maturity double sigma_sqr = pow(sigma,2); double time_sqrt = sqrt(time); double d1 = (log(S/X) + (r-q + 0.5*sigma_sqr)*time)/(sigma*time_sqrt); double d2 = d1-(sigma*time_sqrt); double call_price = S * exp(-q*time)* N(d1) - X * exp(-r*time) * N(d2); return call_price;};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?