binance_depth
Retrieve a snapshot of the order book for a specified trading pair. Refer to this article for the management of an orderbook.
- Github function here.
Example: Spot (spot)
Get depth data for BTCUSDT
in spot market.
Show the code
Visualize a structure orderbook from depth data with OrderBook()
function:
Example: Futures (fapi)
Get depth data for BTCUSDT
in USD-m market.
Show the code
library(binancer)
library(dplyr)
# import depth futures usd-m data from binance
depth_fapi <- binance_depth(pair = "BTCUSDT", api = "fapi", quiet = TRUE)
df_depth <-
dplyr::bind_rows(
tail(dplyr::filter(depth_fapi, side == "ASK"), n = 1), # best ask
head(dplyr::filter(depth_fapi, side == "BID"), n = 1) # best bid
)
Example: Futures (dapi)
Get depth data for BTCUSD_PERP
in COIN-m market.
Show the code
library(binancer)
library(dplyr)
# import depth futures coin-m data from binance
depth_dapi <- binance_depth(pair = "BTCUSD_PERP", api = "dapi", quiet = TRUE)
df_depth <- dplyr::bind_rows(
tail(dplyr::filter(depth_dapi, side == "ASK"), n = 1), # best ask
head(dplyr::filter(depth_dapi, side == "BID"), n = 1) # best bid
)
Example: Options (eapi)
Get depth data for BTC-240628-30000-P
in Options market. BTC-240628-30000-P
is a Put contract with strike price 30000 and expiry date on 28-06-2024
.
Show the code
library(binancer)
library(dplyr)
# import depth futures coin-m data from binance
depth_eapi <- binance_depth(pair = "BTC-240628-30000-P", api = "eapi")
df_depth <- dplyr::bind_rows(
tail(dplyr::filter(depth_eapi, side == "ASK"), n = 1), # best ask
head(dplyr::filter(depth_eapi, side == "BID"), n = 1) # best bid
)
Citation
BibTeX citation:
@online{sartini2024,
author = {Sartini, Beniamino},
date = {2024-06-18},
url = {https://cryptoverser.org/binancer-docs/binance_depth.html},
langid = {en}
}
For attribution, please cite this work as:
Sartini, Beniamino. 2024. June 18, 2024. https://cryptoverser.org/binancer-docs/binance_depth.html.