Skip to content

Commit

Permalink
Adapt crypto_history() function to accept modified lists as input for…
Browse files Browse the repository at this point in the history
… the coin retrieval e.g. gathered using a custom version of rypto_list().
  • Loading branch information
sstoeckl committed Mar 20, 2019
1 parent 0a415e2 commit 8d1e8dc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions R/crypto_history.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#' analysis on the crypto financial markets or to attempt
#' to predict future market movements or trends.
#'
#' @param coin string Name, symbol or slug of crypto currency, default is all tokens
#' @param coins string if NULL retrieve all currently existing coins (crypto_list()),
#' or provide list of crypto currencies in the crypto_list() format (e.g. current and dead coins since 2015)
#' @param limit integer Return the top n records, default is all tokens
#' @param start_date string Start date to retrieve data from, format 'yyyymmdd'
#' @param end_date string End date to retrieve data from, format 'yyyymmdd'
Expand Down Expand Up @@ -55,7 +56,7 @@
#'
#' @export
#'
crypto_history <- function(coin = NULL, limit = NULL, start_date = NULL, end_date = NULL,
crypto_history <- function(coins = NULL, limit = NULL, start_date = NULL, end_date = NULL,
coin_list = NULL, sleep = NULL) {
pink <- crayon::make_style(grDevices::rgb(0.93, 0.19, 0.65))
options(scipen = 999)
Expand All @@ -70,8 +71,8 @@ crypto_history <- function(coin = NULL, limit = NULL, start_date = NULL, end_dat
message("ERC-20: 0x375923Bf82F0b728d23A5704261a6e16341fd860", appendLF = TRUE)
message("XRP: rK59semLsuJZEWftxBFhWuNE6uhznjz2bK", appendLF = TRUE)
message("\n")
# only if no coin_list is provided
if (is.null(coin_list)) coins <- crypto_list(coin, start_date, end_date, coin_list)
# only if no coins are provided
if (is.null(coins)) coins <- crypto_list(coin, start_date, end_date, coin_list)

if (!is.null(limit))
coins <- coins[1:limit, ]
Expand Down
2 changes: 1 addition & 1 deletion R/crypto_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#' coin_list <- crypto_list()
#'
#' # return all coins listed in 2015
#' coins_list_2015 <- crypto_list(start_date_hist="20150101",end_date_hist="20151231",date_gap="months")
#' coin_list_2015 <- crypto_list(start_date_hist="20150101",end_date_hist="20151231",date_gap="months")
#'
#' }
#'
Expand Down
5 changes: 3 additions & 2 deletions man/crypto_history.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/crypto_list.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8d1e8dc

Please sign in to comment.