rintraday: Simulate intraday prices

Description Examples

Description

Note that trading hours are based on GMT, so be sure that your timezone is specified as GMT. Sys.setenv(TZ='GMT')

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
th <- function(x) trading_hours(x,'cme')
myou <- function(x) ou(x, 40, 3/24, 45, .03/1440)
x <- rintraday(myou, obs=60)

mygbm <- function(x) gbm(x, 40, .03/1440)
y <- rintraday(mygbm, start='2014-01-01', end='2014-06-30', period=5, hours.fn=th)

# Create correlated intraday prices
seed <- rintraday(mygbm, obs=60, period=5, hours.fn=th)
cmat <- matrix(c(1,0,0, .8,1,0, .6,.4,1), ncol=3)
z <- rintraday(seed, cmat)

# Create correlated intraday OHLC bars with optional volume.
seed <- rintraday(mygbm, obs=60, period=5, hours.fn=th)
cmat <- matrix(c(1,0,0, .8,1,0, .6,.4,1), ncol=3)
z <- rintraday(seed, cmat, ohlc=1, volume=100)

zatonovo/fractalrock documentation built on May 15, 2021, 7:28 p.m.