Evaluates the price of a Treasury bond where the coupons are paid n-times a year (ie yearly, semi-annual, quarterly etc), this method corresponds to Excel's PRICE function.
0 means a 30/360 day count convention is used and 1 means an Actual/Actual day count convention is used. Note that this parameter must be given as 0, or 1.The technique used here to evaluate the price is to discount the future cash flows in accordance with the risk free interest rate. The method allows the price of a bond to be deduced from its yield, the corresponding method (essentially the inverse) where as you are able to deduce price from the yield is YieldToMaturityFromPrice(Date, Date, double, double, double, int, int).
Notes:
Within this worked example we compare our results with the results given by the PRICE function from Excel. The basis is 0, correspond a 30/360 day count convention which is used with all Excel and WebCab evaluations.
Settlement
DateMaturity
DateYield Coupon Redemption
PriceCoupon
FrequencyExcel
ResultsWebCab
ResultsDifference 29-Aug-2006 23-Dec-2011 0.099873254 9.5 100 2 98 98.00001323 -1.32276E-05 29-Aug-2006 01-Sep-2006 12.68563806 8 105 4 98 98 0 29-Aug-2006 15-Oct-2008 0.125364189 12 100 4 99 99.00005159 -5.15888E-05 11-Jan-2005 24-Jun-2008 0.114390678 9 110 2 100 99.99991167 8.8332E-05 23-Sep-2004 29-Jan-2020 0.115433807 12 110 2 105 104.9999209 7.90621E-05 02-Jun-2000 02-Jun-2015 0.046000314 10 250 1 234 234.0000633 -6.31955E-05 01-Jul-2006 14-Aug-2006 0.248367267 10 205 1 200 200 0 15-Jan-2004 15-Sep-2009 0.079225376 50 1200 1 1000 1000.000053 -5.26783E-05 31-Dec-2003 01-Jan-2007 0.100170841 7 110 1 100 99.99993432 6.5687E-05 01-Jan-2006 01-Jun-2006 0.207874016 10 105 1 100 100 0
Source Code Implementation: You can find the source code implementation of this worked
example within the Client/BasicBonds/PriceAndYieldFunctions/ directory.
| Exception Type | Condition |
|---|---|
| Exception | Thrown if the settlementDate is after the maturityDate then an argument exception will be thrown. |
| Exception | Thrown if the rate, yield, or redemption are negative then an argument exception will be thrown. |
| Exception | Thrown if the frequency given is not one of 1, 2, 3, 4, 6 or 12, then an argument exception will be thrown. |
| Exception | Thrown if the basis given is not 0 or 1, then an argument exception will be thrown. |
TreasuryPrice Class | BasicBonds Namespace | TreasuryPrice.TbondPrice Overload List | YieldToMaturityFromPrice - Evaluate the yield to maturity from the price of the bond and is essential an inverse of this method.