Skip to content

Commit adad762

Browse files
committed
Update financial functions.R
1 parent 0303109 commit adad762

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

R/financial functions.R

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,43 @@ fin_valuation <- function(revenue=6e6*30e3, opmargin=.08, expenses=.2, PE=30, sy
4848
invisible(marketCap)
4949
}
5050

51+
#' Compute the net present value of a future income stream
52+
#'
53+
#' @description
54+
#' `fin_valuation` uses the revenue, operating margin, expenses and PE to compute a market capitalization.
55+
#' Better to use a more powerful online site.
56+
#'
57+
#' @details
58+
#' Revenue stream is discounted back to a present day cash amount which is equivalent.
59+
#'
60+
#' @param cashflow Value of expected recurring payment
61+
#' @param discount Percent return to discount against (.05 = 5%)
62+
#' @param periods How many periods the stream delivers, e.g., (90-65) for 25 of a pension.
63+
#' @param PE of the company
64+
#' @param symbol Currency
65+
#' @param use reporting values in "B" (billion) or "M" (millions)
66+
#' @return - value
67+
#' @export
68+
#' @family Miscellaneous Functions
69+
#' @seealso - [fin_interest()], [fin_NI()], [fin_percent()]
70+
#' @md
71+
#' @examples
72+
#' fin_net_present_value(27e3, .05, 25)
73+
#'
74+
fin_net_present_value <- function(income=27e3, discount_rate=.05, periods = 25, symbol = NULL) {
75+
if(is.null(symbol)){symbol = umx_set_dollar_symbol(silent=TRUE)}
76+
77+
cashflows = rep(income, periods)
78+
timePeriods = seq(1, periods)
79+
discount_factors = 1/(1+discount_rate)^timePeriods
80+
present_values = cashflows*discount_factors
81+
pv = sum(present_values)
82+
cat("\nBased on a discount rate of ", discount_rate*100, "%, an income of ", bucks(income, symbol, cat=TRUE), " for ", periods, " years, has a net present value of \n", sep="")
83+
cat("\n", bucks(pv, symbol))
84+
85+
invisible(pv)
86+
}
87+
5188
#' Compute the future value and gain of an investment
5289
#'
5390
#' @description

0 commit comments

Comments
 (0)