bondYield#

swordfish.function.bondYield()#

Calculate the bond yield for each 100 face value of a bond based on its clean price or dirty price.

Parameters:
  • start (Constant) – A calar or vector of DATE type indicating the bond’s value date.

  • maturity (Constant) – A DATE scalar or vector indicating the maturity date.

  • issuePrice (Constant) – A numeric scalar or vector of the same length as start indicating the bond’s issue price. For discount bonds, the actual issue price must be specified (typically less than 100); for other bonds, it is usually 100.

  • coupon (Constant) – A numeric scalar or vector indicating the annual coupon rate. For example, 0.03 indicates a 3% annual coupon.

  • frequency (Constant) –

    An INT scalar/vector indicating the number of payments, or a STRING scalar/vector indicating payment frequency. It can be:

    • 0/”Once”: Bullet payment at maturity.

    • 1/”Annual”: Annual payments.

    • 2/”Semiannual”: Semi-annual payments.

    • 4/”Quarterly”: Quarterly payments.

    • 12/”Monthly”: Monthly payments.

  • dayCountConvention (Constant) –

    A STRING scalar or vector indicating the day count convention to use. It can be:

    • ”Thirty360US”: US (NASD) 30/360

    • ”ActualActualISMA” (default): actual/actual (ISMA rule)

    • ”Actual360”: actual/360

    • ”Actual365”: actual/365

    • ”Thirty360EU”: European 30/360

    • ”ActualActualISDA” (default): actual/actual (ISDA rule)

  • bondType (Constant) –

    A STRING scalar or vector indicating the bond type. It can be:

    • ”FixedRate”: Fixed-rate bond, where interest is paid periodically based on the coupon rate.

    • ”Discount”: Discount bond, where no interest is paid, and the bond is issued at a discount. FV at maturity = face value.

    • ”ZeroCoupon”: Zero-coupon bond, where interest and face value are paid at maturity. FV at maturity = face value + interest.

  • settlement (Constant) – A DATE scalar or vector indicating the settlement date.

  • price (Constant) –

    A numeric scalar or vector whose meaning depends on the value of priceType:

    • When priceType is “CleanPrice”, price indicates the bond’s clean price.

    • When priceType is “DirtyPrice”, price indicates the bond’s dirty price.

  • priceType (Constant) –

    A STRING scalar or vector used to specify the type of the bond price (price). It can be:

    • ”CleanPrice”: Clean price.

    • ”DirtyPrice”: Dirty price.

  • method (Constant, optional) –

    A STRING scalar or vector indicating the optimization algorithm used to solve the bond yield, by default DFLT. It can be:

    • ”newton” (default): Newton algorithm.

    • ”brent”: Brent algorithm.

    • ”nm”: Nelder-Mead simplex algorithm.

    • ”bfgs”: BFGS algorithm.

    • ”lbfgs”: LBFGS algorithm.

  • maxIter (Constant, optional) – A positive integer or a vector of positive integers indicating the maximum number of iterations, by default DFLT.

  • benchmark (Constant, optional) – A STRING scalar indicating the reference algorithm, by default DFLT. Currently, only “Excel” (the algorithm used in Excel) is supported.

Returns:

A DOUBLE scalar or vector.

Return type:

Constant