/* ** 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 a Strangle (at expiry and before). ** - long Strangle (buy put and call) ** - short Strangle (sell put and call) ** */ 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) " ; " " ; " LONG_SHORT = indicate whether you want to plot a long or " ; " a short Straddle " ; " (Options : 'long' or 'short') " ; " " ; " ------------------------------------------------------------ " ; /* ---------------------------------- START USER DATA INPUT ----------------------------- */ K1 = 120 ; @ Strike price of first option @ K2 = 100 ; @ Strike price of second option @ T = 1 ; r = 0.1 ; sigma = 0.2 ; LONG_SHORT = "long" ; @ Choose between "long" and "short" @ /* ------------------------------------ END USER DATA INPUT ----------------------------- */ K = K1|K2 ; min_K = minc(K) ; max_K = maxc(K) ; @ ----------------- Setting S0 for call and put premium calculation --------------------- @ S0 = min_K + (max_K-min_K)/2 ; @ Choosen to be between K1 and K2 @ {PremC} = bscall(max_K,S0,sigma,T,r); {PremP} = bsput(min_K,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 @ max_KK = zeros(n,1) ; max_KK = max_K ; min_KK = zeros(n,1) ; min_KK = min_K ; ssigma = zeros(n,1) ; ssigma = sigma ; rr = zeros(n,1) ; rr = r ; TT = zeros(n,1) ; TT = T ; PayOff = zeros(n,1) ; PayOff_C = zeros(n,1) ; PayOff_P = zeros(n,1) ; /* --------------------------------- Calculating Payoff Profile -------------------------- */ /* --------------------------------- for different S -------------------------- */ {PO_TC} = bscall(max_KK,ST,ssigma,TT,rr); {PO_TP} = bsput(min_KK,ST,ssigma,TT,rr); OptC_PO = ST - max_K ; OptP_PO = min_K - ST ; i = 1 ; do until i > n ; if OptC_PO[i,.] > 0 ; PayOff_C[i,.] = OptC_PO[i,.] ; else ; PayOff_C[i,.] = 0 ; endif ; if OptP_PO[i,.] > 0 ; PayOff_P[i,.] = OptP_PO[i,.] ; else ; PayOff_P[i,.] = 0 ; endif ; i = i+1 ; endo ; if LONG_SHORT $== "long" ; PayOff_C = PayOff_C - PremC ; @ Call option long @ PayOff_P = PayOff_P - PremP ; @ Put option long @ PO_TC = PO_TC - PremC ; PO_TP = PO_TP - PremP ; else ; @ Note : Short Strangle now - both option are short @ PayOff_C = -PayOff_C + PremC ; @ Call option short @ PayOff_P = -PayOff_P + PremP ; @ Put option short @ PO_TC = -PO_TC + PremC ; PO_TP = -PO_TP + PremP ; endif ; PayOff = PayOff_C + PayOff_P ; PO_T = PO_TC + PO_TP ; SBE1 = max_K + PremC + PremP ; SBE2 = min_K - PremC - PremP ; /* --------------------------- Printing Output and the Graph --------------------------- */ output on ; screen on ; @@ "" ; " ------------------------------------------------------------------------ " ; " " ; " FILE : Chp10 Strangle Payoff.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 a Strangle (long or short) " ; " " ; " ------------------------------------------------------------------------ " ; @@ "" ; @@ " 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 K1 .== K2 ; errorlog "As K1 = K2 this is a Straddle. CHOOSE ONE DIFFERENT STRIKE PRICE FOR STRANGLE" ; @@ "" ; @@ "" ; @@ "" ; endif ; if LONG_SHORT $== "long" ; @@ " The payoff diagram shows a LONG STRANGLE " ; @@ " ======================================== " ; @@ "" ; @@ "To create a long straddle one has to buy a call with the higher strike price " ; @@ "and a put with a lower strike price. " ; @@ "" ; elseif LONG_SHORT $== "short" ; @@ " The payoff diagram shows a SHORT STRANGLE " ; @@ " ========================================= " ; @@ "" ; @@ "To create a short straddle one has to sell a call with the higher strike price " ; @@ "and a put with a lower strike price " ; @@ "" ; endif ; @@ "" ; @@ "" ; @@ ftos(S0,"Stock Price used for BS premium calculations : %*.*lf",9,2) ; @@ "" ; @@ ftos(PremC,"BS call option premium : %*.*lf",31,2) ; @@ ftos(PremP,"BS put option premium : %*.*lf",32,2) ; @@ "" ; @@ ftos(SBE2,"Lower break even stock price boundary : %*.*lf",16,2) ; @@ ftos(SBE1,"Upper break even stock price boundary : %*.*lf",16,2) ; @@ "" ; title("Payoff profile : Strangle (long or short)") ; xy (ST,PayOff~PO_T~Zeroline) ; /* --------------------------------- END OF PROGRAM ----------------------------------- */ /*------------------------------------------------------------------------------------- */ /* Procedures: BS Call and Put */ /* ------------------------------------------------------------------------------------ */ 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; 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 ;