Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. paths = 30000000; %paths
  2. [ NumWorkers, NumBlocks, NumIter] = ChoiceParam( paths )%Choice of the number of workers
  3. delete(gcp('nocreate')) %Delete the current parallel pool
  4. parpool(NumWorkers) %Start a parallel pool to define the number of workers
  5.  
  6. %Start a stopwatch to measure performance
  7. tic
  8. averPayoff = 0; %average call payoffs
  9. averPayoff_int = 0; %temporary average call payoffs
  10. parfor i = 1:NumBlocks;
  11. S_1 = 863.00 * ones(1,NumIter); %underlying spot price
  12. sigma1 = 0.20 * ones(1,NumIter); %volatility of 20.00%
  13. r1 = 0.0118 * ones(1,NumIter); %risk free rate of 1.18%
  14. T1 = 100/365.0 * ones(1,NumIter);%maturity in 100 days
  15. K1 = 860.00 * ones(1,NumIter); %strike
  16. zero1 = zeros(1,NumIter);
  17. % generate asset price
  18. M=S_1.*exp((r1 -0.5 * sigma1.^2) .* T1 + sigma1 .* sqrt(T1) .* normrnd(0.0,1.0,1,NumIter));
  19. % call payoffs
  20. payoff_i = max(M - K1, zero1);
  21. averPayoff_int = averPayoff_int + sum(payoff_i)/NumIter;
  22. end
  23. averPayoff = averPayoff_int / NumBlocks; %average call payoffs
  24. toc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement