[Uwgarp-commits] r193 - in pkg/GARPFRM: R man sandbox vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jun 28 02:29:22 CEST 2014


Author: tfillebeen
Date: 2014-06-28 02:29:22 +0200 (Sat, 28 Jun 2014)
New Revision: 193

Modified:
   pkg/GARPFRM/R/discountFactorArbitrage.R
   pkg/GARPFRM/man/bondFullPrice.Rd
   pkg/GARPFRM/sandbox/test_discountFactorArbitrage.R
   pkg/GARPFRM/vignettes/FixedIncome.lyx
Log:
vignette/tests edited

Modified: pkg/GARPFRM/R/discountFactorArbitrage.R
===================================================================
--- pkg/GARPFRM/R/discountFactorArbitrage.R	2014-06-26 19:28:54 UTC (rev 192)
+++ pkg/GARPFRM/R/discountFactorArbitrage.R	2014-06-28 00:29:22 UTC (rev 193)
@@ -75,7 +75,15 @@
   return(DF)
 }
 
+#' bondFullPrice
+#' 
 #' Estimate price of bond w/ acrrued interest
+#' The present value of a bond's cash flows should be equated or 
+#' compared with its full price, with the amount a pruchaser actually 
+#' pays to purchase those cash flows. The flat price is p, accrued 
+#' interest is AI, the present value of the cash flows by PV, and the 
+#' full price by P: 
+#' P=p+AI=PV
 #' 
 #' This function calculates the price of a fixed rate coupon bond given coupon rate, yield, 
 #' compoundPd, cashFlowPd, face value, previous coupon date, next coupon date.
@@ -85,6 +93,16 @@
 #' @param t0 previous coupon date
 #' @param t1 next coupon period
 #' @param currentDate current date
+#' @examples
+#' t0 = as.Date("2013-08-15")
+#' t1 = as.Date("2014-02-15")
+#' tn = as.Date("2013-10-04")
+#' currentDate = tn
+#' bond = bondSpec(face=100, m=2, couponRate = 0.0475)
+#' y1 = 0.00961
+#' bondFullPrice(bond, y1, 8, t0, t1, tn)$clean
+#' bondFullPrice(bond, y1, 8, t0, t1, tn)$dirty
+#' bondFullPrice(bond, y1, 8, t0, t1, tn)$accruedInterest
 #' @return price of the bond: clean, dirty and accrued interest
 #' @author TF
 #' @export

Modified: pkg/GARPFRM/man/bondFullPrice.Rd
===================================================================
--- pkg/GARPFRM/man/bondFullPrice.Rd	2014-06-26 19:28:54 UTC (rev 192)
+++ pkg/GARPFRM/man/bondFullPrice.Rd	2014-06-28 00:29:22 UTC (rev 193)
@@ -1,7 +1,7 @@
 % Generated by roxygen2 (4.0.1): do not edit by hand
 \name{bondFullPrice}
 \alias{bondFullPrice}
-\title{Estimate price of bond w/ acrrued interest}
+\title{bondFullPrice}
 \usage{
 bondFullPrice(bond, yield, cashFlowPd, t0, t1, currentDate)
 }
@@ -22,9 +22,29 @@
 price of the bond: clean, dirty and accrued interest
 }
 \description{
+Estimate price of bond w/ acrrued interest
+The present value of a bond's cash flows should be equated or
+compared with its full price, with the amount a pruchaser actually
+pays to purchase those cash flows. The flat price is p, accrued
+interest is AI, the present value of the cash flows by PV, and the
+full price by P:
+P=p+AI=PV
+}
+\details{
 This function calculates the price of a fixed rate coupon bond given coupon rate, yield,
 compoundPd, cashFlowPd, face value, previous coupon date, next coupon date.
 }
+\examples{
+t0 = as.Date("2013-08-15")
+t1 = as.Date("2014-02-15")
+tn = as.Date("2013-10-04")
+currentDate = tn
+bond = bondSpec(face=100, m=2, couponRate = 0.0475)
+y1 = 0.00961
+bondFullPrice(bond, y1, 8, t0, t1, tn)$clean
+bondFullPrice(bond, y1, 8, t0, t1, tn)$dirty
+bondFullPrice(bond, y1, 8, t0, t1, tn)$accruedInterest
+}
 \author{
 TF
 }

Modified: pkg/GARPFRM/sandbox/test_discountFactorArbitrage.R
===================================================================
--- pkg/GARPFRM/sandbox/test_discountFactorArbitrage.R	2014-06-26 19:28:54 UTC (rev 192)
+++ pkg/GARPFRM/sandbox/test_discountFactorArbitrage.R	2014-06-28 00:29:22 UTC (rev 193)
@@ -7,6 +7,13 @@
 ## The Cash Flows from Fixed-Rate Government Coupon Bonds
 # Discount Factors and the Law of One Price
 # Initialize: The Cash Flows from Fixed-Rate: treasury bonds ticking in quarters
+## Example from Tuckman
+cashFlow = rbind(c(100+(1+1/4)/2,0,0),c((4 +7/8)/2,100+(4+7/8)/2,0),c((4+1/2)/2,(4+1/2)/2,100+(4+1/2)/2))
+# Initialize: Price of the bond
+price = matrix(c(100.550, 104.513, 105.856), ncol=1)
+DF = discountFactor(price, cashFlow)
+
+## Additional Example
 cashFlow = rbind(c(100, 0, 0, 0), c(2 + 7/8, 102 + 7/8, 0, 0), c(3 + 3/4, 3 + 3/4, 103 + 3/4, 0), c(3 + 3/4, 3 + 3/4, 3 + 3/4, 103 + 3/4))
 # Initialize: Price of the bond
 price <- matrix(c(96.8, 99.56, 100.86, 101.22), ncol=1)
@@ -109,7 +116,8 @@
 # Plot of continuously compounded spot rates
 plot(x=years, y=rate, type="l", ylab="Rate", xlab="Time to Maturity", main="Term Structure: Spot Rates")
 
-# Spot, Forward, and Par Rates
+# Spot, Forward Rates
 DF = c(0.996489, 0.991306, 0.984484, 0.975616, 0.964519)
 time = seq(from=0.5, to=2.5, by=0.5)
-
+rates = spotForwardRates(time,DF)
+rates
\ No newline at end of file

Modified: pkg/GARPFRM/vignettes/FixedIncome.lyx
===================================================================
(Binary files differ)



More information about the Uwgarp-commits mailing list