You are on page 1of 1

PD

F -X C h a n ge

PD

F -X C h a n ge

O W !

bu

to

lic

lic

to

bu

N
.c

O W !

.d o

c u -tr a c k

Appendix 1 : Code to Generate Random walk of stock price

.d o

c u -tr a c k

.c

with Statistics : with plots : S0 d 100 : k d 120 : r d 0.05 : td1: vol d 0.1 : steps d 1000 : trials d 5 : S d Vector steps : tt d Vector steps : t : dt d steps for j from 1 to trials do for i from 1 to steps do x d Sample RandomVariable Normal 0, 1 , 1 1 : # random var from std normal dW d evalf sqrt dt $x : # Wiener increment if i = 1 then Sm1 d S0 else Sm1 d S i K1 end if: S i d Sm1$ 1 C r$dt C vol$dW : tt i d i$dt : #print S i ; end do: plot tt, S ; end do; Thank s to Stephen O'Sullivan

w
w

w
w

You might also like