I would like to implement the following: Please see the code below.
I have R1 returns simulated N=5000 times, my option database consists of 10964 quotations, these quotations are divided into 60 sets of different maturities e.g. I have, T3= 21 days, T3=49 days, T3= 77 day, etc....Below I have used the sstats instruction to, for example, pick a random draw of 21 values among 500,000 randoms numbers and then adding 21 values, this methodology need to be implemented for all the 60 different maturities. By estimating the time it will take for the whole database based on what it took me for T3= 21 days:
5573 hours for 10,000 simulations
928 hours for 1000 simulations
My question is the following: Is there a way to manipulate these sub-matrices to shorten the time?
Many thanks
Rachid
Code: Select all
DATA(FORMAT=xls,ORG=COL) 1 138 S T1 div r2 T2 K
com M = 61, P=10964, N=5000
com Callsum = %zeros(M,P)
dec rec T3 ST Call Rtstr Callav
dim T3(M,P) Rtstr(M,P) ST(M,P) Call(M,P) Callav(M,P)
dec vect[series] R1(N)
do rep = 1,N
.....
set R1(rep) = risk-neutral returns
sample(smpl=%valid(R1(rep))) R1(rep) / goodsource 1
compute goodnobs = %nobs
boot entries 1 21 1 goodnobs
sstats 1 21 goodsource(entries(t))>>sumof21
ewise T3(i,j) = T2(j)-T1(i)
ewise Rtstr(i,j) = S(i)*exp((r2(i)-div(i))*T3(i,j)/365+sumof21)
ewise ST(i,j) = %if(T3(i,j)>0,Rtstr(i,j),%na)
ewise Call(i,j) = %if(T3(i,j)>0,exp(-r2(i)*T3(i,j)/365)*%max(0,ST(i,j)-K(j)),%na)
com Callsum = Callsum+Call
end do rep
com Callav = Callsum/N