/* ** 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 Puts ** - Bear Spread with Puts ** */ 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 the options " ; " (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 - put @ K2 = 100 ; @ Strike price of second option - put @ T = 1 ; r = 0.1 ; sigma = 0.2 ; BULL_BEAR = "bear" ; @ 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 put premium calculation @ S0 = K1 + (K2-K1)/2 ; @ Choosen to be midpoint between K1 and K2 @ {Prem1P} = bsput(K1,S0,sigma,T,r); {Prem2P} = bsput(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} = bsput(KK1,ST,ssigma,TT,rr); @ BS Payoff profile for different ST @ {PO_T2} = bsput(KK2,ST,ssigma,TT,rr); Opt1_PO = K1 - ST ; @ long put payoff @ Opt2_PO = K2 - ST ; 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 K2 > K1 ; @ Note : Option 2 is short @ PayOff_1 = PayOff_1 - Prem1P ; @ Option 1 long @ PayOff_2 = -PayOff_2 + Prem2P ; @ Option 2 short @ PO_T1 = PO_T1 - Prem1P ; PO_T2 = -PO_T2 + Prem2P ; @ Option 2 has to be short @ else ; @ Note : Option 2 is long @ PayOff_1 = -PayOff_1 + Prem1P ; @ Option 1 short @ PayOff_2 = PayOff_2 - Prem2P ; @ Option 2 long @ PO_T1 = -PO_T1 + Prem1P ; @ Option 1 has to be short @ PO_T2 = PO_T2 - Prem2P ; endif ; else ; @ Here we have a BEAR Spread @ if K2 < K1 ; @ Note : Option 2 is short @ PayOff_1 = PayOff_1 - Prem1P ; @ Option 1 long @ PayOff_2 = -PayOff_2 + Prem2P ; @ Option 2 short @ PO_T1 = PO_T1 - Prem1P ; PO_T2 = -PO_T2 + Prem2P ; @ Option 2 has to be short @ else ; @ Note : Option 2 is long @ PayOff_1 = -PayOff_1 + Prem1P ; @ Option 1 short @ PayOff_2 = PayOff_2 - Prem2P ; @ Option 2 long @ PO_T1 = -PO_T1 + Prem1P ; @ Option 1 has to be short @ PO_T2 = PO_T2 - Prem2P ; endif ; endif ; PayOff = PayOff_1 + PayOff_2 ; PO_T = PO_T1 + PO_T2 ; SBE = min_K + ( abs(Prem1P - Prem2P) ) ; /* -------------------------- Printing Output and the Graph --------------------- */ output on ; screen on ; @@ "" ; " ------------------------------------------------------------------------ " ; " " ; " FILE : Chp10 Spread Payoff put.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 puts) " ; " " ; " ------------------------------------------------------------------------ " ; @@ "" ; @@ " 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 PUTS) " ; @@ " ================================================= " ; @@ "" ; @@ "The option with the LOWER strike price has to be held LONG and the other option has to be held short" ; @@ "" ; if K1 > K2 ; @@ " Option 1 has to be SHORT and Option 2 has to be LONG " ; else ; @@ " Option 1 has to be LONG and Option 2 has to be SHORT " ; endif ; elseif BULL_BEAR $== "bear" ; @@ " The payoff diagram for a BEAR SPREAD (using PUTS) " ; @@ " ================================================= " ; @@ "" ; @@ "The option with the HIGHER strike price has to be held LONG and the other option has to be held short" ; @@ "" ; if K2 > K1 ; @@ " Option 1 has to be SHORT and Option 2 has to be LONG " ; else ; @@ " Option 1 has to be LONG and Option 2 has to be SHORT " ; endif ; endif ; @@ "" ; @@ "" ; @@ ftos(S0,"Stock Price used for BS premium calculations : %*.*lf",8,2) ; @@ "" ; @@ ftos(Prem1P,"BS put option premium for asset 1 : %*.*lf",19,2) ; @@ ftos(Prem2P,"BS put option premium for asset 2 : %*.*lf",19,2) ; @@ "" ; @@ ftos(SBE,"Break even stock price for this put spread : %*.*lf",10,2) ; @@ "" ; title("Payoff profile : Spread with Put Options (Bull or Bear)") ; xy (ST,PayOff~PO_T~Zeroline) ; /* ------------------------------------ END OF PROGRAM ---------------------------- */ /* -------------------------------------------------------------------------------- */ /* Procedures: BS Put */ /* -------------------------------------------------------------------------------- */ proc bsput(k,s,sigma,tau,r); local d1,d2,p; d2=(ln(s./(k.*exp(-r.*tau))))./(sigma.*sqrt(tau))-0.5*sigma.*sqrt(tau); d1=d2+sigma.*sqrt(tau); p=-s.*cdfn(-d1)+k.*exp(-r.*tau).*cdfn(-d2); retp(p); endp; end ;