/* ** Version 01 ** Date : 20/07/2001 ** -------------------------------------------------------------------------- ** Copyright K.Cuthbertson and D. Nitzsche ** "Financial Engineering:Derivatives and Risk Manangement" - J. Wiley 2001 ** ** VaR OF A CALL(OR PUT) OPTION: MONTE CARLO SIMULATION ** ** VaR of CALL or PUT (one asset case): RNV WITH ANTITHETICS ** see Table 24.3 - although random numbers here do not match those in T24.3 ** */ new ; cls ; format /m1/rd 12,4; output on ; screen on ; /* output file = c:\docs\arun\out.out reset ; */ @ user to check filepath @ /* " ---------------------------------------------------------------------- "; " A MONTE CARLO SIMULATION FOR VaR of a European option "; " using antithetic variables based on Table 24.3 "; " ---------------------------------------------------------------------- "; " tau = time TO maturity of option (years) "; " dt = time step used in MCS "; " r = interest rate "; " k = strike price "; " sigma = standard deviation:underlying(annual, fraction) "; " s = underlying spot market asset (eg. stock price ) "; " days = DAYS for VaR horizon "; " Tee = days/365 (years for VaR horizon) "; " mu = growth rate of stock (p.a., fraction) "; " runs2 = number of runs in the MCS "; " ----------------------------------------------------------------------- "; ?; " Must use 'mu' for calculation of S (and not r) in Brownian motion for stock "; " Do-loop could be done in 'one pass' but is not for pedagagic reasons "; " ---------------------------------------------------------------------- "; */ @ -------------------------------------------------- USER INPUT---------------------------------------------- @ @ --- Note: if you increase 'DAYS' then the distributions for call and put are more skewed,try days =200 --- @ days = 10 ; @ VaR horizon in DAYS @ nob = 10 ; @ fix the number of points to final stock price, in do-loop for MCS @ s = zeros(nob,1) ; @ underlying asset - in do loop for MCS @ s[1,1] = 100 ; @ current value for underlying @ tau = 1.0 ; @ time to maturity of the option(years), must exceed Tee @ r = 0.05 ; k = 100 ; mu = 0.10 ; @ annual growth rate of stock price, propn. @ sigma = 0.40 ; @ ------------------------------------ END USER INPUT ------------------------------------------- @ Tee = days/365 ; @ VaR horizon in years @ dt = Tee/nob ; @ size of time steps to achieve Tee @ taunew = tau - Tee ; @ life of option after 'days' have elapsed @ /*nob = trunc(Tee/dt) ; */ @ truncates to whole number, if needed @ runs = 10000 ; @ this should be > 10,000 @ runs2 = runs*2 ; dcall_T = zeros(runs2,1) ; @ storeage for chnge in values at VaR horizon @ dput_T = zeros(runs2,1) ; dstock_T = zeros(runs2,1) ; @ --------------------------------- Include a little 'failsafe' for user ------------------------ @ if Tee > tau ; errorlog "ERROR : Tau for time to expiry of option must exceed Tee for VaR horizon " ; end; endif ; /* ---------------------------------------------------------------------------------------------- Start of the big loop in the MCS Note stock grows at "mu" p.a. We do not use the root-T rule below --------------------------------------------------------------------------------------------- */ rndseed 123456567; @ fixes sequence of random numbers:reproduces same results each time you run GAUSS @ i=1; @ count for MC runs @ m=0; @ count for storing payoffs at VaR hrzn, m(max) =2 x runs @ do while i<=runs; e = rndn(nob,1); @ generate nx1 series of N(0,1) errors @ j=1; do while j<=2; @ allows a 'switch' between using +e and -e in antithetics @ if j <= 1; @ generate s using exact lognormal with,mu and antithetics @ t=1; do while t < nob; t = t+1; s[t,1] = s[t-1,1]* ( exp( ( mu - sigma^2/2)*dt + sigma*sqrt(dt)*e[ t ] ) ) ; @ note: '+sigma' @ endo; else; t=1; do while t