Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

7 Homework 7 (Lecture 12): Black-Scholes-Merton formula for options The symbols

ID: 3718888 • Letter: 7

Question

7 Homework 7 (Lecture 12): Black-Scholes-Merton formula for options The symbols S, K, r, q, ?, t0 and T have theit usual meanings . Define the variables di and d2 as follows to The Black-Scholes Merton formula for the fair value of a European call c and a Europeain put p, and the corresponding Delta ?c and ?p, is . T-to) N(-d- (7.2) N(di) . The cumulative normal function N(x) is given N(x) (7.3) . Fortunately C++ provides a function erf (x) which can be used to compute N(x) (7.4) . You may use the C+ function below to compute the value of N(x) double cum_norm (double x) const double root-sqrt (0.5); return 0.5 (1.0 erf(x*root)); » Write functions to calculate the fair value and Delta of European call and put options using the Black- Scholes-Merton formula.

Explanation / Answer

#define _USE_MATH_DEFINES

#include <iostream>

#include <cmath>

// Standard normal probability density function

double norm_pdf(const double& x) {

return (1.0/(pow(2*M_PI,0.5)))*exp(-0.5*x*x);

}

// An approximation to the cumulative distribution function

// for the standard normal distribution

// Note: This is a recursive function

double norm_cdf(const double& x) {

double k = 1.0/(1.0 + 0.2316419*x);

double k_sum = k*(0.319381530 + k*(-0.356563782 + k*(1.781477937 + k*(-1.821255978 + 1.330274429*k))));

if (x >= 0.0) {

return (1.0 - (1.0/(pow(2*M_PI,0.5)))*exp(-0.5*x*x) * k_sum);

} else {

return 1.0 - norm_cdf(-x);

}

}

// This calculates d_j, for j in {1,2}. This term appears in the closed

// form solution for the European call or put price

double d_j(const int& j, const double& S, const double& K, const double& r, const double& v, const double& T) {

return (log(S/K) + (r + (pow(-1,j-1))*0.5*v*v)*T)/(v*(pow(T,0.5)));

}

// Calculate the European vanilla call price based on

// underlying S, strike K, risk-free rate r, volatility of

// underlying sigma and time to maturity T

double call_price(const double& S, const double& K, const double& r, const double& v, const double& T) {

return S * norm_cdf(d_j(1, S, K, r, v, T))-K*exp(-r*T) * norm_cdf(d_j(2, S, K, r, v, T));

}

// Calculate the European vanilla put price based on

// underlying S, strike K, risk-free rate r, volatility of

// underlying sigma and time to maturity T

double put_price(const double& S, const double& K, const double& r, const double& v, const double& T) {

return -S*norm_cdf(-d_j(1, S, K, r, v, T))+K*exp(-r*T) * norm_cdf(-d_j(2, S, K, r, v, T));

}

int main(int argc, char **argv) {

// First we create the parameter list

double S = 100.0; // Option price

double K = 100.0; // Strike price

double r = 0.05; // Risk-free rate (5%)

double v = 0.2; // Volatility of the underlying (20%)

double T = 1.0; // One year until expiry

// Then we calculate the call/put values

double call = call_price(S, K, r, v, T);

double put = put_price(S, K, r, v, T);

// Finally we output the parameters and prices

std::cout << "Underlying: " << S << std::endl;

std::cout << "Strike: " << K << std::endl;

std::cout << "Risk-Free Rate: " << r << std::endl;

std::cout << "Volatility: " << v << std::endl;

std::cout << "Maturity: " << T << std::endl;

std::cout << "Call Price: " << call << std::endl;

std::cout << "Put Price: " << put << std::endl;

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote