black_scholes_put.cc

来自「Financial Recipes」· CC 代码 · 共 16 行

CC
16 行
字号
#include <cmath>              // mathematical library#include "normdist.h"          // this defines the normal distributionusing namespace std; double option_price_put_black_scholes( double S,      // spot price				       double X,      // Strike (exercise) price,				       double r,      // interest rate				       double sigma,  // volatility				       double time) {      double time_sqrt = sqrt(time);    double d1 = (log(S/X)+r*time)/(sigma*time_sqrt) + 0.5*sigma*time_sqrt;    double d2 = d1-(sigma*time_sqrt);    double p =  X * exp(-r*time) * N(-d2) - S * N(-d1);     return p;};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?