lazytrade (version 0.4.0)

self_learn_ai_R: Function to train Deep Learning regression model

Description

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 most recent indicator pattern.

Usage

self_learn_ai_R(
  price_dataset,
  indicator_dataset,
  num_bars,
  timeframe,
  path_model,
  setup_mode = FALSE,
  research_mode = FALSE,
  write_log = TRUE
)

Arguments

price_dataset

Dataset containing assets prices. It will be used as a label

indicator_dataset

Dataset containing assets indicator which pattern will be used as predictor

num_bars

Number of bars used to detect pattern

timeframe

Data timeframe e.g. 1 min

path_model

Path where the models are be stored

setup_mode

When TRUE function will attempt to write model to the disk without checking it

research_mode

When TRUE model will be saved and model result will be stored as well. To be used at the first run.

write_log

Writes results of the newly trained model and previously used model to the file

Value

Function is writing files into Decision Support System folder

Details

Performs data manipulation and training of the model. Function is handling shift of the price and indicator datasets. Function will also check how the model predict by using trading objective. NOTE: Always run parameter research_mode = TRUE for the first time

Because of the function is intended to periodically re-train the model it would always check how the previous model was working. In case new model is better, the better model will be used.

Function can also write a log files with a results of the strategy test

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
library(dplyr)
library(readr)
library(magrittr)
library(h2o)
library(lazytrade)
# start h2o engine (using all CPU's by default)
h2o.init()

path_model <- normalizePath(tempdir(),winslash = "/")
path_data <- normalizePath(tempdir(),winslash = "/")

data(indicator_dataset_big)
data(price_dataset_big)

prices <- price_dataset_big
macd <- indicator_dataset_big

# performing Deep Learning Regression using the custom function
self_learn_ai_R(price_dataset = prices,
                indicator_dataset = macd,
                num_bars = 75,
                timeframe = 60,
                path_model = path_model,
                setup_mode = FALSE,
                research_mode = FALSE,
                write_log = FALSE)

# 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 DataCamp Workspace