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 |
before |
An integer if datetime is |
after |
An integer if datetime is |
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 |
datetime |
A logical. |
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 |
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)