Description Usage Arguments Value Examples
The formula is simply: prices[length(prices)] / prices[1] - 1
. If
units.rate
is specified, then it converts to x-unit growth rate.
1 | prices_rate(prices, units.rate = NULL)
|
prices |
Numeric vector of prices or data frame with one column for each investment. |
units.rate |
Numeric value specifying the number of units for growth
rate calculation, if you want something other than total growth. For
annualized growth rate, set to 252 if |
Numeric value or vector.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ## Not run:
# Load historical prices for SPY and TLT and then calculate growth rate
prices <- load_prices(tickers = c("SPY", "TLT"), mutual.start = TRUE)
prices_rate(prices)
# Plot mean vs. SD for UPRO/VBLTX/VWEHX
plot_metrics_3funds(mean ~ sd, tickers = c("UPRO", "VBLTX", "VWEHX"))
# Plot CAGR vs. MDD for FB/AAPL/NFLX and SPY/TLT/JNK
plot_metrics_3funds(cagr ~ mdd, tickers = c("FB", "AAPL", "NFLX", "SPY", "TLT", "JNK"))
# Plot Sharpe ratio vs. allocation for the same sets
plot_metrics_3funds(sharpe ~ allocation, tickers = c("FB", "AAPL", "NFLX", "SPY", "TLT", "JNK"))
## End(Not run)
# Create vector of daily closing prices for a hypothetical stock
prices <- c(100.4, 98.7, 101.3, 101.0, 100.9)
# Overall growth is 0.50%
prices_rate(prices)
# Average daily growth is 0.12%
prices_rate(prices, 1)
# Corresponds to 36.7% annualized growth
prices_rate(prices, 252)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.