Learn R Programming

cryptowatchR (version 0.2.0)

get_trades: Get trades of cryptocurrencies

Description

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.

Usage

get_trades(pair, since = NULL, limit = 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.

since

An integer if datetime is FALSE and a character string if it is TRUE: Limit the response to trades after this date (optional). This can only be used to filter recent trades. Historical trades cannot be retrieved.

limit

An integer: Limit the number of trades (optional). Max: 1000.

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 trades of a given pair of currencies. If allowance is TRUE, get_trades() 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

Run this code
# 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)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab