WebCab Bonds Web Services for .NET v2.01

TreasuryPrice.TbondPrice Method (DateTime, DateTime, Double, Double, Double, Int32, Int32)

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.

public double TbondPrice(
   DateTime settlementDate,
   DateTime maturityDate,
   double rate,
   double yield,
   double redemption,
   int frequency,
   int basis
);

Parameters

settlementDate
The date when the buyer receives the ownership of the bonds. For example, if the Bond is traded on Monday on a T+3 settlement then the ownership of the bond will be received 3 days after the initial trade. The reason for this distinction is that when a bond is purchased on an open market the new owner will not be entitled to the coupon payments until the settlement date.
maturityDate
The date when the bond matures when the holder of the bond will receive the payment of the redemption value (also known as the principle sum).
rate
The (annual) rate of the coupon. This is the annual cash flow (from coupons) which are received by the holder of the bond, this parameter is given as a percentage of the principle sum where the amount receive in coupon over a year is equal to the given percentage of the principle sum.
yield
The effective annual yield (to maturity) of the bond given in decimal format (i.e. 1 percent = 0.01). Note that the yield (to maturity) is assumed to be known and is the essential ingredient within this method from which the price is deduced.
redemption
The redemption (also known as the principle sum) of the bond is the sum which is paid to the holder of the bond at maturity.
frequency
The number of equal coupon payments per year. This parameter must taken one of the values 1, 2, 3, 4, 6, or 12; corresponding to the divisors of 12.
basis
The type of day count basis to use, where 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.

Remarks

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:

  1. As remarked above this methods offers the same functionality, with the same interface as the PRICE function within the Analysis ToolPak of Microsoft's Excel.
  2. Within the documentation of this method we use technical terms in accordance with there use within Excel's documentation.
  3. In addition to Excel this method also corresponds to the yield evaluation used within a Bloomberg terminal which can be accessed with a terminal by entering the command DES <GO>.

Worked Example

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
Date
Maturity
Date
YieldCouponRedemption
Price
Coupon
Frequency
Excel
Results
WebCab
Results
Difference
29-Aug-200623-Dec-20110.0998732549.510029898.00001323-1.32276E-05
29-Aug-200601-Sep-200612.685638068105498980
29-Aug-200615-Oct-20080.1253641891210049999.00005159-5.15888E-05
11-Jan-200524-Jun-20080.1143906789110210099.999911678.8332E-05
23-Sep-200429-Jan-20200.115433807121102105104.99992097.90621E-05
02-Jun-200002-Jun-20150.046000314102501234234.0000633-6.31955E-05
01-Jul-200614-Aug-20060.2483672671020512002000
15-Jan-200415-Sep-20090.079225376501200110001000.000053-5.26783E-05
31-Dec-200301-Jan-20070.1001708417110110099.999934326.5687E-05
01-Jan-200601-Jun-20060.2078740161010511001000

Source Code Implementation: You can find the source code implementation of this worked example within the Client/BasicBonds/PriceAndYieldFunctions/ directory.

Exceptions

Exception TypeCondition
ExceptionThrown if the settlementDate is after the maturityDate then an argument exception will be thrown.
ExceptionThrown if the rate, yield, or redemption are negative then an argument exception will be thrown.
ExceptionThrown if the frequency given is not one of 1, 2, 3, 4, 6 or 12, then an argument exception will be thrown.
ExceptionThrown if the basis given is not 0 or 1, then an argument exception will be thrown.

See Also

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.