/* ** Version 01 ** Date : 20/07/2001 ** -------------------------------------------------------------------------- ** Copyright K.Cuthbertson and D. Nitzsche ** "Financial Engineering:Derivatives and Risk Manangement" - J. Wiley 2001 ** ** OPTION SPREADS AND STOCK OPTIONS ** ** Option payoff profiles of Spreads (at expiry and before). ** - Bull Spread with Calls ** - Bear Spread with Calls ** */ new ; cls ; @ ---------------------------- next 2 statements required for GAUSS graphs -------------------- @ library gauss pgraph ; graphset ; /* ofile = "c:\\kcdn\\output.out" ; output file = ^ofile reset ; */ format /m1/rdn 16,8 ; output off ; screen off ; " ------------------------------------------------------------ " ; " " ; " Definitions of Variables Used " ; " ----------------------------- " ; " " ; " " ; " K1 = Strike price of first option " ; " " ; " K2 = Strike price of second option " ; " (The second strike prices has to be " ; " different from the first one) " ; " " ; " T = Time to maturity of option " ; " (Default : 1) " ; " " ; " r = Current interest rates " ; " " ; " sigma = Volatility of the underlying asset " ; " " ; " Graph_Start = Starting value for plotting the graph " ; " (Default : K(low) - 20) " ; " " ; " BULL_BEAR = indicate whether you want to plot a bull or " ; " a bear spread " ; " (Options : 'bull' or 'bear') " ; " " ; " ------------------------------------------------------------ " ; @ ----------------------------------------- START USER DATA INPUT ---------------------------- @ K1 = 120 ; @ Strike price of first option - call @ K2 = 100 ; @ Strike price of second option - call @ T = 1 ; r = 0.1 ; sigma = 0.2 ; BULL_BEAR = "bull" ; @ Choose between "bull" and "bear" @ @ --------------------------------------- END USER DATA INPUT -------------------------------- @ if K1 .== K2 ; errorlog "ERROR : K1 cannot be the same as K2. CHOOSE A DIFFERENT STRIKE PRICE" ; end; endif ; K = K1|K2 ; min_K = minc(K) ; max_K = maxc(K) ; @ ---------------------- Setting S0 for call and put premium calculation ----------------------- @ S0 = K1 + (K2-K1)/2 ; @ Choosen to be between K1 and K2 @ {Prem1C} = bscall(K1,S0,sigma,T,r); {Prem2C} = bscall(K2,S0,sigma,T,r); S_range = 30 ; Graph_Start = min_K - S_range ; @ This parameter sets the starting point of the graph @ @ ------------------------------------- STARTING THE CALCULATION ------------------------------ @ if Graph_Start <= 0 ; Graph_Start = 1 ; endif ; Graph_End = (max_K + S_range) + 1 - Graph_Start ; if K > 25 ; Step = 1 ; ST = seqa(Graph_Start, Step, Graph_End) ; elseif K > 10 ; Step = 0.5 ; ST = seqa(Graph_Start, Step, 2*Graph_End) ; else ; Step = 0.1 ; ST = seqa(Graph_Start, Step, 10*Graph_End) ; endif ; n = rows(ST) ; Zeroline = zeros(n,1) ; @ Creating the Zero Line for graph @ KK1 = zeros(n,1) ; KK1 = K1 ; KK2 = zeros(n,1) ; KK2 = K2 ; ssigma = zeros(n,1) ; ssigma = sigma ; rr = zeros(n,1) ; rr = r ; TT = zeros(n,1) ; TT = T ; PayOff = zeros(n,1) ; PayOff_1 = zeros(n,1) ; PayOff_2 = zeros(n,1) ; /* ------------------------------ Calculating Payoff Profile ------------------------- ----------------------------- for different S -------------------------- */ {PO_T1} = bscall(KK1,ST,ssigma,TT,rr); {PO_T2} = bscall(KK2,ST,ssigma,TT,rr); Opt1_PO = ST - K1 ; Opt2_PO = ST - K2 ; i = 1 ; do until i > n ; if Opt1_PO[i,.] > 0 ; PayOff_1[i,.] = Opt1_PO[i,.] ; else ; PayOff_1[i,.] = 0 ; endif ; if Opt2_PO[i,.] > 0 ; PayOff_2[i,.] = Opt2_PO[i,.] ; else ; PayOff_2[i,.] = 0 ; endif ; i = i+1 ; endo ; if BULL_BEAR $== "bull" ; if K1 > K2 ; @ Note : Option 1 is short @ PayOff_1 = -PayOff_1 + Prem1C ; @ Option 1 short @ PayOff_2 = PayOff_2 - Prem2C ; @ Option 2 long @ PO_T1 = -PO_T1 + Prem1C ; @ Option 1 has to be short @ PO_T2 = PO_T2 - Prem2C ; else ; @ Note : Option 1 is long @ PayOff_1 = PayOff_1 - Prem1C ; @ Option 1 long @ PayOff_2 = -PayOff_2 + Prem2C ; @ Option 2 short @ PO_T1 = PO_T1 - Prem1C ; PO_T2 = -PO_T2 + Prem2C ; @ Option 2 has to be short @ endif ; else ; @ Here we have a BEAR Spread @ if K1 < K2 ; @ Note : Option 1 is short @ PayOff_1 = -PayOff_1 + Prem1C ; @ Option 1 short @ PayOff_2 = PayOff_2 - Prem2C ; @ Option 2 long @ PO_T1 = -PO_T1 + Prem1C ; @ Option 1 has to be short @ PO_T2 = PO_T2 - Prem2C ; else ; @ Note : Option 1 is long @ PayOff_1 = PayOff_1 - Prem1C ; @ Option 1 long @ PayOff_2 = -PayOff_2 + Prem2C ; @ Option 2 short @ PO_T1 = PO_T1 - Prem1C ; PO_T2 = -PO_T2 + Prem2C ; @ Option 2 has to be short @ endif ; endif ; PayOff = PayOff_1 + PayOff_2 ; PO_T = PO_T1 + PO_T2 ; SBE = min_K + (abs(Prem1C - Prem2C)) ; @ ------------------------------ Printing Output and the Graph -------------------------------- @ output on ; screen on ; ?; " ------------------------------------------------------------------------ " ; " " ; " FILE : Chp10 Spread Payoff call.txt " ; " =================================== " ; " " ; " Version 20/07/2001 " ; " " ; " Copyright K.Cuthbertson and D. Nitzsche " ; " 'Financial Engineering:Derivatives and Risk Manangement' - J. Wiley 2001 " ; " " ; " OPTION SPREADS AND STOCK OPTIONS " ; " Ploting the payoff Profile for Bull and Bear Spreads (using calls) " ; " " ; " ------------------------------------------------------------------------ " ; ?; ?; " Parameter Inputs " ; ?; " ================ " ; ?; ?; ftos(K1,"Strike Price of Options 1 : %*.*lf",20,2) ; ?; ?; ftos(K2,"Strike Price of Options 2 : %*.*lf",20,2) ; ?; ?; ftos(T,"Time to expiry : %*.*lf",31,2) ; ?; ftos(r,"Current interest rates : %*.*lf",23,2) ; ?; ftos(sigma,"Volatility of the underlying asset : %*.*lf",11,2) ; ?; ?; if BULL_BEAR $== "bull" ; ?; " The payoff diagram for a BULL SPREAD (using CALLS) " ; ?; " ================================================== " ; ?; ?; "The option with the LOWER strike price has to be held LONG and the other option has to be held short" ; ?; if K2 > K1 ; @@ " Option 1 has to be LONG and Option 2 has to be SHORT " ; else ; @@ " Option 1 has to be SHORT and Option 2 has to be LONG " ; endif ; elseif BULL_BEAR $== "bear" ; ?; " The payoff diagram for a BEAR SPREAD (using CALLS) " ; ?; " ================================================== " ; ?; ?; "The option with the HIGHER strike price has to be held LONG and the other option has to be held short" ; ?; if K1 > K2 ; @@ " Option 1 has to be LONG and Option 2 has to be SHORT " ; else ; @@ " Option 1 has to be SHORT and Option 2 has to be LONG " ; endif ; endif ; ?; ?; ?; ftos(S0,"Stock Price used for BS premium calculations : %*.*lf",9,2) ; ?; ?; ftos(Prem1C,"BS call option premium for asset 1 : %*.*lf",19,2) ; ?; ftos(Prem2C,"BS call option premium for asset 2 : %*.*lf",19,2) ; ?; ?; ftos(SBE,"Break even stock price for this call spread : %*.*lf",10,2) ; ?; title("Payoff profile : Spread with Call Options (Bull or Bear)") ; xy (ST,PayOff~PO_T~Zeroline) ; @ -------------------------------------- END OF PROGRAM --------------------------------------- @ /* ----------------------------------------------------------------------------------- */ /* Procedures: BS Call --- */ /* ----------------------------------------------------------------------------------- */ proc bscall(k,s,sigma,tau,r); local d1,d2,c; d2=(ln(s./(k.*exp(-r.*tau))))./(sigma.*sqrt(tau))-0.5*sigma.*sqrt(tau); d1=d2+sigma.*sqrt(tau); c=s.*cdfn(d1)-k.*exp(-r.*tau).*cdfn(d2); retp(c); endp; end ;