duration: 'duration'

View source: R/duration.R

durationR Documentation

duration

Description

Function which calculates the duration of a portfolio or a contract.

Usage

duration(x, type="macaulay", yield, price, isPercentage=TRUE, from)

Arguments

x

the contract or portfolio of contracts for which to calculate the duration.

type

a character defining the type of duration; possible types are 'fisher-weil', 'macaulay' (default) and 'dollar'.

yield

a numeric, an Object of class YieldCurve or DynamicYieldCurve that describes the spot rate term structure or indicates the yield used to calculate the duration.

price

a numeric, indicating the price used for calculating the yield to maturity of each contract.

isPercentage

a numeric, indicating if the 'yield' is passed as percentage (TRUE) or as fraction (FALSE).

from

a character indicating the date as for which the net present value is calculated.

Details

For the Macaulay duration, if yield is not provided, price should be provided and is used to calculate the yield. For the Fisher-Weil duration, yieldCurve must be specified. In this case the argument price has no effect.

Value

a numeic containing the calculated duration.

Examples

bnd1=bond(start="2015-01-01", maturity="30 years", nominal=1000, 
          coupon=0.06, couponFreq="1 year", role="long", variable=FALSE)
duration(bnd1, type="macaulay", yield=9)


wbreymann/FEMS documentation built on May 6, 2024, 2:19 p.m.