Advertisement
Guest User

Untitled

a guest
Jul 8th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.33 KB | None | 0 0
  1. S0=[50;55;35;45;5350];
  2. X0=[1;1;1.49;1.28;1/101];
  3. rUSD=0.004;rUK=0.004;rGermany=0.001;rJPY=0.001; % interest rates
  4. y=0.02*ones(5,1); % dividend yields
  5. T=2;
  6. steps=256;
  7.  
  8. dt=T/steps;
  9. sims=10000;
  10. subSize = 250;
  11. r=zeros(5,1);
  12. r(1)=rUSD-y(1)-v(1)^2/2;
  13. r(2)=rUSD-y(2)-v(2)^2/2;
  14. r(3)=rUK-y(3)-R(3,6)*v(6)*v(3)-v(3)^2/2;
  15. r(4)=rGermany-y(4)-R(4,7)*v(7)*v(4)-v(4)^2/2;
  16. r(5)=rJPY-y(5)-R(5,8)*v(8)*v(5)-v(5)^2/2;
  17.  
  18. time_indices = [16 32 64 128 256];
  19.  
  20. K0 = [50;55;35;45;5350];
  21. cap = 30;
  22. i = 1;
  23.  
  24. corrmat = R;
  25. upperTriangle=chol(corrmat(1:length(S0),1:length(S0)));
  26.  
  27. numBatches = 10;
  28. latinHypercubePrices = zeros(numBatches,1);
  29. for numBatch = 1:numBatches
  30.     Spath=LatinHypercube(upperTriangle,r,S0,v(1:length(S0)),sims,steps,T); % latin
  31.     [~, latinHypercubePrices(numBatch,1), standard_error] = Payoff(Spath, K0, time_indices, cap, X0, rUSD, T);    
  32. end
  33. disp('Latin Hypercube');
  34. disp(mean(latinHypercubePrices));
  35. disp(std(latinHypercubePrices)/sqrt(numBatches));
  36.  
  37. sobolPrices = zeros(numBatches, 1);
  38. sobolsequence=sobolset(size(R,2)-2, 'Skip', 1e3);
  39. for numBatch = 1:numBatches
  40.     SobolPoints=sobolsequence((numBatch-1)*sims+1:numBatch*sims,1:size(R,2)-2);
  41.     Spath = Sobol(upperTriangle,r,S0,v(1:length(S0)),sims,steps,T, SobolPoints);
  42.     [~, sobolPrices(numBatch,1), standard_error] = Payoff(Spath, K0, time_indices, cap, X0, rUSD, T);
  43. end
  44. disp('Sobol');
  45. disp(mean(sobolPrices));
  46. disp(std(sobolPrices)/sqrt(numBatches));
  47.  
  48. momentMatchingPrices = zeros(numBatches, 1);
  49. for numBatch = 1:numBatches
  50.     Spath=MomentMatching(upperTriangle,r,S0,v(1:length(S0)),sims,steps,T, subSize); % Moment matching
  51.     [~, momentMatchingPrices(numBatch, 1), standard_error] = Payoff(Spath, K0, time_indices, cap, X0, rUSD, T);
  52. end
  53. disp('MomentMatching')
  54. disp(mean(momentMatchingPrices));
  55. disp(std(momentMatchingPrices)/sqrt(numBatches));
  56.  
  57. Spath=SamplePath2(upperTriangle,r,S0,v(1:length(S0)),sims,steps,T, subSize); % naive MC
  58. [payoffs_Naive, naivePrice, standard_error] = Payoff(Spath, K0, time_indices, cap, X0, rUSD, T);
  59. disp('Naive');
  60. disp(naivePrice);
  61. disp(standard_error);
  62.  
  63.  
  64. [Spath1,Spath2]=AntitheticVar(upperTriangle,r,S0,div,v(1:length(S0)),sims,steps,T,subSize);
  65. [antitheticPrice, standard_error] = AntitheticPayoff(Spath1,Spath2, K0, time_indices, cap, X0, rUSD, T);
  66. disp('Antithetic');
  67. disp(antitheticPrice);
  68. disp(standard_error);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement