Skip to content

Commit

Permalink
Cleaned up codes
Browse files Browse the repository at this point in the history
Removed unnecessary codes in helpers and utils
  • Loading branch information
serkor1 committed Dec 9, 2023
1 parent 3a8aad0 commit f978f53
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 138 deletions.
138 changes: 0 additions & 138 deletions R/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,81 +5,6 @@
# function
# script start;



constructInterval <- function(source, futures, interval) {

# 1) construct the interval
interval <- get(
paste0(source, 'Intervals')
)(
futures = futures,
interval = interval
)

# 2) return the interval
return(
interval
)

}



# check_interval <- function(
# interval
# ) {
#
# indicator <- grepl(
# pattern = paste0(
# collapse = '|',
# available_intervals()
# ),
# x = interval
# )
#
# if (!indicator) {
#
# rlang::abort(
# message = paste0('Chosen interval: "', interval, '" is not available.'),
# body = 'Use availableIntervals()-function to see a full list.',
# call = NULL
# )
#
# }
#
#
# }




convert_date <- function(
input
) {

# Was:
# format(
# as.numeric(
# as.POSIXct(to,tz = 'UTC'
# )
# ) * 1e3,
# cientific = FALSE
# )

as.POSIXct(
as.numeric(input)/1e3,
origin = '1970-01-01'
)



}





# generate data;
# this data is for the purpose of presenting
# and error-testing
Expand Down Expand Up @@ -184,69 +109,6 @@ generate_data <- function(
}






convertIndicator <- function(indicator) {

# 1) convert indicator
# list.wise
indicator <- as.list(
indicator
)

# 2) extract names
# from the list
indicator_names <- names(
indicator
)

# 3) convert the
# list to a long
# data.frame
indicator <- do.call(
rbind,
lapply(
X = seq_along(indicator_names),
FUN = function(i) {

# 1) store the values
# in a variable
x <- indicator[[i]]

# 2) set column name
# to value
colnames(x) <- 'value'

# 3) convert to
# data.frame
x <- toDF(
x
)

# 4) add label
# to the data
x$label <- indicator_names[i]

return(
x
)

}

)
)



return(
indicator
)

}


toDF <- function(quote) {


Expand Down
19 changes: 19 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@



constructInterval <- function(source, futures, interval) {

# 1) construct the interval
interval <- get(
paste0(source, 'Intervals')
)(
futures = futures,
interval = interval
)

# 2) return the interval
return(
interval
)

}



# base-url;
baseUrl <- function(
source = 'binance',
Expand Down

0 comments on commit f978f53

Please sign in to comment.