/* ** 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 payoffs from interst rate floors. ** */ new ; cls ; /* ofile = "c:\\kcdn\\output.out" ; output file = ^ofile reset ; */ format /m1/rdn 16,8 ; output on ; screen on ; " ------------------------------------------------------------------------ " ; " " ; " FILE : Chp15 Tab4 Int rate floor.txt " ; " ==================================== " ; " " ; " Version 20/07/2001 " ; " " ; " Copyright K.Cuthbertson and D. Nitzsche " ; " 'Financial Engineering:Derivatives and Risk Manangement' - J. Wiley 2001 " ; " " ; " INTEREST RATE DERIVATIVES " ; " Calculating payoffs from interest rate floor " ; " " ; " ------------------------------------------------------------------------ " ; output off ; screen off ; " ---------------------------------------------------------- " ; " " ; " Definitions of Variables Used " ; " ----------------------------- " ; " " ; " Dep = Deposit " ; " P_floor = Premium floor " ; " K_floor = Strike rate (floor) " ; " " ; " Dep_ma = Maturity of deposit (days) " ; " Day_y = Day count (per Year) " ; " Reset_d = Reset dates (days) " ; " " ; " ---------------------------------------------------------- " ; /* ------------------------------------ START USER DATA INPUT ---------------------------------- */ /* The number of dates the user has to input has to be equal to (Dep_ma / Reset_d) + 1 ** and the number of interest rates has to match the LIBOR rates at those dates ** see Cuthbertson and Nitzsche 'Financial Engineering : Derivatives and Risk ** Management' Chp. 15 */ Dep = 20000000 ; P_floor = 40000 ; K_floor = 0.1 ; Dep_ma = 360 ; Day_y = 360 ; Reset_d = 90 ; Size = Round(Dep_ma/Reset_d) + 1 ; @ Size represents the number of Dates @ @ Size has to match the number of dates below @ @ Number of LIBOR dates are Size - 1 @ days = zeros(Size,1) ; cum_days = zeros(Size,1) ; r = zeros(Size,1) ; declare matrix DD ; let DD[1,3] = 2000 1 10 ; @ Date @ let DDN[1,3] = 2000 4 10 ; DD = DD|DDN ; let DDN[1,3] = 2000 7 10 ; DD = DD|DDN ; let DDN[1,3] = 2000 10 10 ; DD = DD|DDN ; let DDN[1,3] = 2001 1 10 ; DD = DD|DDN ; r[1] = 0.099 ; @ Interest rates - r1 @ r[2] = 0.095 ; r[3] = 0.090 ; r[4] = 0.080 ; /* --------------------------------------- END USER DATA INPUT -------------------------------- */ RDD = rows(DD) ; screen on ; if RDD < Size ; errorlog "ERROR : CHECK THE NUMBER OF PAYMENTS AND THE NUMBER OF DATE ENTRIES DO NOT MATCH" ; end; elseif RDD > Size ; errorlog "ERROR : CHECK THE NUMBER OF PAYMENTS AND THE NUMBER OF DATE ENTRIES DO NOT MATCH" ; end ; endif ; screen off ; /* --------------------------------------- STARTING THE CALCULATION ---------------------------- */ Inter = zeros(Size,1) ; Floor_pay = zeros(Size,1) ; Principal = zeros(Size,1) ; NCF_y = zeros(Size,1) ; NCF_n = zeros(Size,1) ; n = 1 ; Floor_pay[n,1] = -P_floor ; do until n > Size-1 ; days[n+1,.] = etdays(DD[n,.]',DD[n+1,.]') ; cum_days[n+1,.] = days[n+1,.]+cum_days[n,.] ; Inter[n+1,1] = Dep*r[n]*(days[n+1,1]/Day_y) ; n = n+1 ; endo ; n = 2 ; do until n > Size-1 ; Floor_pay[n+1,.] = Dep*(days[n+1,.]/day_y)*(K_floor-r[n,1]) ; n = n+1 ; endo ; @ ------------------------- Principal payment is only made at maturity ------------------------ @ n = Size ; Principal[n,1] = Dep ; @ ------------------------------ Adding up the relevant Columns -------------------------------- @ NCF_y = Principal + Floor_pay + Inter ; NCF_n = Inter + Principal ; @ ---------------------- Changing the first Net Cash Flow - to allow for payment --------------- @ n = 1 ; NCF_y[n,1] = -Dep+Floor_pay[n,1] ; NCF_n[n,1] = -Dep ; @ ----------------------- Calculating the Effective Rate of return - IRR ----------------------- @ TT = seqa(1,1,Size-1) ; CF = NCF_y ; {IRR,f1,lagr,retcode} = sqpSolve(&fct,0.1) ; irr_yq = IRR ; irr_ya = (1 + irr_yq)^(Day_y/Reset_d) -1 ; CF = NCF_n ; {IRR,f1,lagr,retcode} = sqpSolve(&fct,0.1) ; irr_nq = IRR ; irr_na = (1 + irr_nq)^(Day_y/Reset_d) -1 ; @ ------------------------------------------- Procedure -------------------------------------- @ proc fct(r) ; local Disc, PV, NPV, NPV_min ; Disc = 1/(1+r)^TT[1:Size-1,.] ; PV = CF[2:Size,.].*Disc ; NPV = CF[1,1] + sumc(PV) ; NPV_min = NPV*NPV ; retp(NPV_min) ; endp ; /* ---------------------------------------- PRINTING THE OUTPUT ------------------------------- */ output on ; screen on ; mask = 1~1~1~1~1~1~1~1~1~1 ; let fmt[10,3] = "-*.*lf" 3 0 " *.*lf" 3 0 " *.*lf" 6 0 " *.*lf" 9 0 " *.*lf" 15 4 " *.*lf" 13 2 " *.*lf" 15 2 " *.*lf" 14 2 " *.*lf" 18 2 " *.*lf" 18 2 ; floor_tab = DD[.,3]~DD[.,2]~DD[.,1]~days~r~Inter~Floor_pay~Principal~NCF_y~NCF_n ; /* ** ** Producing a Nicer Table (by cutting off the rows of zeros ** (Matrix floor_tab (with 0) or floor_tab1 (without 0)) ** */ r_rows = counts(DD[.,3],0) ; r_rows = Size - r_rows ; v1 = zeros(r_rows,1) ; n = 1 ; do until n > r_rows ; v1[n,1] = n ; n = n+1 ; endo ; floor_tab1 = submat(floor_tab,v1,0) ; @@ ""; @@ " TABLE 15.04 : INTEREST RATE FLOOR " ; @@ " ================================= " ; @@ ""; @@ ftos(Dep,"Deposit (lending) : %*.*lf",24,2) ; @@ ftos(P_floor,"Floor Premium : %*.*lf",28,2) ; @@ ftos(K_floor,"Strike rate : %*.*lf",30,2) ; @@ ""; @@ ftos(Dep_ma,"Maturity of the deposit (days) : %*.*lf",8,0) ; @@ ftos(Day_y,"Days in the year (for cap) : %*.*lf",12,0) ; @@ ftos(Reset_d,"Reset dates (days) : %*.*lf",20,0) ; @@ ""; @@ ""; @@ "--------------------------------------------------------------------------------------------------------------------- " ; @@ " Date Days between LIBOR Interest Floor Principal Net Cash Flows" ; @@ " Dates Received Payments Repayment with Floor withput Floor " ; @@ "--------------------------------------------------------------------------------------------------------------------- " ; @@ call printfm(floor_tab1, mask, fmt) ; @@ "--------------------------------------------------------------------------------------------------------------------- " ; @@ "" ; @@ "" ; @@ "The effective annual rate of return is : " @@ "" ; @@ " with floor (per period / per annuam) " irr_yq~irr_ya ; @@ " without floor (per period / per annum) " irr_nq~irr_na ; @@ "" ; end ;