presentValue | R Documentation |
presentValue
Function that calculates the Net Present Value (NPV) for the cash flow streams
generated by or contained in object x
.
presentValue(x, yield, by, isPercentage, isPrice, digits)
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 |
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) |
TO BE ADDED
a numeric, representing the Net Present Value (NPV) of the contract.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.