/* ** 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 Butterfly (at expiry and before). ** - long Butterfly ** - short Butterfly ** */ 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) " ; " " ; " K3 = Strike price of third option " ; " (The third strike prices has to be " ; " different from the other two) " ; " " ; " 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 @ K3 = 80 ; @ Strike price of third option @ T = 1 ; r = 0.1 ; sigma = 0.2 ; LONG_SHORT = "short" ; @ Choose between "long" and "short" @ /* --------------------------------- END USER DATA INPUT ------------------------- */ K = K1|K2|K3 ; KS = sortc(K,1) ; print KS ; min_K = minc(K) ; max_K = maxc(K) ; mid_K = KS[2,1] ; @ ----------------------- Setting S0 for call and put premium calculation -------------------- @ S0 = min_K + (max_K-min_K)/2 ; @ Choosen to be between K1 and K2 @ {PremC1} = bscall(min_K,S0,sigma,T,r); @ Sell call @ {PremC2} = bscall(mid_K,S0,sigma,T,r); @ Buy 2 call @ {PremC3} = bscall(max_K,S0,sigma,T,r); @ Sell call @ 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 ; mid_KK = zeros(n,1) ; mid_KK = mid_K ; ssigma = zeros(n,1) ; ssigma = sigma ; rr = zeros(n,1) ; rr = r ; TT = zeros(n,1) ; TT = T ; PayOff = zeros(n,1) ; PayOff_C1 = zeros(n,1) ; PayOff_C2 = zeros(n,1) ; PayOff_C3 = zeros(n,1) ; /* ---------------------------- Calculating Payoff Profile --------------------- */ /* ---------------------------- for different S --------------------- */ {PO_TC1} = bscall(max_KK,ST,ssigma,TT,rr) ; {PO_TC2} = bscall(mid_KK,ST,ssigma,TT,rr) ; {PO_TC3} = bscall(min_KK,ST,ssigma,TT,rr) ; OptC_PO1 = ST - max_K ; OptC_PO2 = ST - mid_K ; OptC_PO3 = ST - min_K ; i = 1 ; do until i > n ; if OptC_PO1[i,.] > 0 ; PayOff_C1[i,.] = OptC_PO1[i,.] ; else ; PayOff_C1[i,.] = 0 ; endif ; if OptC_PO2[i,.] > 0 ; PayOff_C2[i,.] = OptC_PO2[i,.] ; else ; PayOff_C2[i,.] = 0 ; endif ; if OptC_PO3[i,.] > 0 ; PayOff_C3[i,.] = OptC_PO3[i,.] ; else ; PayOff_C3[i,.] = 0 ; endif ; i = i+1 ; endo ; if LONG_SHORT $== "long" ; PayOff_C1 = -PayOff_C1 + PremC1 ; @ Sell call option 1 @ PayOff_C2 = PayOff_C2 - PremC2 ; @ Buy call option 2 @ PayOff_C2 = 2*PayOff_C2 ; PayOff_C3 = -PayOff_C3 + PremC3 ; @ Sell call option 3 @ PO_TC1 = -PO_TC1 + PremC1 ; PO_TC2 = PO_TC2 - PremC2 ; PO_TC2 = 2*PO_TC2 ; PO_TC3 = -PO_TC3 + PremC3 ; else ; @ Note : Short Strangle now - both options are short @ PayOff_C1 = PayOff_C1 - PremC1 ; PayOff_C2 = -PayOff_C2 + PremC2 ; PayOff_C2 = 2*PayOff_C2 ; PayOff_C3 = PayOff_C3 - PremC3 ; PO_TC1 = PO_TC1 - PremC1 ; PO_TC2 = -PO_TC2 + PremC2 ; PO_TC2 = 2*PO_TC2 ; PO_TC3 = PO_TC3 - PremC3 ; endif ; PayOff = PayOff_C1 + PayOff_C2 + PayOff_C3 ; PO_T = PO_TC1 + PO_TC2 + PO_TC3 ; SBE1 = max_K - (PremC1 - 2*PremC2 + PremC3) ; SBE2 = min_K + (PremC1 - 2*PremC2 + PremC3) ; /* ------------------------------ Printing Output and the Graph ----------------------- */ output on ; screen on ; @@ "" ; " ------------------------------------------------------------------------ " ; " " ; " FILE : Chp10 Butterfly 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 Butterfly (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(K3,"Strike Price of Options 3 : %*.*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 LONG_SHORT $== "long" ; @@ " The payoff diagram shows a LONG BUTTERFLY " ; @@ " ========================================= " ; @@ "" ; @@ "To create a long butterfly you have to sell 1 call with the lowest strike price, buy 2 calls " ; @@ "with the middle strike price and sell 1 call with the highest strike price " ; @@ "and a put with a lower strike price. " ; @@ "" ; elseif LONG_SHORT $== "short" ; @@ " The payoff diagram shows a SHORT BUTTERFLY " ; @@ " ========================================== " ; @@ "" ; @@ "To create a short butterfly you have to buy 1 call with the lowest strike price, sell 2 calls " ; @@ "with the middle strike price and buy 1 call with the highest strike price " ; @@ "and a put with a lower strike price " ; @@ "" ; endif ; @@ "" ; @@ "" ; @@ ftos(S0,"Stock Price used for BS premium calculations : %*.*lf",9,2) ; @@ "" ; @@ ftos(PremC1,"BS call option premium (Option 1) : %*.*lf",20,2) ; @@ ftos(PremC2,"BS call option premium (Option 2) : %*.*lf",20,2) ; @@ ftos(PremC3,"BS call option premium (Option 3) : %*.*lf",20,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 : Butterfly ") ; xy (ST,PayOff~PO_T~Zeroline) ; /* ----------------------------------------- END OF PROGRAM ------------------------------- */ /* ---------------------------------------------------------------------------------------- */ /* BS Call and Put Procedures */ /* --------------------------------------------------------------------------------------- */ 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 ;