diff --git a/.Rbuildignore b/.Rbuildignore index 1071d3c..f074592 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -2,3 +2,4 @@ ^\.Rproj\.user$ ^\.github$ ^LICENSE\.md$ +^README\.md$ diff --git a/R/markets.R b/R/markets.R index 493c34e..b7adcc1 100644 --- a/R/markets.R +++ b/R/markets.R @@ -2,7 +2,7 @@ #' #' Get data.frame with prices for cryptocurrencies using the REST API of cryptowat.ch. #' -#' @usage markets(pair, params = NULL, exchange = "kraken", route = "ohlc", datetime = FALSE) +#' @usage markets(pair, params = NULL, exchange = "kraken", route = "ohlc", datetime = TRUE) #' @param pair A string containing a pair symbol, e.g. \emph{btcusd} (required argument). #' @param params A list containing \code{before}, \code{after} and \code{periods} (optional). See \url{https://docs.cryptowat.ch/rest-api/markets/ohlc} for further information. #' @param exchange A string containing the exchange. Default is \emph{kraken}. @@ -23,7 +23,7 @@ #' } #' #' @export -markets <- function(pair, params = NULL, exchange = "kraken", route = "ohlc", datetime = FALSE) { +markets <- function(pair, params = NULL, exchange = "kraken", route = "ohlc", datetime = TRUE) { if (datetime) { diff --git a/README.md b/README.md index 580af4d..8505fa5 100644 --- a/README.md +++ b/README.md @@ -31,30 +31,43 @@ devtools::install_github("lorenzbr/cryptowatchR@main") ## Usage ```R -# Examples +## Examples +# Set parameters exchange <- "kraken" pair <- "btcusd" route <- "ohlc" +# Get daily prices for longest possible time period params1 <- list(periods = 86400) +df.markets1 <- cryptowatchR::get_markets(pair, params1, exchange = "kraken", route = "ohlc") + +# Get hourly prices params2 <- list(periods = 3600, before = 1609851600, after = 1609506000) +df.markets2 <- cryptowatchR::markets(pair, params2, exchange = "kraken", route = "ohlc", datetime = FALSE) + +# Get hourly prices using date/datetime variables params3 <- list(periods = 3600, before = "2021-01-05", after = "2021-01-01") +df.markets3 <- cryptowatchR::markets(pair, params3, exchange = "kraken", route = "ohlc", datetime = TRUE) + +# Get daily prices using date/datetime variables params4 <- list(periods = 86400, before = "2021-05-12", after = "2021-01-01") +df.markets4 <- cryptowatchR::markets(pair, params4, exchange = "kraken", route = "ohlc", datetime = TRUE) + +# Get daily prices using POSIX time params5 <- list(periods = 86400, before = as.numeric(as.POSIXct("2021-05-12 14:00:00 UCT")), after = as.numeric(as.POSIXct("2021-01-01 14:00:00 UCT"))) -df.markets1 <- cryptowatchR::get_markets(pair, params1, exchange = "kraken", route = "ohlc") -df.markets2 <- cryptowatchR::markets(pair, params2, exchange = "kraken", route = "ohlc", datetime = FALSE) -df.markets3 <- cryptowatchR::markets(pair, params3, exchange = "kraken", route = "ohlc", datetime = TRUE) -df.markets4 <- cryptowatchR::markets(pair, params4, exchange = "kraken", route = "ohlc", datetime = TRUE) df.markets5 <- cryptowatchR::markets(pair, params5, exchange = "kraken", route = "ohlc", datetime = FALSE) +# Get asset information asset.data <- cryptowatchR::get_assets("btc") df.assets <- cryptowatchR::get_assets() +# Get information on pairs of currencies btcusd.data <- cryptowatchR::get_pairs("btcusd") df.pairs <- cryptowatchR::get_pairs() +# Get information on crypto exchanges exchange.data <- cryptowatchR::get_exchanges("kraken") df.exchanges <- cryptowatchR::get_exchanges() ``` diff --git a/man/markets.Rd b/man/markets.Rd index e6e99f5..8305fac 100644 --- a/man/markets.Rd +++ b/man/markets.Rd @@ -4,7 +4,7 @@ \alias{markets} \title{Get prices for cryptocurrencies} \usage{ -markets(pair, params = NULL, exchange = "kraken", route = "ohlc", datetime = FALSE) +markets(pair, params = NULL, exchange = "kraken", route = "ohlc", datetime = TRUE) } \arguments{ \item{pair}{A string containing a pair symbol, e.g. \emph{btcusd} (required argument).}