#include #include #include #include #include #define pi 3.141592653 class option { public: //**FUNCTIONS**// void DisplayInfo(); void defineOption(ifstream myFile); void BlackScholes(); float nd(float d1); void sdeviation(ifstream myFile); //**IMPORTANT VARIABLES**// char name[5]; //ticker symbol float stock; //stock price float strike; //strike price float expiration; //years until expiration float rate; //interest rate float volat; //volatility //**AUXILLARY VARIABLES**// float mean; //mean of stock data float sd; //sd of stock data float BSprice; //black-scholes option price }; void option::DisplayInfo() { cout<<"Stock Name: "<> name >> stock >> strike >> expiration >> rate >> volat; } void option::BlackScholes() { float d1 = (log(stock / strike) + (rate + pow(volat,2) / 2) * expiration)/(volat*sqrt(expiration)); float d2 = d1 - volat * sqrt(expiration); cout<> price_array[x]; sum_of_array += price_array[x]; } mean = sum_of_array / 30.0; for (x=0; x<30; x++) { float difference = mean - price_array[x]; if (difference < 0) //absolute value difference = difference * -1.0; sum_of_residuals += difference * difference; //add residual^2 } sd = sqrt(sum_of_residuals / 30.0); volat = sd/stock; //volatility = standard deviation/stock price } int main() { option a; //cout << "Input values:"; //cin >> a.stock >> a.strike >> a.expiration >> a.rate >> a.volat; a.stock = 50.0; a.strike = 60.0; a.expiration = .1; a.rate = .04; a.volat = .44; a.BlackScholes(); //calculates the Black-Scholes option value cout << a.BSprice << endl; return 0; }