CallOption.cpp
#include "CallOption.h"
#include "matlib.h"
CallOption::CallOption() :
strike(0.0),
maturity(0.0) {
}
double CallOption::price(
const BlackScholesModel& bsm ) const {
double S = bsm.stockPrice;
double K = strike;
double sigma = bsm.volatility;
double r = bsm.riskFreeRate;
double T = maturity - bsm.date;
double numerator = log( S/K ) + ( r + sigma*sigma*0.5)*T;
double denominator = sigma * sqrt(T );
double d1 = numerator/denominator;
double d2 = d1 - denominator;
return S*normcdf(d1) - exp(-r*T)*K*normcdf(d2);
}