Title: | An API Wrapper for 'Cryptowatch' |
---|---|
Description: | An API wrapper for 'Cryptowatch' to get prices and other information (e.g., volume, trades, order books, bid and ask prices, live quotes, and more) about cryptocurrencies and crypto exchanges. See <https://docs.cryptowat.ch/rest-api> for a detailed documentation. |
Authors: | Lorenz Brachtendorf [aut, cre] |
Maintainer: | Lorenz Brachtendorf <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.0.9000 |
Built: | 2024-11-13 04:13:27 UTC |
Source: | https://github.com/lorenzbr/cryptowatchr |
Get asset information on cryptocurrencies.
get_assets(asset = NULL, api_key = NULL, allowance = FALSE)
get_assets(asset = NULL, api_key = NULL, allowance = FALSE)
asset |
A string containing an asset symbol, e.g. btc
(optional argument). Run |
api_key |
A 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 list or data frame containing data on assets.
See https://docs.cryptowat.ch/rest-api for further information
get_markets
, get_exchanges
,
get_pairs
## Not run: # Get all assets available on 'Cryptowatch' df_assets <- get_assets() # Bitcoin asset details asset_btc <- get_assets("btc") ## End(Not run)
## Not run: # Get all assets available on 'Cryptowatch' df_assets <- get_assets() # Bitcoin asset details asset_btc <- get_assets("btc") ## End(Not run)
Get current price of cryptocurrencies using the REST API of cryptowat.ch. The route is price or prices and returns the current price of a given pair or current prices of all pairs. See https://docs.cryptowat.ch/rest-api/markets/price for further information.
get_current_price(pair, exchange = "kraken", api_key = NULL, allowance = FALSE)
get_current_price(pair, exchange = "kraken", api_key = NULL, allowance = FALSE)
pair |
A string containing a pair symbol, e.g. btcusd (required
argument). Run |
exchange |
A string containing the exchange. Default is kraken.
Run |
api_key |
A 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 |
Current price of a given pair of currencies. If allowance is
TRUE
, get_current_price()
returns a list.
See https://docs.cryptowat.ch/rest-api for further information.
get_markets
, get_ohlc
,
get_exchanges
, get_pairs
## Not run: # Daily prices of Bitcoin in USD current_price <- get_current_price("btcusd") current_prices <- get_current_price() ## End(Not run)
## Not run: # Daily prices of Bitcoin in USD current_price <- get_current_price("btcusd") current_prices <- get_current_price() ## End(Not run)
Get information on exchanges.
get_exchanges(exchange = NULL, api_key = NULL, allowance = FALSE)
get_exchanges(exchange = NULL, api_key = NULL, allowance = FALSE)
exchange |
A string containing an exchange symbol, e.g. kraken
(optional argument). Run |
api_key |
A 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 list or data frame containing data on exchanges.
See https://docs.cryptowat.ch/rest-api for further information
get_markets
, get_assets
, get_pairs
## Not run: # Get all available exchanges df_exchanges <- get_exchanges() # Get information on the exchange Kraken exchange_kraken <- get_exchanges("kraken") ## End(Not run)
## Not run: # Get all available exchanges df_exchanges <- get_exchanges() # Get information on the exchange Kraken exchange_kraken <- get_exchanges("kraken") ## End(Not run)
Get prices of cryptocurrencies using the REST API of cryptowat.ch.
get_markets(route, pair = NULL, exchange = NULL, params = NULL, api_key = NULL, allowance = FALSE)
get_markets(route, pair = NULL, exchange = NULL, params = NULL, api_key = NULL, allowance = FALSE)
route |
A character string containing a market endpoint. Possible values: price, prices, trades, summary, summaries, orderbook, orderbook/liquidity, orderbooks/calculator, ohlc (required argument). See https://docs.cryptowat.ch/rest-api/markets for further information. |
pair |
A character string containing a pair symbol, e.g. btcusd
(optional argument). Run |
exchange |
A character string containing the exchange (optional argument).
Run |
params |
A list containing query parameters. E.g., for the route
ohlc, this is |
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 list containing markets data.
See https://docs.cryptowat.ch/rest-api for further information
markets
, get_assets
,
get_exchanges
, get_pairs
## Not run: # Prices of Bitcoin in USD for all periods btcusd_ohlc_all <- get_markets(route = "ohlc", pair = "btcusd", exchange = "kraken") # Hourly prices of Bitcoin in USD for a specific time period btcusd_ohlc_hourly <- get_markets(route = "ohlc", pair = "btcusd", exchange = "kraken", list(periods = 3600, before = as.numeric(as.POSIXct(Sys.Date())), after = as.numeric(as.POSIXct(Sys.Date() - 5)))) ## End(Not run)
## Not run: # Prices of Bitcoin in USD for all periods btcusd_ohlc_all <- get_markets(route = "ohlc", pair = "btcusd", exchange = "kraken") # Hourly prices of Bitcoin in USD for a specific time period btcusd_ohlc_hourly <- get_markets(route = "ohlc", pair = "btcusd", exchange = "kraken", list(periods = 3600, before = as.numeric(as.POSIXct(Sys.Date())), after = as.numeric(as.POSIXct(Sys.Date() - 5)))) ## End(Not run)
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)
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)
## 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)
Get the order book of cryptocurrencies using the REST API of cryptowat.ch. The route is orderbook and returns two arrays, bids and asks. See https://docs.cryptowat.ch/rest-api/markets/order-book for further information.
get_orderbook(pair, depth = NULL, span = NULL, limit = NULL, exchange = "kraken", api_key = NULL, allowance = FALSE)
get_orderbook(pair, depth = NULL, span = NULL, limit = NULL, exchange = "kraken", api_key = NULL, allowance = FALSE)
pair |
A string containing a pair symbol, e.g. btcusd (required
argument). Run |
depth |
A number: Only return orders cumulating up to this size (optional). |
span |
A number: Only return orders within this percentage of the midpoint (optional). Example: 0.5 (meaning 0.5 percent). |
limit |
An integer limiting the number of orders on each side of the book (optional). |
exchange |
A character string containing the exchange. Default is
kraken. Run |
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 list containing an order book of a given pair of currencies. It
contain two data frames for bid and ask prices with columns Price and
Amount. The function also returns the sequence number seqNum.
If allowance is TRUE
, get_orderbook()
returns a list which
additionally includes allowance information.
See https://docs.cryptowat.ch/rest-api for further information.
get_markets
, get_orderbook_liquidity
,
get_exchanges
, get_pairs
## Not run: # Entire order book of Bitcoin in USD orderbook <- get_orderbook("btcusd") # Order book of Bitcoin in USD: only the best bid and best ask, i.e. the spread orderbook_limit <- get_orderbook("btcusd", limit = 1) # Order book of Bitcoin in USD for orders within 0.5% of the top of the book orderbook_span <- get_orderbook("btcusd", span = 0.5) # Order book of Bitcoin in Euro for orders adding up to 100 BTC on each side orderbook_depth <- get_orderbook("btceur", depth = 100) ## End(Not run)
## Not run: # Entire order book of Bitcoin in USD orderbook <- get_orderbook("btcusd") # Order book of Bitcoin in USD: only the best bid and best ask, i.e. the spread orderbook_limit <- get_orderbook("btcusd", limit = 1) # Order book of Bitcoin in USD for orders within 0.5% of the top of the book orderbook_span <- get_orderbook("btcusd", span = 0.5) # Order book of Bitcoin in Euro for orders adding up to 100 BTC on each side orderbook_depth <- get_orderbook("btceur", depth = 100) ## End(Not run)
Get a live quote from the order book for a given buy and sell amount. The route is orderbook/calculator and returns two data.frames containing buy and sell projections. See https://docs.cryptowat.ch/rest-api/markets/order-book for further information.
get_orderbook_calculator(pair, amount = NULL, exchange = "kraken", api_key = NULL, allowance = FALSE)
get_orderbook_calculator(pair, amount = NULL, exchange = "kraken", api_key = NULL, allowance = FALSE)
pair |
A string containing a pair symbol, e.g. btcusd
(required argument). Run |
amount |
A number: Amount to buy or sell (required). |
exchange |
A character string containing the exchange. Default is
kraken. Run |
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 list containing projections for the buy and sell side for a given
amount. Reach indicates the farthest your reach would fill.
Avg indicates the volume-weighted average. If allowance is
TRUE
, get_orderbook_calculator()
returns a list which
additionally includes allowance information.
See https://docs.cryptowat.ch/rest-api for further information.
get_markets
, get_orderbook
,
get_orderbook_liquidity
, get_exchanges
,
get_pairs
## Not run: # Live quote for 50 Bitcoins calculator <- get_orderbook_calculator("btcusd", amount = 50) ## End(Not run)
## Not run: # Live quote for 50 Bitcoins calculator <- get_orderbook_calculator("btcusd", amount = 50) ## End(Not run)
Get liquidity sums in the order book of cryptocurrencies using the REST API of cryptowat.ch. The route is orderbook/liquidity. See https://docs.cryptowat.ch/rest-api/markets/order-book for further information.
get_orderbook_liquidity(pair, exchange = "kraken", api_key = NULL, allowance = FALSE)
get_orderbook_liquidity(pair, exchange = "kraken", api_key = NULL, allowance = FALSE)
pair |
A character string containing a pair symbol, e.g. btcusd
(required argument). Run |
exchange |
A character string containing the exchange. Default is
kraken. Run |
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 list containing liquidity sums at several basis point levels in
the order book. If allowance is TRUE
, get_orderbook()
returns
a list which additionally includes allowance information.
See https://docs.cryptowat.ch/rest-api for further information.
get_markets
, get_orderbook
,
get_exchanges
, get_pairs
## Not run: # Get liquidity sums in the order book of Bitcoin in USD liquidity <- get_orderbook_liquidity("btcusd") ## End(Not run)
## Not run: # Get liquidity sums in the order book of Bitcoin in USD liquidity <- get_orderbook_liquidity("btcusd") ## End(Not run)
Get details on pairs of (crypto)currencies.
get_pairs(pair = NULL, api_key = NULL, allowance = FALSE)
get_pairs(pair = NULL, api_key = NULL, allowance = FALSE)
pair |
A string containing a pair symbol, e.g. btcusd (optional
argument). Run |
api_key |
A 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 list or data.frame containing data on pairs.
See https://docs.cryptowat.ch/rest-api for further information
get_markets
, get_assets
,
get_exchanges
## Not run: # Get all available pairs of currencies df_pairs <- get_pairs() # Get details on the pair Bitcoin-USD pair_btcusd <- get_pairs("btcusd") ## End(Not run)
## Not run: # Get all available pairs of currencies df_pairs <- get_pairs() # Get details on the pair Bitcoin-USD pair_btcusd <- get_pairs("btcusd") ## End(Not run)
Get 24-hour summary of cryptocurrencies using the REST API of cryptowat.ch. The route is summary or summaries and returns the current 24-hour summary of a given pair or a summary of all pairs. See https://docs.cryptowat.ch/rest-api/markets/summary for further information.
get_summary(pair, keyBy = NULL, exchange = "kraken", api_key = NULL, allowance = FALSE)
get_summary(pair, keyBy = NULL, exchange = "kraken", api_key = NULL, allowance = FALSE)
pair |
A character string containing a pair symbol, e.g. btcusd
(required argument). Run |
keyBy |
A single character string. Possible values are are either id or symbols. |
exchange |
A character string containing the exchange. Default is
kraken. Run |
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 |
Current 24-hour summary of a given pair of currencies. If allowance
is TRUE
, get_summary()
returns a list with additional
information on allowances.
See https://docs.cryptowat.ch/rest-api for further information.
get_markets
, get_current_price
,
get_exchanges
, get_pairs
## Not run: # 24h-hour summary of cryptocurrency pairs summary <- get_summary("btcusd") summaries <- get_summary() summaries2 <- get_summary(keyBy = "id") summaries3 <- get_summary(keyBy = "symbols") ## End(Not run)
## Not run: # 24h-hour summary of cryptocurrency pairs summary <- get_summary("btcusd") summaries <- get_summary() summaries2 <- get_summary(keyBy = "id") summaries3 <- get_summary(keyBy = "symbols") ## End(Not run)
Get data.frame with trades of cryptocurrencies using the REST API of cryptowat.ch. The route is trades and returns trades for a specified market. See https://docs.cryptowat.ch/rest-api/markets/trades for further information.
get_trades(pair, since = NULL, limit = NULL, exchange = "kraken", datetime = TRUE, api_key = NULL, allowance = FALSE)
get_trades(pair, since = NULL, limit = NULL, exchange = "kraken", datetime = TRUE, api_key = NULL, allowance = FALSE)
pair |
A character string containing a pair symbol, e.g. btcusd
(required argument). Run |
since |
An integer if datetime is |
limit |
An integer: Limit the number of trades (optional). Max: 1000. |
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 trades of a given pair of currencies. If
allowance is TRUE
, get_trades()
returns a list.
See https://docs.cryptowat.ch/rest-api for further information.
get_markets
, get_assets
,
get_exchanges
, get_pairs
## Not run: # Most recent trades (default is 50) trades <- get_trades(pair) # 200 trades (maximum is 1000) since 1589571417 (unix timestamp) trades_unix <- get_trades(pair, since = 1589571417, limit = 200, datetime = FALSE) # 1000 trades and datetime is TRUE trades_datetime <- get_trades(pair, since = "2021-06-01", limit = 1000) ## End(Not run)
## Not run: # Most recent trades (default is 50) trades <- get_trades(pair) # 200 trades (maximum is 1000) since 1589571417 (unix timestamp) trades_unix <- get_trades(pair, since = 1589571417, limit = 200, datetime = FALSE) # 1000 trades and datetime is TRUE trades_datetime <- get_trades(pair, since = "2021-06-01", limit = 1000) ## End(Not run)
Get data frame with prices of cryptocurrencies using the REST API of cryptowat.ch.
markets(pair, params = NULL, exchange = "kraken", route = "ohlc", datetime = TRUE)
markets(pair, params = NULL, exchange = "kraken", route = "ohlc", datetime = TRUE)
pair |
A string containing a pair symbol, e.g. btcusd (required argument). |
params |
A list containing |
exchange |
A character string containing the exchange. Default is kraken. |
route |
A character string containing the route. Default is ohlc. |
datetime |
A logical. |
A data frame containing OHLC candlestick prices of a given pair of currencies.
See https://docs.cryptowat.ch/rest-api for further information.
get_markets
, get_assets
, get_exchanges
,
get_pairs
## Not run: df_ohlc_hourly <- markets("btcusd") df_ohlc_hourly2 <- markets("btcusd", list(periods = 3600, before = 1609851600, after = 1609506000), datetime = FALSE) df_ohlc_daily <- markets("btceur", list(periods = 86400, before = "2021-05-12", after = "2021-01-01"), datetime = TRUE) ## End(Not run)
## Not run: df_ohlc_hourly <- markets("btcusd") df_ohlc_hourly2 <- markets("btcusd", list(periods = 3600, before = 1609851600, after = 1609506000), datetime = FALSE) df_ohlc_daily <- markets("btceur", list(periods = 86400, before = "2021-05-12", after = "2021-01-01"), datetime = TRUE) ## End(Not run)