View source: R/get_orderbook.R
get_orderbook | R Documentation |
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)
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.