Next: Approximations Up: Simulation Previous: Simulating the sample path.   Contents   Index

Subsections

# Hedge parameters

```// file simulated_delta_call.cc
// author: Bernt A Oedegaard
// estimation of the partials when doing monte carlo

#include <cmath>     // standard mathematical functions
#include "random.h"   // definition of random number generator
#include <algorithm>   // define the max() function

double option_price_delta_call_european_simulated( double S,
double X,
double r,
double sigma,
double time,
int no_sims)
// estimate the price using two different S values
{
double sigma_sqr = sigma * sigma;
double R = (r - 0.5 * sigma_sqr)*time;
double SD = sigma * sqrt(time);
double sum_payoffs = 0.0;
double sum_payoffs_2 = 0.0;
double q = S*0.01;
for (int n=1; n<=no_sims; n++) {
double Z = random_normal();

double S_T  = S* exp(R + SD * Z);
sum_payoffs += max(0.0, S_T-X);

double S_T_2 = (S+q)* exp(R + SD * Z);
sum_payoffs_2 += max(0.0, S_T_2-X);
};
double c = exp(-r*time) * ( sum_payoffs/no_sims);
double c2 = exp(-r*time) * ( sum_payoffs_2/no_sims);
return (c2-c)/q;
};
```