Skip to content

Commit

Permalink
added automated machine learning scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhomeexperiments committed May 7, 2020
1 parent ff15fe2 commit 868a138
Show file tree
Hide file tree
Showing 49 changed files with 880 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ ScoreData.R
model/LOG/AI_T-15.csv
model/LOG/AI_T-60.csv
*.csv
_DATA/
_MODELS/
_SETUP/
Binary file added _LOGS/time_executeM15.rds
Binary file not shown.
Binary file added _LOGS/time_executeM60.rds
Binary file not shown.
Binary file modified _MODELS/DL_Regression100-1
Binary file not shown.
Binary file modified _MODELS/DL_Regression100-15
Binary file not shown.
Binary file modified _MODELS/DL_Regression100-60
Binary file not shown.
Binary file modified _MODELS/DL_Regression125-1
Binary file not shown.
Binary file modified _MODELS/DL_Regression125-15
Binary file not shown.
Binary file modified _MODELS/DL_Regression125-60
Binary file not shown.
Binary file modified _MODELS/DL_Regression75-1
Binary file not shown.
Binary file modified _MODELS/DL_Regression75-15
Binary file not shown.
Binary file modified _MODELS/DL_Regression75-60
Binary file not shown.
2 changes: 1 addition & 1 deletion _MODELS/LOG/AI_T-15.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
TPSL_Level
10
60
2 changes: 1 addition & 1 deletion _MODELS/LOG/AI_T-60.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
TPSL_Level
40
30
4 changes: 2 additions & 2 deletions _PROD/01_SelfLearn1.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
:: Use this line of code for debugging purposes *** Adapt the paths for R installation and R script!!!
::"C:\Program Files\R\R-3.6.0\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\01_SelfLearnM1.R"
::"C:\Program Files\R\R-3.6.1\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\01_SelfLearnM1.R"
:: Use this code in 'production'
"C:\Program Files\R\R-3.6.0\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\01_SelfLearnM1.R"
"C:\Program Files\R\R-3.6.1\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\01_SelfLearnM1.R"
4 changes: 2 additions & 2 deletions _PROD/02_ScoreData1.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
:: Use this line of code for debugging purposes *** Adapt the paths for R installation and R script!!!
::"C:\Program Files\R\R-3.6.0\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\02_ScoreDataM1.R"
::"C:\Program Files\R\R-3.6.1\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\02_ScoreDataM1.R"
:: Use this code in 'production'
"C:\Program Files\R\R-3.6.0\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\02_ScoreDataM1.R
"C:\Program Files\R\R-3.6.1\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\02_ScoreDataM1.R
4 changes: 2 additions & 2 deletions _PROD/03_SelfLearn15.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
:: Use this line of code for debugging purposes *** Adapt the paths for R installation and R script!!!
::"C:\Program Files\R\R-3.6.0\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\03_SelfLearnM15.R"
::"C:\Program Files\R\R-3.6.1\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\03_SelfLearnM15.R"
:: Use this code in 'production'
"C:\Program Files\R\R-3.6.0\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\03_SelfLearnM15.R"
"C:\Program Files\R\R-3.6.1\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\03_SelfLearnM15.R"
4 changes: 2 additions & 2 deletions _PROD/04_ScoreData15.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
:: Use this line of code for debugging purposes *** Adapt the paths for R installation and R script!!!
::"C:\Program Files\R\R-3.6.0\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\04_ScoreDataM15.R"
::"C:\Program Files\R\R-3.6.1\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\04_ScoreDataM15.R"
:: Use this code in 'production'
"C:\Program Files\R\R-3.6.0\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\04_ScoreDataM15.R
"C:\Program Files\R\R-3.6.1\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\04_ScoreDataM15.R
4 changes: 2 additions & 2 deletions _PROD/05_SelfLearn60.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
:: Use this line of code for debugging purposes *** Adapt the paths for R installation and R script!!!
::"C:\Program Files\R\R-3.6.0\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\05_SelfLearnM60.R"
::"C:\Program Files\R\R-3.6.1\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\05_SelfLearnM60.R"
:: Use this code in 'production'
"C:\Program Files\R\R-3.6.0\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\05_SelfLearnM60.R"
"C:\Program Files\R\R-3.6.1\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\05_SelfLearnM60.R"
4 changes: 2 additions & 2 deletions _PROD/06_ScoreData60.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
:: Use this line of code for debugging purposes *** Adapt the paths for R installation and R script!!!
::"C:\Program Files\R\R-3.6.0\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\06_ScoreDataM60.R"
::"C:\Program Files\R\R-3.6.1\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\06_ScoreDataM60.R"
:: Use this code in 'production'
"C:\Program Files\R\R-3.6.0\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\06_ScoreDataM60.R
"C:\Program Files\R\R-3.6.1\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\06_ScoreDataM60.R
45 changes: 45 additions & 0 deletions _PROD/08_CollectDataM15.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# ----------------------------------------------------------------------------------------
# R Script to collect the asset indicator data and respective 'future' price change
# ----------------------------------------------------------------------------------------
# (C) 2019 Vladimir Zhbanko
# https://www.udemy.com/self-learning-trading-robot/?couponCode=LAZYTRADE7-10
#
# load libraries to use and custom functions
library(tidyverse)
library(lubridate)
library(lazytrade)

#### Read asset prices and indicators ==========================================
#absolute path with the data (choose either MT4 directory or a '_TEST_DATA' folder)

path_terminal <- "C:/Program Files (x86)/FxPro - Terminal2/MQL4/Files/"
macd <- load_asset_data(path_terminal = path_terminal, trade_log_file = "AI_Macd", time_period = 15, data_deepth = "300")
prices <- load_asset_data(path_terminal = path_terminal, trade_log_file = "AI_CP", time_period = 15, data_deepth = "300")

path_data <- "C:/Users/fxtrams/Documents/000_TradingRepo/R_selflearning/_DATA"
# Vector of currency pairs
Pairs = c("EURUSD", "GBPUSD", "AUDUSD", "NZDUSD", "USDCAD", "USDCHF", "USDJPY",
"EURGBP", "EURJPY", "EURCHF", "EURNZD", "EURCAD", "EURAUD", "GBPAUD",
"GBPCAD", "GBPCHF", "GBPJPY", "GBPNZD", "AUDCAD", "AUDCHF", "AUDJPY",
"AUDNZD", "CADJPY", "CHFJPY", "NZDJPY", "NZDCAD", "NZDCHF", "CADCHF")

# Writing indicator and price change to the file
for (PAIR in Pairs) {
# PAIR <- "EURUSD"
# performing data collection using the custom function
aml_collect_data(price_dataset = prices,
indicator_dataset = macd,
symbol = PAIR,
num_bars = 75,
timeframe = 15,
path_data = path_data)

#full_path <- file.path(path_data, 'EURUSDM15X75.rds')
#full_path <- file.path(path_data, 'GBPUSDM15X75.rds')
#x1 <- read_rds(full_path)

}

# outcome is series of files written to the _DATA folder of the repository


5 changes: 5 additions & 0 deletions _PROD/08_CollectDataM15.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
:: Use this line of code for debugging purposes *** Adapt the paths for R installation and R script!!!
::"C:\Program Files\R\R-3.6.1\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\08_CollectDataM15.R"
:: Use this code in 'production'
"C:\Program Files\R\R-3.6.1\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\08_CollectDataM15.R"
5 changes: 5 additions & 0 deletions _PROD/09_MakeModel15.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
:: Use this line of code for debugging purposes *** Adapt the paths for R installation and R script!!!
::"C:\Program Files\R\R-3.6.1\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\09_MakeModelM15.R"
:: Use this code in 'production'
"C:\Program Files\R\R-3.6.1\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\09_MakeModelM15.R
43 changes: 43 additions & 0 deletions _PROD/09_MakeModelM15.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# ----------------------------------------------------------------------------------------
# R Script to build or update Deep Learning model for every Currency Pair
# ----------------------------------------------------------------------------------------
# (C) 2019 Vladimir Zhbanko
# https://www.udemy.com/self-learning-trading-robot/?couponCode=LAZYTRADE7-10
#
# load libraries to use and custom functions
library(tidyverse)
library(h2o)
library(lazytrade)

#### Read asset prices and indicators ==========================================
#absolute path with the data (choose either MT4 directory or a '_TEST_DATA' folder)
path_data <- "C:/Users/fxtrams/Documents/000_TradingRepo/R_selflearning/_DATA"
# Vector of currency pairs
Pairs = c("EURUSD", "GBPUSD", "AUDUSD", "NZDUSD", "USDCAD", "USDCHF", "USDJPY",
"EURGBP", "EURJPY", "EURCHF", "EURNZD", "EURCAD", "EURAUD", "GBPAUD",
"GBPCAD", "GBPCHF", "GBPJPY", "GBPNZD", "AUDCAD", "AUDCHF", "AUDJPY",
"AUDNZD", "CADJPY", "CHFJPY", "NZDJPY", "NZDCAD", "NZDCHF", "CADCHF")
#absolute path to store model objects (useful when scheduling tasks)
path_model <- "C:/Users/fxtrams/Documents/000_TradingRepo/R_selflearning/_MODELS"

h2o.init()

# Writing indicator and price change to the file
for (PAIR in Pairs) {
## PAIR <- "EURUSD"
# performing Deep Learning Regression using the custom function
aml_make_model(symbol = PAIR,
num_bars = 75,
timeframe = 15,
path_model = path_model,
path_data = path_data)

}

# stop h2o engine
h2o.shutdown(prompt = F)


# outcome are the models files for each currency pair written to the folder /_MODELS


50 changes: 50 additions & 0 deletions _PROD/10_ScoreDataM15.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ----------------------------------------------------------------------------------------
# R Script to score the latest asset indicator data against Deep Learning model
# ----------------------------------------------------------------------------------------
# (C) 2019 Vladimir Zhbanko
# https://www.udemy.com/self-learning-trading-robot/?couponCode=LAZYTRADE7-10
#
# load libraries to use and custom functions
library(tidyverse)
library(h2o)
library(lazytrade)

#### definition of paths and variables ==========================================
path_data <- "C:/Users/fxtrams/Documents/000_TradingRepo/R_selflearning/_DATA"
#absolute path to store model objects (useful when scheduling tasks)
path_model <- "C:/Users/fxtrams/Documents/000_TradingRepo/R_selflearning/_MODELS"
# load prices of 28 currencies
path_sbxm <- "C:/Program Files (x86)/FxPro - Terminal1/MQL4/Files"
path_sbxs <- "C:/Program Files (x86)/FxPro - Terminal3/MQL4/Files"

time_frame <- 15 #this is to define chart timeframe periodicity
predictor_period <- 75 #this variable will define market type period (number of bars)

# Vector of currency pairs
Pairs = c("EURUSD", "GBPUSD", "AUDUSD", "NZDUSD", "USDCAD", "USDCHF", "USDJPY",
"EURGBP", "EURJPY", "EURCHF", "EURNZD", "EURCAD", "EURAUD", "GBPAUD",
"GBPCAD", "GBPCHF", "GBPJPY", "GBPNZD", "AUDCAD", "AUDCHF", "AUDJPY",
"AUDNZD", "CADJPY", "CHFJPY", "NZDJPY", "NZDCAD", "NZDCHF", "CADCHF")

# initialize the virtual machine
h2o.init(nthreads = 1)

for (PAIR in Pairs) {
## PAIR <- "EURUSD"

aml_score_data(symbol = PAIR,
num_bars = predictor_period,
timeframe = time_frame,
path_model = path_model,
path_data = path_data,
path_sbxm = path_sbxm,
path_sbxs = path_sbxs)

}

# shutdown h2o
h2o.shutdown(prompt = F)

# outcome is series of files written to the sandboxes of each terminals


5 changes: 5 additions & 0 deletions _PROD/10_ScoreDataM15.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
:: Use this line of code for debugging purposes *** Adapt the paths for R installation and R script!!!
::"C:\Program Files\R\R-3.6.1\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\10_ScoreDataM15.R"
:: Use this code in 'production'
"C:\Program Files\R\R-3.6.1\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\10_ScoreDataM15.R
45 changes: 45 additions & 0 deletions _PROD/11_CollectDataM60.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# ----------------------------------------------------------------------------------------
# R Script to collect the asset indicator data and respective 'future' price change
# ----------------------------------------------------------------------------------------
# (C) 2019 Vladimir Zhbanko
# https://www.udemy.com/self-learning-trading-robot/?couponCode=LAZYTRADE7-10
#
# load libraries to use and custom functions
library(tidyverse)
library(lubridate)
library(lazytrade)

#### Read asset prices and indicators ==========================================
#absolute path with the data (choose either MT4 directory or a '_TEST_DATA' folder)

path_terminal <- "C:/Program Files (x86)/FxPro - Terminal2/MQL4/Files/"
macd <- load_asset_data(path_terminal = path_terminal, trade_log_file = "AI_Macd", time_period = 60, data_deepth = "300")
prices <- load_asset_data(path_terminal = path_terminal, trade_log_file = "AI_CP", time_period = 60, data_deepth = "300")

path_data <- "C:/Users/fxtrams/Documents/000_TradingRepo/R_selflearning/_DATA"
# Vector of currency pairs
Pairs = c("EURUSD", "GBPUSD", "AUDUSD", "NZDUSD", "USDCAD", "USDCHF", "USDJPY",
"EURGBP", "EURJPY", "EURCHF", "EURNZD", "EURCAD", "EURAUD", "GBPAUD",
"GBPCAD", "GBPCHF", "GBPJPY", "GBPNZD", "AUDCAD", "AUDCHF", "AUDJPY",
"AUDNZD", "CADJPY", "CHFJPY", "NZDJPY", "NZDCAD", "NZDCHF", "CADCHF")

# Writing indicator and price change to the file
for (PAIR in Pairs) {
# PAIR <- "EURUSD"
# performing data collection using the custom function
aml_collect_data(price_dataset = prices,
indicator_dataset = macd,
symbol = PAIR,
num_bars = 75,
timeframe = 60,
path_data = path_data)

#full_path <- file.path(path_data, 'EURUSDM15X75.rds')
#full_path <- file.path(path_data, 'GBPUSDM15X75.rds')
#x1 <- read_rds(full_path)

}

# outcome is series of files written to the _DATA folder of the repository


5 changes: 5 additions & 0 deletions _PROD/11_CollectDataM60.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
:: Use this line of code for debugging purposes *** Adapt the paths for R installation and R script!!!
::"C:\Program Files\R\R-3.6.1\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\11_CollectDataM60.R"
:: Use this code in 'production'
"C:\Program Files\R\R-3.6.1\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD\11_CollectDataM60.R"
48 changes: 48 additions & 0 deletions _PROD1/01_CollectDataM15.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ----------------------------------------------------------------------------------------
# R Script to collect the asset indicator data and respective 'future' price change
# ----------------------------------------------------------------------------------------
# (C) 2019 Vladimir Zhbanko
# https://www.udemy.com/self-learning-trading-robot/?couponCode=LAZYTRADE7-10
#
# load libraries to use and custom functions
#library(tidyverse)
library(magrittr)
library(dplyr)
library(readr)
library(lubridate)
library(lazytrade)

#### Read asset prices and indicators ==========================================
#absolute path with the data (choose either MT4 directory or a '_TEST_DATA' folder)

path_terminal <- "C:/Program Files (x86)/FxPro - Terminal2/MQL4/Files/"
macd <- load_asset_data(path_terminal = path_terminal, trade_log_file = "AI_Macd", time_period = 15, data_deepth = "300")
prices <- load_asset_data(path_terminal = path_terminal, trade_log_file = "AI_CP", time_period = 15, data_deepth = "300")

path_data <- "C:/Users/fxtrams/Documents/000_TradingRepo/R_selflearning/_DATA"
# Vector of currency pairs
Pairs = c("EURUSD", "GBPUSD", "AUDUSD", "NZDUSD", "USDCAD", "USDCHF", "USDJPY",
"EURGBP", "EURJPY", "EURCHF", "EURNZD", "EURCAD", "EURAUD", "GBPAUD",
"GBPCAD", "GBPCHF", "GBPJPY", "GBPNZD", "AUDCAD", "AUDCHF", "AUDJPY",
"AUDNZD", "CADJPY", "CHFJPY", "NZDJPY", "NZDCAD", "NZDCHF", "CADCHF")

# Writing indicator and price change to the file
for (PAIR in Pairs) {
# PAIR <- "EURUSD"
# performing data collection using the custom function
aml_collect_data(price_dataset = prices,
indicator_dataset = macd,
symbol = PAIR,
num_bars = 75,
timeframe = 15,
path_data = path_data)

#full_path <- file.path(path_data, 'EURUSDM15X75.rds')
#full_path <- file.path(path_data, 'GBPUSDM15X75.rds')
#x1 <- read_rds(full_path)

}

# outcome is series of files written to the _DATA folder of the repository


5 changes: 5 additions & 0 deletions _PROD1/01_CollectDataM15.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
:: Use this line of code for debugging purposes *** Adapt the paths for R installation and R script!!!
::"C:\Program Files\R\R-3.6.2\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD1\01_CollectDataM15.R"
:: Use this code in 'production'
"C:\Program Files\R\R-4.0.0\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD1\01_CollectDataM15.R"
5 changes: 5 additions & 0 deletions _PROD1/02_MakeModel15.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
:: Use this line of code for debugging purposes *** Adapt the paths for R installation and R script!!!
::"C:\Program Files\R\R-3.6.2\bin\R.exe" CMD BATCH "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD1\02_MakeModelM15.R"
:: Use this code in 'production'
"C:\Program Files\R\R-4.0.0\bin\Rscript.exe" "C:\Users\fxtrams\Documents\000_TradingRepo\R_selflearning\_PROD1\02_MakeModelM15.R"
Loading

0 comments on commit 868a138

Please sign in to comment.