Binance

class BinanceBar

Bases: object

Represents a Binance bar (kline/candlestick) with additional Binance-specific fields.

Extends the core Bar fields with quote_volume, count, taker_buy_base_volume, and taker_buy_quote_volume.

bar_type
close
count
static from_dict(values)
high
low
open
quote_volume
taker_buy_base_volume
taker_buy_quote_volume
to_dict()

# Errors

Returns a PyErr if generating the Python dictionary fails.

ts_event
ts_init
volume
class BinanceDataClientConfig

Bases: object

Configuration for Binance data client.

Ed25519 API keys are required for SBE WebSocket streams.

base_url_http
base_url_ws
environment
has_proxy_url
instrument_provider
instrument_refresh_interval_secs
instrument_status_poll_secs
product_type
recv_window_ms
spot_market_data_mode
transport_backend
us
class BinanceDataClientFactory

Bases: object

Factory for creating Binance data clients.

name()
class BinanceEnvironment

Bases: object

Binance environment type.

DEMO = BinanceEnvironment.DEMO
LIVE = BinanceEnvironment.LIVE
TESTNET = BinanceEnvironment.TESTNET
class BinanceExecClientConfig

Bases: object

Configuration for Binance execution client.

Global execution uses WebSocket API authentication with Ed25519 credentials. Binance US uses HMAC-signed HTTP requests and listen-key user data streams.

account_id
base_url_http
base_url_ws
base_url_ws_trading
bnfcr_currency
default_taker_fee
environment
futures_leverages
futures_margin_types
has_proxy_url
instrument_provider
instrument_refresh_interval_secs
oms_type
product_type
recv_window_ms
trader_id
transport_backend
treat_expired_as_canceled
us
use_gtd
use_position_ids
use_trade_lite
use_ws_trading
ws_trading_setup_timeout_ms
class BinanceExecutionClientFactory

Bases: object

Factory for creating Binance Spot execution clients.

name()
class BinanceFuturesLiquidation

Bases: object

Binance Futures liquidation update from the forceOrder stream.

accumulated_qty
average_price
instrument_id
last_filled_qty
price
side
ts_event
ts_init
class BinanceFuturesMarkPriceUpdate

Bases: object

Binance Futures mark-price stream update with venue-specific fields.

estimated_settle_price
funding_rate
index_price
instrument_id
mark_price
next_funding_time
ts_event
ts_init
class BinanceFuturesOpenInterest

Bases: object

Binance Futures current open interest snapshot.

instrument_id
open_interest
ts_event
ts_init
class BinanceFuturesOpenInterestHist

Bases: object

Binance Futures historical open interest batch.

COIN-M requests are keyed by pair and contract type rather than by symbol. Perpetuals derive both from the _PERP symbol suffix, while delivery contracts resolve them from the cached instrument definition.

instrument_id
period
points
ts_event
ts_init
class BinanceFuturesOpenInterestHistPoint

Bases: object

Binance Futures historical open interest point.

sum_open_interest
sum_open_interest_value
ts_event
class BinanceFuturesTicker

Bases: object

Binance Futures 24-hour ticker statistics from the ticker stream.

close_time
first_trade_id
high_price
instrument_id
last_price
last_qty
last_trade_id
low_price
num_trades
open_price
open_time
price_change
price_change_percent
quote_volume
ts_event
ts_init
volume
weighted_avg_price
class BinanceInstrumentProviderConfig

Bases: object

Configuration for Binance instrument loading.

filter_callable
filters
load_all
load_ids
log_warnings
query_commission_rates
class BinanceMarginType

Bases: object

Margin type applied to a position.

Serializes to the POST format (CROSSED/ISOLATED) expected by /fapi/v1/marginType. Deserializes from both POST and GET/WS formats (cross/isolated) via serde aliases.

CROSS = BinanceMarginType.CROSS
ISOLATED = BinanceMarginType.ISOLATED
UNKNOWN = BinanceMarginType.UNKNOWN
class BinancePositionSide

Bases: object

Position side for dual-side position mode.

Both = BinancePositionSide.Both
Long = BinancePositionSide.Long
Short = BinancePositionSide.Short
Unknown = BinancePositionSide.Unknown
class BinanceProductType

Bases: object

Binance product type identifier.

Each product type corresponds to a different Binance API domain and has distinct trading rules and instrument specifications.

COIN_M = BinanceProductType.COIN_M
MARGIN = BinanceProductType.MARGIN
OPTIONS = BinanceProductType.OPTIONS
SPOT = BinanceProductType.SPOT
USD_M = BinanceProductType.USD_M
class BinanceSpotMarketDataMode

Bases: object

Spot market-data transport mode.

Json = BinanceSpotMarketDataMode.Json
Sbe = BinanceSpotMarketDataMode.Sbe
class BinanceSpotTicker

Bases: object

Binance Spot 24-hour ticker statistics from the ticker stream.

ask_price
ask_qty
bid_price
bid_qty
close_time
first_trade_id
high_price
instrument_id
last_price
last_qty
last_trade_id
low_price
num_trades
open_price
open_time
prev_close_price
price_change
price_change_percent
quote_volume
ts_event
ts_init
volume
weighted_avg_price
decode_binance_futures_client_order_id(encoded)

Decodes a Binance Futures encoded clientOrderId back to the original value.

Binance Futures orders placed through the Rust execution client have their ClientOrderId encoded with a broker ID prefix for Link and Trade attribution. This function reverses that encoding.

Strings without the broker prefix are returned unchanged.

decode_binance_spot_client_order_id(encoded)

Decodes a Binance Spot encoded clientOrderId back to the original value.

Binance Spot orders placed through the Rust execution client have their ClientOrderId encoded with a broker ID prefix for Link and Trade attribution. This function reverses that encoding.

Strings without the broker prefix are returned unchanged.

get_binance_arrow_schema_map(cls)

Returns a mapping from field names to Arrow data types for the BinanceBar class.

# Errors

Returns a PyErr if the class name is not recognized.

async load_binance_instruments(config: BinanceDataClientConfig) list[object]

Load the configured Binance instrument catalogue.

This is the Python v2 replacement for constructing a cached low-level HTTP client and a product-specific v1 instrument provider. The embedded instrument_provider config controls selection, filters, parser warnings, and commission queries.

load_binance_order_book_deltas(file_path, nrows=None)

Loads Binance order book CSV data for wrangling into Nautilus deltas.

# Errors

Returns an error if the file cannot be read, a row cannot be parsed, or a side is invalid.