shrektan / fcl

financial calculator
https://shrektan.github.io/fcl/
Other
2 stars 1 forks source link

use year_frac to calculate YTM #1

Closed shrektan closed 2 years ago

shrektan commented 2 years ago

So that leap and non-leap year input generates same YTM

r$> out <- fcl::bond_result( 
        value_date = c(200101, 210101), 
        mty_date = c(210101, 220101), 
        redem_value = 100, 
        cpn_rate = 0.05, 
        cpn_freq = 1, 
        ref_date = c(200101, 210101), 
        clean_price = 100 
      )                                                           

r$> out                                                           
   YTM MACD     MODD
1 0.05    1 0.952381
2 0.05    1 0.952381
shrektan commented 2 years ago

This is also aligned with China Bond's method (basically the same, except that it uses current coupon period's remainning days / period's full days to calculate the fractions). It's better than than the days/365 method.

image