**Dr. Johnson**, Computational Finance, C++ – Coding Black Scholes Formula, here. Let’s illustrate some of the ILP concepts just in the gcc world. Here’s some scalar Black Scholes code. We could pick any valuation model and do the same thing. Black Scholes is reasonably straightforward because it is just closed form expression evaluation.

double callOptionPrice(double S,double t,double X,double r,double sigma,double T)
{
double d1=(log(S/X) + (r+sigma*sigma/2.)*(T-t))/(sigma*sqrt(T-t));
double d2=(log(S/X) + (r-sigma*sigma/2.)*(T-t))/(sigma*sqrt(T-t));
**return** normalDistribution(d1)*S - normalDistribution(d2)*X*exp(-r*(T-t));
}
int main()
{
cout << "Call Option Price = " << callOptionPrice(1,0,1,0.05,0.2,1) << endl;
**return** 0;
}

### Like this:

Like Loading...

*Related*