presentValue: 'presentValue'

View source: R/presentValue.R

presentValueR Documentation

presentValue

Description

Function that calculates the Net Present Value (NPV) for the cash flow streams generated by or contained in object x.

Usage

presentValue(x, yield, by, isPercentage, isPrice, digits)

Arguments

x

a contract type, for which to calculate the NPV. This can also be a timeSeries, EventSeries or Portfolio object.

yield

a numeric, an object of type YieldCurve or DynamicYieldcurve to calculate discount factors from, indicating the percentage yield used to discount.

by

a character indicating the date as for which the NPV is calculated.

isPercentage

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

isPrice

a logical indicating whether the result should be a price in the case of a cash flow pattern where the initial cash flow is negative and the others are positive (default is FALSE).

digits

an integer indicating the number of digits to round to. (default is 2)

Details

TO BE ADDED

Value

a numeric, representing the Net Present Value (NPV) of the contract.

Examples

b <- bond("2013-12-31", maturity = "5 years", nominal = 50000, 
           coupon = 0.02, couponFreq = "1 years")
npv <- presentValue(b, yield = 2) # result: 0 due to same coupon as yield
evs <- events(b, "2013-12-31")
npv <- presentValue(evs, yield = 1)
ts <- timeSeries(data = c(-50000, 1000, 1000, 1000, 1000, 51000),
                 charvec = c("2013-12-31", "2014-12-31", "2015-12-31", 
                 "2016-12-31", "2017-12-31", "2018-12-31"),
                 units = "Value")
npv <- presentValue(ts, yield = 1)


wbreymann/FEMS documentation built on Dec. 8, 2022, 9:43 a.m.