gains_prices {stocks} | R Documentation |
Convert Gains to Prices
Description
Calculates prices based on initial balance and vector of gains.
Usage
gains_prices(gains, initial = 10000)
Arguments
gains |
Numeric matrix with 1 column of gains for each investment (can be a vector if there is only one). |
initial |
Numeric value. |
Value
Numeric value if gains
is a vector, numeric matrix if
gains
is a matrix.
Examples
# Simulate daily gains over a 5-year period
set.seed(123)
gains <- rnorm(n = 252 * 5, mean = 0.001, sd = 0.02)
# Plot balance over time if initial balance is $10,000
prices <- gains_prices(gains)
plot(prices)
[Package stocks version 1.1.4 Index]