Learn R Programming

cryptowatchR (version 0.2.0)

get_orderbook_calculator: Get live quotes from order book

Description

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.

Usage

get_orderbook_calculator(pair, amount = NULL, 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.

amount

A number: Amount to buy or sell (required).

exchange

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

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

References

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

See Also

get_markets, get_orderbook, get_orderbook_liquidity, get_exchanges, get_pairs

Examples

Run this code
# NOT RUN {
# Live quote for 50 Bitcoins
calculator <- get_orderbook_calculator("btcusd", amount = 50)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab