random_ohlc | R Documentation |
Calculate a random OHLC time series either by simulating random prices following geometric Brownian motion, or by randomly sampling from an input time series.
random_ohlc(
ohlc = NULL,
reducit = TRUE,
volat = 6.5e-05,
drift = 0,
datev = seq(from = as.POSIXct(paste(Sys.Date() - 3, "09:30:00")), to =
as.POSIXct(paste(Sys.Date() - 1, "16:00:00")), by = "1 sec"),
...
)
ohlc |
An OHLC time series of prices and trading volumes, in xts format (default is NULL). |
volat |
The volatility per period of the |
drift |
The drift per period of the |
datev |
The time index for the OHLC time series. |
reducit |
Boolean argument: should |
If the input ohlc
time series is NULL (the default),
then the function random_ohlc()
simulates a minutely OHLC
time series of random prices following geometric Brownian motion, over the
two previous calendar days.
If the input ohlc
time series is not NULL, then the rows of
ohlc
are randomly sampled, to produce a random time series.
If reducit
is TRUE
(the default), then the ohlc
time
series is first transformed to reduced form, then randomly sampled, and
finally converted to standard form.
Note: randomly sampling from an intraday time series over multiple days will cause the overnight price jumps to be re-arranged into intraday price jumps. This will cause moment estimates to become inflated compared to the original time series.
An xts time series with the same dimensions and the same time
index as the input ohlc
time series.
# Create minutely synthetic OHLC time series of random prices
ohlc <- HighFreq::random_ohlc()
# Create random time series from SPY by randomly sampling it
ohlc <- HighFreq::random_ohlc(ohlc=HighFreq::SPY["2012-02-13/2012-02-15"])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.