Learn R Programming

cryptowatchR (version 0.2.0)

get_current_price: Get current price of cryptocurrencies

Description

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.

Usage

get_current_price(pair, exchange = "kraken", api_key = NULL, allowance = FALSE)

Arguments

pair

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

exchange

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

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 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

Current price of a given pair of currencies. If allowance is TRUE, get_current_price() returns a list.

References

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

See Also

get_markets, get_ohlc, get_exchanges, get_pairs

Examples

Run this code
# NOT RUN {
# Daily prices of Bitcoin in USD
current.price <- get_current_price("btcusd")
current.prices <- get_current_price()
# }

Run the code above in your browser using DataLab