# Pathwise Derivative To Estimate Delta

I am trying to estimate delta using the pathwise derivative method (Broadie and Glasserman (1996)) and I stuck on this part: Here is the other notation defined: Here is my C++ code I have written so far:

void Pathwise_Derivative(double S0, double K, double r, double sigma, double T, int M, int N){
double dt = T/N;
double S[N+1];
for(int i = 0; i < M; i++){
S = S0;
for(int j = 0; j < N; j++){
double Z = gaussian_box_muller();
S[j+1] = S[j]*exp( (r - (sigma*sigma)/(2))*dt + sigma*sqrt(dt)*Z);
}
}

// Estimating Delta
int I[N+1];
I = 0;
for(int i = 1; i <= N; i++){
if(S[i] > K){
I[i] = 1;
}else{
I[i] = 0;
}
}
double delta = 0.0;
for(int i = 1; i <= N; i++){
delta += exp(-r*T)*(S[i]/S0)*I[i];
}

}


I just do not understand the formula for estimating delta and translating it into C++ code, any suggestions are greatly appreciated.

• When you do Monte Carlo on a European option on GBM, there is no need for a time wise sequence of stock prices S[j] j=0 to N. You can find $S_T$ from $S_0$ in a single leap of T time units and using a single normal r.n.. You then compute $e^{-rt}\frac{S_T}{S_0}I_{S_T>K}$ and add it to a SumOfDeltas variable. Outside the MonteCarlo loop you divide SumOfDeltas by M to find the desired Delta (i.e. the average of the estimates you computed). HTH. – Alex C Apr 15 '17 at 23:43
• @AlexC I am not completely following could you provide an answer to this question and expand upon your comment? – Wolfy Apr 16 '17 at 1:05

Caution: this code has not been tested.

totDelta = 0.0
for(int i = 0; i < M; i++){
double Z = gaussian_box_muller();
ST = S0*exp( (r - (sigma*sigma)/(2.0))*T + sigma*sqrt(T)*Z);
if(ST > K){
I = 1;
}else{
I = 0;
}
Delta = exp(-r*T)*(ST/S0)*I;
totDelta += Delta
}

return(totDelta/M); /* Average Delta over M MonteCarlo trials */

• Just needed to modify your code but it worked, I was wondering do you know how to compute the bias of the estimator? – Wolfy Apr 16 '17 at 23:23
• The bias or the uncertainty? For the bias you could compare to the known BS delta. For the uncertainty, you need to track not just the average Delta estimate but also the variance of the estimates, and then the std dev of the average. – Alex C Apr 16 '17 at 23:59
• Well essentially I need to compute the marginal squared error which from what my notes says $$MSE = bias^2 + variance$$ – Wolfy Apr 17 '17 at 1:06
• I'm just not sure how to find the MSE for this method – Wolfy Apr 17 '17 at 16:32
• Use the formula you gave. (1) Bias = your estimate of delta minus the Black-Scholes delta. (2) In the loop update totSum and totSum2, where totSum2 is the sum of squared deltas. After the loop use totSum and totSum2 to compute the variance of your observations. Finally find the variance of your mean estimate by dividing the variance of the observations by M, the number of observations (since they are statistically independent). – Alex C Apr 17 '17 at 18:47