get_ohlc {cryptowatchR}R Documentation

Get prices of cryptocurrencies

Description

Get data.frame with prices of cryptocurrencies using the REST API of cryptowat.ch. The route is ohlc and returns OHLC candlestick prices. The default is daily prices but can be changed with periods. See https://docs.cryptowat.ch/rest-api/markets/ohlc for further information.

Usage

get_ohlc(pair, before = NULL, after = NULL, periods = NULL, exchange = "kraken",
         datetime = TRUE, api_key = NULL, allowance = FALSE)

Arguments

pair

A character string containing a pair symbol, e.g. btcusd (required argument). Run get_pairs() to find other available pairs.

before

An integer if datetime is FALSE and a character string if it is TRUE: Only returns candles opening before this time (optional).

after

An integer if datetime is FALSE and a character string if it is TRUE: Only returns candles opening after this time (optional).

periods

A integer or integer vector. Only return these periods. Periods are measured in seconds (optional). Examples: 60, 180, 108000.

exchange

A character string containing the exchange. Default is kraken. Run get_exchanges() to find other available exchanges.

datetime

A logical. TRUE indicates that datetime type is used. FALSE indicates unix timestamp. Default is TRUE.

api_key

A character string containing the API key. See https://docs.cryptowat.ch/rest-api/rate-limit to learn how to create an account and how to generate an API key.

allowance

A logical (default is FALSE). If TRUE the function returns a list which includes allowance information, i.e. cost of the request, remaining credits and your account name.

Value

A data.frame containing OHLC candlestick prices of a given pair of currencies. If allowance is TRUE, get_ohlc() returns a list.

References

See https://docs.cryptowat.ch/rest-api for further information.

See Also

get_markets, get_assets, get_exchanges, get_pairs

Examples

## Not run: 
# Daily prices of Bitcoin in USD
df.ohlc <- get_ohlc("btcusd")
# Hourly prices of Bitcoin in USD for a specific time period
df.ohlc.hourly <- get_ohlc("btcusd", periods = 3600, before = 1609851600,
                                          after = 1609506000, datetime = FALSE)
# Daily prices of Bitcoin in Euro for a specific time period
df.ohlc.daily <- get_ohlc("btceur", periods = 86400, before = "2021-05-12",
                                          after = "2021-01-01", datetime = TRUE)

## End(Not run)


[Package cryptowatchR version 0.2.0 Index]