/* ** 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 Straddle (at expiry and before). ** - long Straddle (long call and long put) ** - short Straddle (short call and short put) ** */ 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 " ; " ----------------------------- " ; " " ; " " ; " K = Strike price of options (put and call) " ; " (For a starddle the strike price of the 2 " ; " options has to be the same). " ; " " ; " 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 ---------------------------- */ K = 100 ; T = 1 ; r = 0.1 ; sigma = 0.2 ; LONG_SHORT = "short" ; @ Choose between "long" and "short" @ /* ---------------------------------- END USER DATA INPUT ----------------------------- */ @ ---------------------- Setting S0 for call and put premium calculation ---------------- @ S0 = K ; @ Choosen to be between S0 to be K - at the money option @ {PremC} = bscall(K,S0,sigma,T,r); {PremP} = bsput(K,S0,sigma,T,r); S_range = 30 ; Graph_Start = 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 = (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 @ KK = zeros(n,1) ; KK = 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(KK,ST,ssigma,TT,rr); {PO_TP} = bsput(KK,ST,ssigma,TT,rr); OptC_PO = ST - K ; OptP_PO = 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 Straddle 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 = K + PremC + PremP ; SBE2 = K - PremC - PremP ; /* ------------------------------ Printing Output and the Graph ------------------------- */ output on ; screen on ; @@ "" ; " ------------------------------------------------------------------------ " ; " " ; " FILE : Chp10 Straddle 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 Straddle (long or short) " ; " " ; " ------------------------------------------------------------------------ " ; @@ "" ; @@ " Parameter Inputs " ; @@ " ================ " ; @@ "" ; @@ ftos(K,"Strike Price of the Options : %*.*lf",18,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 LONG_SHORT $== "long" ; @@ " The payoff diagram shows a LONG STRADDLE " ; @@ " ======================================== " ; @@ "" ; @@ "To create a long straddle one has to buy both a call and a put with the same strike price " ; @@ "" ; elseif LONG_SHORT $== "short" ; @@ " The payoff diagram shows a SHORT STRADDLE " ; @@ " ========================================= " ; @@ "" ; @@ "To create a short straddle one has to sell both a call and a put with the same 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 : Straddle (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 ;