aml_collect_data: Function to read, transform, aggregate and save data for...

View source: R/aml_collect_data.R

aml_collect_dataR Documentation

Function to read, transform, aggregate and save data for further retraining of regression model for a single asset

Description

Function is collecting data from the csv files Data objects are transformed to be suitable for Regression Modelling. Price change will be in the column 'LABEL', column X1 will keep the time index Result will be written to a new or aggregated to the existing '.rds' file

Function is keeping generated dataset to be not larger than specified by the user

[Stable]

Usage

aml_collect_data(
  indicator_dataset,
  symbol,
  timeframe = 60,
  path_data,
  max_nrows = 2500
)

Arguments

indicator_dataset

Dataset containing assets indicator which pattern will be used as predictor

symbol

Character symbol of the asset for which to train the model

timeframe

Data timeframe e.g. 1 min

path_data

Path where the aggregated historical data is stored, if exists in rds format

max_nrows

Integer, Maximum number of rows to collect

Details

Function is not handling shift of the price and indicator datasets.

This function is relying on the data collection from the dedicated data robot Other 'aml_*' functions will work based on the data processed by this function

Value

Function is writing files into Decision Support System folder, mainly file object with the model

Author(s)

(C) 2020, 2021 Vladimir Zhbanko

Examples


# write examples for the function
library(dplyr)
library(readr)
library(lubridate)
library(lazytrade)
library(magrittr)

# sample dataset
ind = system.file("extdata", "AI_RSIADXUSDJPY60.csv",
                  package = "lazytrade") %>% read_csv(col_names = FALSE)

# convert to POSIX format
ind$X1 <- ymd_hms(ind$X1)

# create temporary path (check output of tempdir() to check the result)
path_data <- normalizePath(tempdir(),winslash = "/")

# add tick data to the folder
tick = system.file("extdata", "TickSize_AI_RSIADX.csv",
                  package = "lazytrade") %>% read_csv(col_names = FALSE)

write_csv(tick, file.path(path_data, "TickSize_AI_RSIADX.csv"), col_names = FALSE)


# data transformation using the custom function for one symbol
aml_collect_data(indicator_dataset = ind,
                 symbol = 'USDJPY',
                 timeframe = 60,
                 path_data = path_data)



lazytrade documentation built on Sept. 12, 2024, 9:36 a.m.