# Rusquant is quantmod library with ability
# to load Russian market with intraday data
# Use vanilla quantmod for other markets
library(rusquant)
# Load symbol from data provider
data.raw <- getSymbols("SBER", src = "Finam", period="5min", from = "2017-08-25", to = "2017-08-25", auto.assign = FALSE)
# Convert price to stationary data
data <- diff(log(Cl(data.raw)))
# Train auto regression arima model
fit <- arima(data, order=c(10,0,1))
# Predict the future
pred <- predict(fit, n.ahead=100)
# Xts index lost during prediction, so convert predicted data to xts
pred.index <- as.POSIXct(index(pred$pred), origin = min(index(data)))
pred.xts <- xts(pred$pred, order.by = pred.index)
# Draw original and predicted values on the same chart
plot(c(data, pred.xts), type = "n")
lines(data)
lines(pred.xts, col = "red")