This question requires the lecture notes from Lectures 67 Fo

This question requires the lecture notes from Lectures 6&7. For this question, we are going to value at-the-money European calls and puts with one (1) year until -expiration. Remember, a European call\'s value at expiration is max (0, S-K) and a European put\'s value at expiration is max(0, K-S) where K = strike price and S = spot price. Assume that at T = 0, spot and strike price are $100. Further, assume that the risk-free rate (interest rate) is 0%, that is the present value of $1 is equal to the future value of $1. Finally, assume that the stock in question has a drift of 0% and volatility of 20% and has lognormal returns. We simulate the stock\'s stochastic process as: ds/s = mu dt + sigma dZ After solving using Ito\'s Lemma and with our horizon as 1 year, we generate log returns as r = (mu - 1/2 sigma^2) * 1 + sigma Z = (0.0 - 0.5 * 0.2 * 0.2) + 0.2 * Z = -0.02 + 0.2 * Z where Z is a standard normal variable. We then can estimate our stock price as S_1 = Se^r We want to simulate 100,000 1-year stock returns. Refer to class notes (Lectures 6+7) for how to generate standard normal random variables For each simulated return, calculate the expected stock price, the value of call option and value of a put option Keep a running sum of each of these values so that you can calculate average (expected) values Print out the average stock price, call price and put price at the following iterations: 100, 1000, 10000, 100000. That is, after 100 iterations, calculate the average stock, call and put price and print it out. After 1000 iterations, do the same, etc. Using Excel, R or some other handy tool (not C++), create a chart that shows expected call and put values for these iterations. That is, iteration is the X-axis, value is the Y-axis. Include the chart in your homework write-up. Remember: we are calculating values for at-the-money calls at puts. S = 100, K = 100 and thus the value of the call at T=1 will be max(0, S_1 - 100) and the value of the put will be max(0, 100- S_1) where S_1 is the simulated stock price after 1 year.

Solution

#define _USE_MATH_DEFINES
#include<math.h>
#include <iostream>
#include <cmath>
using namespace std;

#define e 2.71828
// 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
double Z = 0.0793;
double r = -0.02+0.2*Z;
double S1 = S*pow(e,r);
// Then we calculate the call/put values
//double call = call_price(S, K, r, v, T);
double call = max(0.0,S1-K);
//double put = put_price(S, K, r, v, T);
double put = max(0.0,K-S1);

// Finally we output the parameters and prices
std::cout << \"Spot: \" << 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;
}

 This question requires the lecture notes from Lectures 6&7. For this question, we are going to value at-the-money European calls and puts with one (1) year
 This question requires the lecture notes from Lectures 6&7. For this question, we are going to value at-the-money European calls and puts with one (1) year

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site