gains_prices: Convert Sequence of Gains to Sequence of Prices

Description Usage Arguments Value Examples

View source: R/gains_prices.R

Description

Converts sequence of gains and initial balance to sequence of prices for one or more investments.

Usage

1
gains_prices(gains, initial = 10000, date1 = NULL)

Arguments

gains

Numeric vector of gains for one investment, or data frame with one column for each investment and an optional Date variable.

initial

Numeric value.

date1

Date to use for initial price.

Value

Numeric vector or data frame.

Examples

1
2
3
4
5
6
7
# 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)

vandomed/stocks documentation built on July 22, 2020, 3:25 a.m.