get_ohlc | R Documentation |
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.
get_ohlc(pair, before = NULL, after = NULL, periods = NULL, exchange = "kraken", datetime = TRUE, api_key = NULL, allowance = FALSE)
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, 3600, 86400. See https://docs.cryptowat.ch/rest-api/markets/ohlc#period-values for complete information. |
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 |
A data.frame containing OHLC candlestick prices of a given pair of
currencies. If allowance is TRUE
, get_ohlc()
returns a list.
See https://docs.cryptowat.ch/rest-api for further information.
get_markets
, get_assets
,
get_exchanges
, get_pairs
## 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 = as.numeric(as.POSIXct(Sys.Date())), after = as.numeric(as.POSIXct(Sys.Date() - 5)), 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.