/* ** Version 01 ** Date : 20/07/2001 ** -------------------------------------------------------------------------- ** Copyright K.Cuthbertson and D. Nitzsche ** "Financial Engineering:Derivatives and Risk Manangement" - J. Wiley 2001 ** ** To calculate the Black-Scholes call and put prices (Table 8.6) and ** to graph call and put premia against S only. ** */ new ; cls ; format /m1/rd 12,6; output on ; screen on ; /* -------------------------------------------------------------------------------- USER INPUT: USER MAY CHANGE FIGURES IN THE NEXT SECTION Data from Table 8.6 "Financial Engineering" - Cuthbertson/Nitzsche J.Wiley 2001 -------------------------------------------------------------------------------- */ k = 43 ; @ strike price @ s0 = 45 ; @ price underlying asset @ r = 10 ; @ interest rate, contin. comp, percent @ d = 0.0 ; @ 'dividend yield', contin. comp, percent @ sigma = 20 ; @ standard deviation, annual, percent @ tau = 0.5 ; @ time to maturity, years @ @ --------------------------- END OF USER INPUT ---------------------------------- @ sigma = sigma./100 ; r = r./100 ; d = d./100 ; {c0} = bscall(k,s0,sigma,tau,r,d); @ activate procedures for call and put premia @ {p0} = bsput(k,s0,sigma,tau,r,d); pp0 = c0 - s0 + k.*exp(-r.*tau) ; @ using put-call parity @ " ------------------------------------------------------------------- " ; " OUTPUT " ; " ------------------------------------------------------------------- " ; " Value of underlying asset (S) " s0 ; " Strike price (K) " k ; " Time to maturity (tau, years or fraction of year) " tau ; " Volatility of underlying (sigma % ) " sigma ; " Risk free rate (r % p.a. - contin. comp.) " r ; " Dividend yield (d % p.a. - contin. comp.) " d ; " ------------------------------------------------------------------- " ; " Price of call " c0 ; " Price of put " p0 ; " Price of put (put-call parity) " pp0 ; " ------------------------------------------------------------------- " ; @ -------------------------------- Setting up the data for graph ----------------------------- @ s = seqa( s0-10, 1, 20 ); c = zeros(20,1); p = zeros(20,1); c[.,1]=bscall(k,s,sigma,tau,r,d); @ Activate the procedures @ p[.,1]=bsput (k,s,sigma,tau,r,d); @ ------------------- Commands for GAUSS graphs xy(.,.) is the only user input ------------- @ library gauss,pgraph; graphset ; graphset; begwind; window(1,2,0); setwind(1); title("Call premium versus underlying asset"); xlabel("Underlying Asset"); ylabel("Call premium"); xy(s,c); nextwind; title("Put premium versus underlying asset"); xlabel("Underlying Asset"); ylabel("Put premium"); xy(s,p); endwind; @ --------------------------------- END OF MAIN PROGRAM --------------------------------- @ /* -------------------------------------------------------------------------------------- Procedures - Black Scholes (with cont. comp.dividends) see kcdn appendix 9.1 ------------------------------------------------------------------------------------- */ proc bscall(k,s,sigma,tau,r,d); local d1,d2,c; d1 = ( ln( s./k ) + ( r - d + sigma^2./2).*tau )./ ( sigma.*sqrt(tau) ); d2 = d1 - sigma.*sqrt(tau); c=s.*exp(-d.*tau).*cdfn(d1) -k.*exp(-r.*tau).*cdfn(d2); retp(c); endp; proc bsput(k,s,sigma,tau,r,d); local d1,d2,p; d1 = ( ln( s./k ) + ( r - d + sigma^2./2).*tau )./ ( sigma.*sqrt(tau) ); d2 = d1 - sigma.*sqrt(tau); p=k.*exp(-r.*tau).*cdfn(-d2) - s.*exp(-d.*tau).*cdfn(-d1) ; retp(p); endp; @ --------------------------- End of Procedures ---------------------------------------- @ end ;