%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% r=0.1; s=0.4; S0=1.0; K=1.1; T=60/252; N=120; % for twice a day observation %N=600; % for ten times a day observation M=50000; % number of simulations h = T/N; Z = randn(M,N); S = S0*ones(M,N+1); % make prices for i=1:N S(:,i+1)=S(:,i).*exp( (r-s^2/2)*h + sqrt(h)*s*Z(:,i)); end Smax = max(S,[],2); ret = exp(-r*T)*(Smax-K).*(Smax>K); mean(ret) std(ret)/sqrt(M) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Results of ten runs for the N=120 case:
0.0885 0.0889 0.0898 0.0892 0.0880 0.0880 0.0886 0.0892 0.0884 0.0886
with stochastic error always 0.0006.
Results of ten runs for the N=600 case:
0.0929 0.0934 0.0934 0.0936 0.0923 0.0936 0.0931 0.0932 0.0928 0.0936
with stochastic error always 0.0006.
The important thing to notice is that the answer is consistently higher when we check more often what the max is - as the more times we check the closer we get to finding the real max. This is a deterministic error.
Does the answer make sense? At first glance it might seem that the option value is a little high. The explanation is that the value of s is quite high, causing substantial price movements. In part d we will see that there is indeed sensitivity to the value of s.
Part c: Here is my program
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% r=0.1; s=0.4; S0=1.0; K=1.1; T=60/252; N=600; M=50000; h = T/N; Z = randn(M,N); eps = 1e-5; % we are going to make two matrices of prices Splus = (S0+eps)*ones(M,N+1); Sminus = (S0-eps)*ones(M,N+1); % make prices for i=1:N Splus(:,i+1) = Splus(:,i) .*exp( (r-s^2/2)*h + sqrt(h)*s*Z(:,i)); Sminus(:,i+1) = Sminus(:,i) .*exp( (r-s^2/2)*h + sqrt(h)*s*Z(:,i)); end Splusmax = max(Splus,[],2); Sminusmax = max(Sminus,[],2); retplus = exp(-r*T)*(Splusmax-K).*(Splusmax>K); retminus = exp(-r*T)*(Sminusmax-K).*(Splusmax>K); sens = (retplus-retminus)/(2*eps); mean(sens) std(sens)/sqrt(M) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The important thing here is that we compute the derivative before taking the expected value - allowed since we are using common random variables. (If we were not using common random variables we would run the original program twice, with 2 initial prices, and compare the answers. And the stochastic error would mean the process was meaningless.) Here are some results for different values of eps:
eps | answer | error |
0.1000 | 1.1250 | 0.0010 |
0.0100 | 0.7923 | 0.0026 |
1.0000e-03 | 0.7558 | 0.0027 |
1.0000e-04 | 0.7572 | 0.0027 |
1.0000e-05 | 0.7575 | 0.0027 |
1.0000e-06 | 0.7596 | 0.0027 |
1.0000e-07 | 0.7559 | 0.0027 |
1.0000e-08 | 0.7516 | 0.0027 |
1.0000e-09 | 0.7552 | 0.0027 |
1.0000e-10 | 0.7594 | 0.0027 |
1.0000e-11 | 0.7542 | 0.0027 |
1.0000e-12 | 0.7518 | 0.0027 |
1.0000e-13 | 0.7492 | 0.0027 |
1.0000e-14 | 0.7520 | 0.0027 |
1.0000e-15 | 0.8143 | 0.0036 |
The first two values of eps are too big. In principle we want to take the limit that eps goes to zero. In practice there is no need to do this, as if eps=0.001 or smaller we already have a deterministic error that is smaller than the stochastic error, and we can do no better. If we take eps too small (only the last line in the results above) then there can be substantial numerical errors.
Part d: Here is my program
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% r=0.1; s=0.4; S0=1.0; K=1.1; T=60/252; N=600; M=50000; h = T/N; Z = randn(M,N); eps = 1e-5; % we are going to make two matrices of prices Splus = S0*ones(M,N+1); Sminus = S0*ones(M,N+1); % make prices for i=1:N Splus(:,i+1) = Splus(:,i) .*exp( (r-(s+eps)^2/2)*h + sqrt(h)*(s+eps)*Z(:,i)); Sminus(:,i+1) = Sminus(:,i) .*exp( (r-(s-eps)^2/2)*h + sqrt(h)*(s-eps)*Z(:,i)); end Splusmax = max(Splus,[],2); Sminusmax = max(Sminus,[],2); retplus = exp(-r*T)*(Splusmax-K).*(Splusmax>K); retminus = exp(-r*T)*(Sminusmax-K).*(Splusmax>K); sens = (retplus-retminus)/(2*eps); mean(sens) std(sens)/sqrt(M) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ran to get expected value of derivative 0.3857 with error 0.0020. Quite reasonable, consistent with the finding in parts a and b that the option value is about 0.1 (with sigma = 0.4).
Back to main course page
Back to my main teaching page
Back to my home page