diff --git a/NAMESPACE b/NAMESPACE index 52ec9da..ac82cdf 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -15,7 +15,6 @@ export(encrypt_api_key) export(evaluate_macroeconomic_event) export(get_profit_factorDF) export(import_data) -export(load_asset_data) export(mt_evaluate) export(mt_import_data) export(mt_make_model) diff --git a/NEWS.md b/NEWS.md index ea84c1f..d42f331 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,8 +11,9 @@ ## Changes -* add simulation function `aml_simulation` designed to test different inputs -* some other minor changes +### New Function `aml_simulation` + +* designed to test different inputs ### Function `aml_make_model` @@ -21,11 +22,11 @@ * add parameter to split data with specific n of rows * add parameter num_bars_ahead, default is 34 bars * add options for deep learning function parameters search, `num_epochs`, `fixed_nn_struct` -* add option `objective_test` to allow strategy test inside the function to select best model +* add option `objective_test` to allow strategy test inside the function to select best model based on specific objective ### Function `aml_collect_data` -* more accurate calculation of Label column +* more accurate calculation of Label column using tick data * added fail safe scenarios # lazytrade 0.4.5 diff --git a/R/load_asset_data.R b/R/load_asset_data.R deleted file mode 100644 index ac6a752..0000000 --- a/R/load_asset_data.R +++ /dev/null @@ -1,85 +0,0 @@ -#' Load and Prepare Asset Data -#' -#' @description Function imports file with financial asset data. Each column represent one asset, rows represent observations. -#' Values in specific columns will be normalized by dividing them by 100. This is specifically done for pairs with JPY. -#' In addition, X1 column will be converted to the ymd_hms format -#' -#' `r lifecycle::badge('deprecated')` -#' -#' @details Works for both price and indicator values, function parameters allowing to import different files. -#' File names are selected to account different time periodicity and amount of the data -#' -#' @param path_terminal - path to the MT4 terminal, string -#' @param trade_log_file - csv file name where the data is stored, without ".csv" -#' @param time_period - data periodicity in minutes, can be 1, 15, 60 -#' @param data_deepth - collected data deepth in rows. describe how many rows in original file to read -#' -#' @return - dataframe with asset data in columns where X1 column is in a POSIXct format -#' @export -#' -#' @examples -#' -#' library(readr) -#' library(dplyr) -#' library(lubridate) -#' library(magrittr) -#' library(lazytrade) -#' path_terminal <- system.file("extdata", package = "lazytrade") -#' -#' # load and prepare prices data -#' prices <- load_asset_data(path_terminal = path_terminal, -#' trade_log_file = "AI_CP", -#' time_period = 60, -#' data_deepth = "300") -#' -#' # load and prepare indicator data -#' macd <- load_asset_data(path_terminal = path_terminal, -#' trade_log_file = "AI_Macd", -#' time_period = 60, -#' data_deepth = "300") -#' -#' -load_asset_data <- function(path_terminal, trade_log_file, time_period = 1, data_deepth = 50000){ - - requireNamespace("readr", quietly = TRUE) - requireNamespace("lubridate", quietly = TRUE) - - lifecycle::deprecate_warn( - "0.4.5", - "load_asset_data()", - details = "This function is not used." - ) - - - DFT1 <- try(readr::read_csv(file = file.path(path_terminal, paste0(trade_log_file, time_period, "-", data_deepth, ".csv")), - col_names = F), - silent = TRUE) - if(class(DFT1)[1] == "try-error") {stop("Error reading file. File with trades may not exist yet!", - call. = FALSE)} - #add one column filled with zeroes DFT1$X3 <- 0 - #detect if some columns are filled with zeroes... - Z_detect <- lapply(DFT1, function(x) all(x == 0)) %>% as.data.frame() - #evaluate results, if any values are equal to 0 provide a warning - if(any(Z_detect == TRUE)){warning("Warning, one or more columns in the datafile contains zeroes")} - - if(!nrow(DFT1)==0){ - # data frame preparation - DFT1$X1 <- lubridate::ymd_hms(DFT1$X1) - if(trade_log_file == "AI_CP"){ - ## divide JPY pairs by 100 - DFT2 <- DFT1[ , c(8,10,18,22,24,25,26)]/100 - DFT3 <- DFT1[, -c(8,10,18,22,24,25,26)] %>% - dplyr::bind_cols(DFT2) %>% - dplyr::select(1,2,3,4,5,6,7,8, - 9,10,11,12,13,14,15, - 16,17,18,19,20,21,22, - 23,24,25,26,27,28,29) - return(DFT3) - } - - return(DFT1) - } else { - stop("Data log is empty!", call. = FALSE) - } - -} diff --git a/R/opt_aggregate_results.R b/R/opt_aggregate_results.R index ac7f298..6988e68 100644 --- a/R/opt_aggregate_results.R +++ b/R/opt_aggregate_results.R @@ -1,9 +1,9 @@ #' Function to aggregate trading results from multiple folders and files #' -#' @description PURPOSE: Read multiple '.csv' files stored in different folders +#' @description Read multiple '.csv' files stored in different folders #' Store results to the intermediate dataframe. #' -#' `r lifecycle::badge('stable')` +#' `r lifecycle::badge('deprecated')` #' #' @details user must provide the path to the files in the folders #' all files in subfolders are read and aggregated into one data object. @@ -28,13 +28,17 @@ #' file.copy(from = system.file("extdata/RES", package = "lazytrade"), #' to = dir, recursive = TRUE) #' -#' -#' #' DF_RES <- opt_aggregate_results(path_data = file.path(dir, "RES")) #' #' opt_aggregate_results <- function(path_data){ + + lifecycle::deprecate_warn(when = "0.5.1", + what = "opt_aggregate_results()", + details = "This function is not used." + ) + # folders with results # join paths into a vector DFOLDER <- dir(path_data, full.names = TRUE) diff --git a/README.Rmd b/README.Rmd index e0c9aa3..947a7f1 100644 --- a/README.Rmd +++ b/README.Rmd @@ -367,6 +367,15 @@ and we check that there is nothing more remained: dir("/tmp/*.csv") ``` +### Delete deprecate functions + +To remove function from the package we can use: + +* Delete function from the folder (careful not to break other functions) +* Build -> More -> Document +* Build -> More -> Clean and Rebuild +* Build -> Check + ## CRAN Submission Tips and Tricks ### Many notes while using global variables: @@ -471,10 +480,16 @@ It's important to avoid that function write to the directory other then `tempdir Construct file name must be done using `file.name()` function as follow: ```{r} +# use plane temp directory dir_name <- normalizePath(tempdir(),winslash = "/") file_name <- paste0('my_file', 1, '.csv') # this needs to be used in the function full_path <- file.path(dir_name, file_name) + +# when using sub-directory +sub_dir <- file.path(dir_name, "_SUB") +if(!dir.exists(sub_dir)){dir.create(sub_dir)} + ``` @@ -501,9 +516,11 @@ Clone package from GitHub and test check it in Docker Container `usethis::use_readme_rmd()` -## Automatic check with Travis +## Automatic check with GitHub Actions + +`usethis::use_github_action()` -`usethis::use_travis()` +To be elaborated ## Upload package to CRAN @@ -520,38 +537,30 @@ then: `devtools::release()` ### before release checks + spelling `devtools::spell_check()` -checking on R hub -`rhub::validate_email()` -`rhub::check( - platform="windows-x86_64-devel", - env_vars=c(R_COMPILE_AND_INSTALL_PACKAGES = "always") -)` - -```{r eval=FALSE, include=FALSE} -rhub::check_on_fedora(show_status = FALSE, - env_vars=c(R_COMPILE_AND_INSTALL_PACKAGES = "always")) -``` - +#### checking on R hub -`devtools::check_rhub(interactive = F)` +https://builder.r-hub.io/ -checking with release +#### checking with release `devtools::check_win_release()` -checking win devel +#### checking win devel `devtools::check_win_devel()` -checking win old devel +#### checking win old devel `devtools::check_win_oldrelease()` -check with rocker R in container +#### check with rocker R in container - use docker image with R Studio, - clone repo, build, check package... -Update news.md file +### Update news.md file + +Explain the changes ### uploading the package archive to CRAN https://cran.r-project.org/submit.html diff --git a/README.md b/README.md index d4f5bd8..eb2eca9 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,8 @@ library(readr) #generate 8digit password for trading platform util_generate_password(salt = 'random text') +#> . +#> 1 8a289ED5 ``` ## Example - generate initialization files for MT4 platform @@ -423,6 +425,16 @@ and we check that there is nothing more remained: dir("/tmp/*.csv") ``` +### Delete deprecate functions + +To remove function from the package we can use: + +- Delete function from the folder (careful not to break other + functions) +- Build -> More -> Document +- Build -> More -> Clean and Rebuild +- Build -> Check + ## CRAN Submission Tips and Tricks ### Many notes while using global variables: @@ -471,10 +483,15 @@ It’s important to avoid that function write to the directory other then function as follow: ``` r +# use plane temp directory dir_name <- normalizePath(tempdir(),winslash = "/") file_name <- paste0('my_file', 1, '.csv') # this needs to be used in the function full_path <- file.path(dir_name, file_name) + +# when using sub-directory +sub_dir <- file.path(dir_name, "_SUB") +if(!dir.exists(sub_dir)){dir.create(sub_dir)} ``` ## Versioning of the package @@ -500,9 +517,11 @@ Clone package from GitHub and test check it in Docker Container `usethis::use_readme_rmd()` -## Automatic check with Travis +## Automatic check with GitHub Actions + +`usethis::use_github_action()` -`usethis::use_travis()` +To be elaborated ## Upload package to CRAN @@ -522,21 +541,30 @@ then: spelling `devtools::spell_check()` -checking on R hub `rhub::validate_email()` -`rhub::check( platform="windows-x86_64-devel", env_vars=c(R_COMPILE_AND_INSTALL_PACKAGES = "always") )` +#### checking on R hub + + + +#### checking with release + +`devtools::check_win_release()` + +#### checking win devel + +`devtools::check_win_devel()` -`devtools::check_rhub(interactive = F)` +#### checking win old devel -checking with release `devtools::check_win_release()` +`devtools::check_win_oldrelease()` -checking win devel `devtools::check_win_devel()` +#### check with rocker R in container -checking win old devel `devtools::check_win_oldrelease()` +- use docker image with R Studio, +- clone repo, build, check package… -check with rocker R in container - use docker image with R Studio, - -clone repo, build, check package… +### Update news.md file -Update news.md file +Explain the changes ### uploading the package archive to CRAN diff --git a/man/load_asset_data.Rd b/man/load_asset_data.Rd deleted file mode 100644 index dd27108..0000000 --- a/man/load_asset_data.Rd +++ /dev/null @@ -1,69 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/load_asset_data.R -\name{load_asset_data} -\alias{load_asset_data} -\title{Load and Prepare Asset Data} -\usage{ -load_asset_data( - path_terminal, - trade_log_file, - time_period = 1, - data_deepth = 50000 -) -} -\arguments{ -\item{path_terminal}{\itemize{ -\item path to the MT4 terminal, string -}} - -\item{trade_log_file}{\itemize{ -\item csv file name where the data is stored, without ".csv" -}} - -\item{time_period}{\itemize{ -\item data periodicity in minutes, can be 1, 15, 60 -}} - -\item{data_deepth}{\itemize{ -\item collected data deepth in rows. describe how many rows in original file to read -}} -} -\value{ -\itemize{ -\item dataframe with asset data in columns where X1 column is in a POSIXct format -} -} -\description{ -Function imports file with financial asset data. Each column represent one asset, rows represent observations. -Values in specific columns will be normalized by dividing them by 100. This is specifically done for pairs with JPY. -In addition, X1 column will be converted to the ymd_hms format - -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} -} -\details{ -Works for both price and indicator values, function parameters allowing to import different files. -File names are selected to account different time periodicity and amount of the data -} -\examples{ - -library(readr) -library(dplyr) -library(lubridate) -library(magrittr) -library(lazytrade) -path_terminal <- system.file("extdata", package = "lazytrade") - -# load and prepare prices data -prices <- load_asset_data(path_terminal = path_terminal, - trade_log_file = "AI_CP", - time_period = 60, - data_deepth = "300") - -# load and prepare indicator data -macd <- load_asset_data(path_terminal = path_terminal, - trade_log_file = "AI_Macd", - time_period = 60, - data_deepth = "300") - - -} diff --git a/man/opt_aggregate_results.Rd b/man/opt_aggregate_results.Rd index 0d35613..857b9c9 100644 --- a/man/opt_aggregate_results.Rd +++ b/man/opt_aggregate_results.Rd @@ -15,10 +15,10 @@ opt_aggregate_results(path_data) Dataframe with trading results } \description{ -PURPOSE: Read multiple '.csv' files stored in different folders +Read multiple '.csv' files stored in different folders Store results to the intermediate dataframe. -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \details{ user must provide the path to the files in the folders @@ -38,8 +38,6 @@ Data object is sorted in descending order by order close time file.copy(from = system.file("extdata/RES", package = "lazytrade"), to = dir, recursive = TRUE) - - DF_RES <- opt_aggregate_results(path_data = file.path(dir, "RES"))