Skip to content

Commit

Permalink
examples updated and default datetime changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzbr committed May 22, 2021
1 parent c67fe69 commit 010df79
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
^\.Rproj\.user$
^\.github$
^LICENSE\.md$
^README\.md$
4 changes: 2 additions & 2 deletions R/markets.R
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand All @@ -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) {

Expand Down
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
```
Expand Down
2 changes: 1 addition & 1 deletion man/markets.Rd

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

0 comments on commit 010df79

Please sign in to comment.