/* ** Version 01 ** Date : 20/07/2001 ** -------------------------------------------------------------------------- ** Copyright K.Cuthbertson and D. Nitzsche ** "Financial Engineering:Derivatives and Risk Manangement" - J. Wiley 2001 ** ** INTEREST RATE DERIVATIVES ** ** Calculating caplet payoffs. ** */ new ; cls ; /* ofile = "c:\\kcdn\\output.out" ; output file = ^ofile reset ; */ format /m1/rd 12,6; output on ; screen on ; " ------------------------------------------------------------------------ " ; " " ; " FILE : Chp15 Tab1 Caplet Payoff.txt " ; " =================================== " ; " " ; " Version 20/07/2001 " ; " " ; " Copyright K.Cuthbertson and D. Nitzsche " ; " 'Financial Engineering:Derivatives and Risk Manangement' - J. Wiley 2001 " ; " " ; " INTEREST RATE DERIVATIVES " ; " Calculating caplet payoffs " ; " " ; " ------------------------------------------------------------------------ " ; output off ; screen off ; " ---------------------------------------------------------- " ; " " ; " Definitions of Variables Used " ; " ----------------------------- " ; " " ; " Loan = Loan " ; " P_cap = Premium cap (buy) " ; " K_cap = Strike rate (cap) - decimal " ; " r0 = current interest rate - decimal " ; " Spread = Spread " ; " " ; " Loan_st = Start of loan (days) " ; " Loan_ma = Maturity of laon (days) " ; " Day_y = Day count (per Year) " ; " " ; " Size = ... " ; " Step = ... " ; " ---------------------------------------------------------- " ; /* ------------------------------------- START USER DATA INPUT ----------------------------- */ Loan = 100000000 ; P_cap = 250000 ; K_cap = 0.1 ; r0 = 0.1 ; Spread = 0 ; Loan_st = 30 ; Loan_ma = 90 ; Day_y = 360 ; Size = 19 ; Step = 0.005 ; /* ------------------------------------------ END USER DATA INPUT ---------------------------- */ /* ---------------------------------------- STARTING THE CALCULATION ----------------------- */ P_comp = P_cap*(1+(r0+Spread)*(Loan_st/Day_y)) ; NetCB = Loan - P_comp ; TTPeriod = Loan_st + Loan_ma ; cal1 = zeros(Size,1) ; r = zeros(Size,1) ; Cap_Poff = zeros(Size,1) ; Loan_int = zeros(Size,1) ; Eff_int = zeros(Size,1) ; Cost_y = zeros(Size,1) ; Cost_n = zeros(Size,1) ; @ Setting the Interest rate column @ mid = (Size+1)/2 ; r[mid,1] = r0 ; n = mid+1 ; do until n > Size ; r[n,1] = r[n-1,1] + Step ; n = n+1 ; endo ; n = mid-1 ; do until n <= 0 ; r[n,1] = r[n+1,1] - Step ; n = n-1 ; endo ; n = 1 ; do until n > Size ; cal1[n,1] = r[n,1]-K_cap ; if cal1[n,1] > 0 ; Cap_Poff[n,1] = Loan*(r[n,1]-K_cap)*(Loan_ma/Day_y) ; else ; Cap_Poff[n,1] = 0 ; endif ; Loan_int[n,1] = Loan*(r[n,1]+Spread)*Loan_ma/Day_y ; Eff_int[n,1] = Loan_int[n,1]-Cap_Poff[n,1] ; Cost_y[n,1] = ((((Loan+Eff_int[n,1])/NetCB)^(365/Loan_ma))-1)*100 ; Cost_n[n,1] = ((((Loan+Loan_int[n,1])/Loan)^(365/Loan_ma))-1)*100 ; n = n+1 ; endo ; /* -------------------------------------- PRINTING THE OUTPUT ---------------------------------- */ output on ; screen on ; mask = 1~1~1~1~1~1 ; let fmt[6,3] = "-*.*lf" 6 4 "*.*lf " 16 2 "*.*lf " 16 2 "*.*lf " 16 2 "*.*lf " 14 4 "*.*lf " 16 4 ; cap_tab = r~Cap_Poff~Loan_int~Eff_int~Cost_y~Cost_n ; @@ ""; @@ " TABLE 15.01 : CAPLET PAYOFFS " ; @@ " ============================ " ; @@ ""; @@ ftos(Loan,"Loan : %*.*lf",48,2) ; @@ ftos(NetCB,"Net cash borrowed (when loan starts) : %*.*lf",16,2) ; @@ ftos(P_cap,"Cap Premium : %*.*lf",41,2) ; @@ ftos(P_comp ,"Premium compounded : %*.*lf",34,2) ; @@ ""; @@ ftos(r0,"Current int. rates (LIBOR) : %*.*lf",28,4) ; @@ ftos(Spread,"Spread : %*.*lf",48,4) ; @@ ftos(K_cap,"K (strike rate) : %*.*lf",39,4) ; @@ ""; @@ ftos(Loan_st,"Start of the loan (days) : %*.*lf",25,0) ; @@ ftos(Loan_ma,"Maturity of the loan (days) : %*.*lf",22,0) ; @@ ftos(Day_y,"Days in the year (for cap) : %*.*lf",23,0) ; @@ ftos(TTPeriod,"Total time period (days) : %*.*lf",25,0) ; @@ ""; @@ ""; @@ "--------------------------------------------------------------------------------------------- " ; @@ "LIBOR Cap Payment Int. on Loan Total eff. int. Ann. cost of loan " ; @@ "at t + ... at t + ... with call without call " ; @@ "--------------------------------------------------------------------------------------------- " ; @@ call printfm(cap_tab, mask, fmt) ; @@ "--------------------------------------------------------------------------------------------- " ; @@ ftos(Loan_st ,"Note : LIBOR at t+%*.*lf",2,0) ; @@ ftos(TTPeriod ," Cap Payment at t+%*.*lf",3,0) ; @@ "" ; end ;