fixed_bond | R Documentation |
Create Fixed Bond Object
fixed_bond(value_date, mty_date, redem_value, cpn_rate, cpn_freq)
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) |
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.
all arguments must be the same length or 1.
The date input will be converted to Date object via ymd::ymd()
.
It doesn't take the day count convention into account for now.
There's no support for business day calendar. The dates in the cashflow projection are the
same days in the next few months (see ymd::edate()
). It considers different days in each
month but no weekend date adjustment.
The 'YTM' value is the cashflow's 'IRR' (internal rate of return) value. Thus, it doesn't
equal to the Excel's Yield value, which is adjusted using this formula
YTM (fcl) = (1 + frac{Yield (Excel)}{n})^n - 1
,
where n is the the coupon payment frequency, when the remaining life of the bond is larger
than 1.
When the bond is going to mature within one year, the Yield (Excel) = frac{Cashflow}{Price} - 1
.
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)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.