⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simulated_call_euro.cc

📁 Financial Recipes
💻 CC
字号:
#include <cmath>     // standard mathematical functions#include <algorithm>     // define the max() functionusing namespace std;#include "normdist.h"   // definition of random number generatordoubleoption_price_call_european_simulated( const double& S, // price of underlying				      const double& X, // exercise price				      const double& r, // risk free interest rate				      const double& sigma,  // volatility of underlying				      const double& time, // time to maturity (in years)				      const int& no_sims){ // number of simulations    double R = (r - 0.5 * pow(sigma,2))*time;    double SD = sigma * sqrt(time);    double sum_payoffs = 0.0;    for (int n=1; n<=no_sims; n++) {	double S_T = S* exp(R + SD * random_normal());	sum_payoffs += max(0.0, S_T-X);    };    return exp(-r*time) * (sum_payoffs/double(no_sims));};

⌨️ 快捷键说明

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