BondVal.Price: BondVal.Price (calculation of CP, AccrInt, DP, ModDUR, MacDUR...

View source: R/BondVal.Price.R

BondVal.PriceR Documentation

BondVal.Price (calculation of CP, AccrInt, DP, ModDUR, MacDUR and Conv)

Description

BondVal.Price computes a bond's clean price given its yield.

Usage

BondVal.Price(
  YtM = as.numeric(NA),
  SETT = as.Date(NA),
  Em = as.Date(NA),
  Mat = as.Date(NA),
  CpY = as.numeric(NA),
  FIPD = as.Date(NA),
  LIPD = as.Date(NA),
  FIAD = as.Date(NA),
  RV = as.numeric(NA),
  Coup = as.numeric(NA),
  DCC = as.numeric(NA),
  EOM = as.numeric(NA),
  DateOrigin = as.Date("1970-01-01"),
  InputCheck = 1,
  FindEOM = FALSE,
  RegCF.equal = 0,
  SimpleLastPeriod = TRUE,
  Calc.Method = 1,
  AnnivDatesOutput = as.list(NA)
)

Arguments

YtM

The bond's yield to maturity p.a. on SETT. (required)

SETT

The settlement date. Date class object with format "%Y-%m-%d". (required)

Em

The bond's issue date. Date class object with format "%Y-%m-%d". (required)

Mat

So-called "maturity date" i.e. date on which the redemption value and the final interest are paid. Date class object with format "%Y-%m-%d". (required)

CpY

Number of interest payments per year (non-negative integer; element of the set {0,1,2,3,4,6,12}. Default: 2.

FIPD

First interest payment date after Em. Date class object with format "%Y-%m-%d". Default: NA.

LIPD

Last interest payment date before Mat. Date class object with format "%Y-%m-%d". Default: NA.

FIAD

Date on which the interest accrual starts (so-called "dated date"). Date class object with format "%Y-%m-%d". Default: NA.

RV

The redemption value of the bond. Default: 100.

Coup

Nominal interest rate per year in percent. Default: NA.

DCC

The day count convention the bond follows. Default: NA. For a list of day count conventions currently implemented type View(List.DCC).

EOM

Boolean indicating whether the bond follows the End-of-Month rule. Default: NA.

DateOrigin

Determines the starting point for the daycount in "Date" objects. Default: "1970-01-01".

InputCheck

If 1, the input variables are checked for the correct format. Default: 1.

FindEOM

If TRUE, EOM is overridden by the value inferred from the data. Default: FALSE.

RegCF.equal

If 0, the amounts of regular cash flows are calculated according to the stipulated DCC. Any other value forces all regular cash flows to be equal sized. Default: 0.

SimpleLastPeriod

Specifies the interest calculation method in the final coupon period. Default: TRUE.

Calc.Method

If 1, discount powers are computed with the same DCC as accrued interest. If 0, discount powers are computed with DCC=2. Default: 1.

AnnivDatesOutput

A list containing the output of the function AnnivDates. Default: NA.

Details

The function BondVal.Price uses the function AnnivDates to analyze the bond and computes the clean price, the accrued interest, the dirty price and the sensitivity measures modified duration (ModDUR), MacAulay duration (MacDUR) and convexity according to the methodology presented in Djatschenko (2018).

Value

CP

The bond's clean price.

AccrInt

The amount of accrued interest.

DP

The bond's dirty price.

ytm.p.a.

Annualized yield to maturity.

ModDUR.inYears

Modified duration in years.

MacDUR.inYears

MacAulay duration in years.

Conv.inYears

Convexity in years.

ModDUR.inPeriods

Modified duration in periods.

MacDUR.inPeriods

MacAulay duration in periods.

Conv.inPeriods

Convexity in periods.

tau

Relative Position of the settlement date in regular periods.

References

  1. Djatschenko, Wadim, The Nitty Gritty of Bond Valuation: A Generalized Methodology for Fixed Coupon Bond Analysis Allowing for Irregular Periods and Various Day Count Conventions (November 5, 2018). Available at SSRN: https://ssrn.com/abstract=3205167.

Examples

data(PanelSomeBonds2016)
randombond<-sample(c(1:length(which(!(duplicated(PanelSomeBonds2016$ID.No))))),1)
df.randombond<-PanelSomeBonds2016[which(PanelSomeBonds2016$ID.No==randombond),]

PreAnalysis.randombond<-suppressWarnings(AnnivDates(
  unlist(df.randombond[
           1,c('Issue.Date','Mat.Date','CpY.Input','FIPD.Input','LIPD.Input',
               'FIAD.Input','RV.Input','Coup.Input','DCC.Input','EOM.Input')],
         use.names=FALSE)))

system.time(
  for (i in c(1:nrow(df.randombond))) {
    BondVal.Price.Output<-suppressWarnings(BondVal.Price(
      unlist(
        df.randombond[
          i,c('YtM.Input','TradeDate','Issue.Date','Mat.Date','CpY.Input',
              'FIPD.Input','LIPD.Input','FIAD.Input','RV.Input','Coup.Input',
              'DCC.Input','EOM.Input')],use.names=FALSE),
      AnnivDatesOutput=PreAnalysis.randombond))
    df.randombond$CP.Out[i]<-BondVal.Price.Output$CP
  }
)
plot(seq(1,nrow(df.randombond),by=1),df.randombond$CP.Out,"l")


BondValuation documentation built on May 30, 2022, 1:08 a.m.