Question: Financial _ European / Asian Call Option

Hi

 

Can anyone please help me Ive been stuck on this program for ages and cant see what I'm doing wrong?

Here is the code:

restart;
randomize();
npaths := 10;
nsteps := 1;
S0 := 100.0;
K := 100;
T := 0.25;
r := 0.05;
sig := 0.15;
lambda := 0.1;
a := -0.9;
nu := 0.45;
m := exp(a + (0.5*nu)*nu);
mu := r - (m - 1.0)*lambda;
dt := T/nsteps;
with(Statistics);
N := RandomVariable(Poisson(lambda*dt));
Z := RandomVariable(Normal(0, 1));
                           1059210787

                            K := 100

                           T := 0.25

                           r := 0.05

                          sig := 0.15

                         

Xsum:=0.0: #`Initialise sum of payoffs over all paths` Asum:= 0.0:   for i from 1 to npaths do    S[0]:=S0 : #` initialise`   lnS:=ln(S[0]):    Stot := 0.0:    for i from 1 to nsteps do  N1:=Sample(N,1)[1]: #` sample number from poisson distribution`  Z1:=Sample(Z,1)[1]: #` sample number from normal distribution`   dlnS:=r*dt+(mu-r)*dt-0.5*sig^(2)*dt+N1*ln(m)-0.5*nu^(2)*N1+sqrt(sig^(2)*dt+nu^(2)*N1) *Z1: #` Joshi 15.12`   lnS:=lnS+dlnS:  #print(cal,N1*ln(m)-0.5*nu^(2)*N1);  S[i]:=exp(lnS):  Stot:= Stot + S[i]:     end do:    #`European Call Option (Parrott)`  X1:=max(0.0,K-S[nsteps]):  Xsum:=Xsum+X1:    #`Asian Call Option`  Save := Stot/(nsteps):  A1 :=max(0.0, K-Save):  Asum := Asum + A1:     if(k mod 10 = 0) then print (k, Euro Call,X1, Asian  Call, A1)end if:   if (k=1) then Sp1:=copy(S) end if:   if (k=2) then Sp2:=copy(S) end if:   if (k=3) then Sp3:=copy(S) end if:     end do:    #`Euro Call`  X0:=exp(-r*T)*(  Xsum)/(npaths);   print("Euro call price at t=0",X0, "actual",3.1490);       #`Asian Call`  A0:=exp(-r*T)*(  Asum)/(npaths);   print("Asian call price at t=0",X0, "actual", A0);   #`Plot of three sample paths: to generate decent looking paths, set npaths=3, and nsteps=1000 above and rerun`    data1:=[seq([ i*dt,Sp1[i]],i=0..nsteps)]:  data2:=[seq([ i*dt,Sp2[i]],i=0..nsteps)]:  data3:=[seq([ i*dt,Sp3[i]],i=0..nsteps)]:  plot([data1,data2,data3]);               ;

 

The errors i get are unterminated loop and parse.

 

Thank you
 

Please Wait...