[Rquantlib-commits] r333 - pkg/QuantLib/demo

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jun 3 14:43:47 CEST 2013


Author: edd
Date: 2013-06-03 14:43:47 +0200 (Mon, 03 Jun 2013)
New Revision: 333

Modified:
   pkg/QuantLib/demo/bonds.R
Log:
add yield to final result set

Modified: pkg/QuantLib/demo/bonds.R
===================================================================
--- pkg/QuantLib/demo/bonds.R	2013-06-03 00:42:48 UTC (rev 332)
+++ pkg/QuantLib/demo/bonds.R	2013-06-03 12:43:47 UTC (rev 333)
@@ -266,23 +266,26 @@
                    Bond_dirtyPrice(zeroCouponBond),
                    Bond_accruedAmount(zeroCouponBond),
                    NA,
-                   NA),
+                   NA,
+                   100*Bond_yield(zeroCouponBond, Actual360(), "Compounded", "Annual")),
                  fixedRate=c(Instrument_NPV(fixedRateBond),
                    Bond_cleanPrice(fixedRateBond),
                    Bond_dirtyPrice(fixedRateBond),
                    Bond_accruedAmount(fixedRateBond),
-                   Bond_previousCouponRate(fixedRateBond),
-                   Bond_nextCouponRate(fixedRateBond)),
+                   100*Bond_previousCouponRate(fixedRateBond),
+                   100*Bond_nextCouponRate(fixedRateBond),
+                   100*Bond_yield(fixedRateBond, Actual360(), "Compounded", "Annual")),
                  floatingRate=c(Instrument_NPV(floatingRateBond),
                    Bond_cleanPrice(floatingRateBond),
                    Bond_dirtyPrice(floatingRateBond),
                    Bond_accruedAmount(floatingRateBond),
-                   Bond_previousCouponRate(floatingRateBond),
-                   Bond_nextCouponRate(floatingRateBond)),
+                   100*Bond_previousCouponRate(floatingRateBond),
+                   100*Bond_nextCouponRate(floatingRateBond),
+                   100*Bond_yield(floatingRateBond, Actual360(), "Compounded", "Annual")),
                  row.names=c("NPV", "Clean Price", "Dirty Price",
-                 "Accrued Amount", "Previous Coupon", "Next Coupon"))
+                 "Accrued Amount", "Previous Coupon", "Next Coupon", "Yield"))
 cat("\nResults:\n")
-print(df)
+print(df, digits=5)
 
 # Other computations
 



More information about the Rquantlib-commits mailing list