Function is training h2o deep learning model to match future prices of the asset to the indicator pattern. Main idea is to be able to predict future prices by solely relying on the recently retrieved indicator pattern. This is to mimic traditional algorithmic systems based on the indicator rule attempting to automate optimization process with AI.
Deep learning model structure is obtained from the 8 random combinations of neurons within 3 hidden layers of the network, the most accurate model configuration will be automatically selected
In addition, the function will check if there is a need to update the model. To do that function will check results of the function aml_test_model.R.
aml_make_model(
symbol,
timeframe,
path_model,
path_data,
force_update = FALSE,
num_nn_options = 24
)
Character symbol of the asset for which to train the model
Data timeframe e.g. 1 min
Path where the models shall be stored
Path where the aggregated historical data is stored, if exists in rds format
Boolean, by setting this to TRUE function will generate new model (useful after h2o engine update)
Integer, value from 1 to 20 or more. Used to change number of variants of the random neural network structures
Function is writing a file object with the best Deep Learning Regression model
Function is using the dataset prepared by the function aml_collect_data.R. Function will start to train the model as soon as there are more than 100 rows in the dataset
# NOT RUN {
# }
# NOT RUN {
library(dplyr)
library(readr)
library(h2o)
library(lazytrade)
library(lubridate)
path_model <- normalizePath(tempdir(),winslash = "/")
path_data <- normalizePath(tempdir(),winslash = "/")
ind = system.file("extdata", "AI_RSIADXUSDJPY60.csv",
package = "lazytrade") %>% read_csv(col_names = FALSE)
ind$X1 <- ymd_hms(ind$X1)
# data transformation using the custom function for one symbol
aml_collect_data(indicator_dataset = ind,
symbol = 'USDJPY',
timeframe = 60,
path_data = path_data)
# dataset will be written to the temp directory
# start h2o engine
h2o.init(nthreads = 2)
# performing Deep Learning Regression using the custom function
aml_make_model(symbol = 'USDJPY',
timeframe = 60,
path_model = path_model,
path_data = path_data,
force_update=FALSE,
num_nn_options = 2)
# stop h2o engine
h2o.shutdown(prompt = FALSE)
#set delay to insure h2o unit closes properly before the next test
Sys.sleep(5)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab