Calculate Growth Rate From a Vector of Stock or Investment Gains
The formula is simply: overall.rate = prod(gains + 1) - 1. If xday is specified, then it converts to x-day growth rate. For example, if balances is a vector of stock gains over a five-day period, say c(-0.02, -0.01, 0.01, 0.02, 0.01), then the total growth rate is approximately 0.0095 over five trading days. If xday.rate is set to 1, this rate is converted to an average daily rate of approximately 0.0019.
Numeric vector of stock or investment gains. Has to be daily gains if you want to calculate x-day rather than overall growth.
Number of days for growth rate calculation. If unspecified, function returns total growth. If set to 251, function would return annual growth rate.
If TRUE, function finds and removes any missing values (NA's) in prices vector. The default is FALSE to maximize speed for the usual case where there are no missing values.
Numeric value indicating the growth rate.
Dane R. Van Domelen
Acknowledgment: This material is based upon work supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE-0940903.
1 2 3 4 5 6 7 8 9 10 11
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.