Vanilla Option Pricing via C++
来源:互联网 发布:淘宝网美肤宝眼霜 编辑:程序博客网 时间:2024/06/07 07:15
Box-Muller Algorithm, generate Gaussian random numbers
#ifndef BM_GAUSSIAN_HPP_INCLUDED#define BM_GAUSSIAN_HPP_INCLUDED#include <cstdlib>#include <cmath>#include <vector>double uniformRandom(){ return (double)(rand()+1.0)/(double)(RAND_MAX+1.0);}void normalRandom(std::vector<double>& v){ double u1=uniformRandom(); double u2=uniformRandom(); v[0] = cos(8.0*atan(1.0)*u2)*sqrt(-2.0*log(u1)); v[1] = sin(8.0*atan(1.0)*u1)*sqrt(-2.0*log(u2));}#endif // BM_GAUSSIAN_HPP_INCLUDED
main function
#include <iostream>#include <cstdlib>#include <cmath>#include <vector>#include <./BM_Gaussian.hpp>using namespace std;int main(){ // set option contract parameters; double T = 1.0; double K = 100; double S0 = 100; double sigma = 0.1; double r = 0.01; int npaths = 100000; int nsteps = 100/2; double S; vector<double> rnorm(2); double sumpayoff = 0.0; double dt = double(T)/double(nsteps); for (int i=0; i<npaths; i++){ S = S0; for (int j=0; j<nsteps; j++){ normalRandom(rnorm); S *= exp((r-0.5*sigma*sigma)*dt + sigma*sqrt(dt)*rnorm[0]); S *= exp((r-0.5*sigma*sigma)*dt + sigma*sqrt(dt)*rnorm[1]); } sumpayoff += max(S-K, 0.0); } double callprice = double(sumpayoff)/double(npaths); cout << "Call Price: " << callprice << endl; return 0;}
0 0
- Vanilla Option Pricing via C++
- American Option Pricing via Longstaff and Schwartz (2001)
- Monte Carlo Asian Option Pricing OOP Framework
- 期权:Black-Scholes put and call option pricing
- Basket Call Option via C++
- (朴素dp)C.Plane Ticket Pricing
- vanilla kernel
- 《CLR Via C#》
- windows via c/c++
- Windows via c/c++
- CLR via c#------Introduction
- Windows Via C/C++
- Pricing Mechanism
- Pricing Factors
- C/C++ Projcet Option
- 【C#】22. Option类型
- CLR Via C#:Second Edition
- 《windows via C++》之精华
- 网络营销公司,一站式网络营销服务
- 非对称加密算法基本概念
- Java 注解总结
- cocos2dx-3.5 NewAudioEngine
- CUDA存储器模型概述
- Vanilla Option Pricing via C++
- Ubnutu 终端里的颜色配置
- HDU 1387 Team Queue
- 可变参数
- J2SE基础摘要——java简介
- 【取石子】只能从一堆取/同时多堆里取
- 工作日志 5.3
- HTTP返回状态值详解
- nyoj题目169:素数