Learn R Programming

fcl (version 0.1.4)

fixed_bond: Create Fixed Bond Object

Description

Create Fixed Bond Object

Usage

fixed_bond(value_date, mty_date, redem_value, cpn_rate, cpn_freq)

Value

it returns an environment containing the following objects:

  • .self: an external pointer of the Rust object.

  • len(): a function returns the length of the internal bonds object.

  • ytm_dur(ref_date, clean_price): a function returns a data.frame, with three columns, 'YTM' (Yield to Maturity), 'MODD' (Modified Duration) and 'MACD' (Macaulay Duration).

  • cf(ref_date): a function returns the schedualed bond cashflows, in xts format.

Arguments

value_date, mty_date

the value and maturity date of the bond

redem_value, cpn_rate, cpn_freq

the redemption value, coupon rate and coupon frequency of the bond. Note that the frequency can only be one of 1, 2, 4, 0 (pay at mature)

Examples

Run this code
bond <- fixed_bond(
  value_date = 210101,
  mty_date = c(250101, 300201),
  redem_value = 100,
  cpn_rate = c(0.05, 0.03),
  cpn_freq = c(0, 1)
)
bond$ytm_dur(
  ref_date = c(220101, 220201),
  clean_price = 100
)
bond$cf(
  ref_date = c(220101, 220131)
)

Run the code above in your browser using DataLab