Calculate Growth Rate From a Vector of Stock Prices or Investment Balances
The formula is simply: overall.rate = prices[length(prices)] / prices - 1. If xday is specified, then it converts to x-day growth rate. For example, if prices is a vector of stock prices over a five-day period, say c(100.4, 98.7, 101.3, 101.0, 100.9), then the overall growth rate is approximately 0.0050 over four full trading days. If xday.rate is set to 1, this rate is converted to an average daily rate of approximately
Numeric vector of stock prices or investment balances. Has to be daily prices if you want to calculate x-day rather than overall growth.
Number of days for growth rate calculation. If unspecified, function returns overall 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.