Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Nautechsystems Nautilus trader BinanceClientConfig

From Leeroopedia
Revision as of 16:00, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Nautechsystems_Nautilus_trader_BinanceClientConfig.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Field Value
sources https://github.com/nautechsystems/nautilus_trader, https://nautilustrader.io/docs/
domains algorithmic trading, exchange connectivity, Binance integration
last_updated 2026-02-10 12:00 GMT

Overview

Concrete tool for configuring Binance exchange data and execution clients provided by NautilusTrader.

Description

NautilusTrader provides two frozen configuration classes for Binance connectivity:

  • BinanceDataClientConfig -- configures the market data client for order book, trade, and quote subscriptions via Binance REST and WebSocket APIs.
  • BinanceExecClientConfig -- configures the execution client for order submission, modification, cancellation, and account/position management.

Both classes inherit from their respective generic base configs (LiveDataClientConfig and LiveExecClientConfig) and add Binance-specific fields for:

  • API key and secret (HMAC or RSA authentication).
  • Account type selection (SPOT, USDT_FUTURE, COIN_FUTURE).
  • Environment selection (LIVE, TESTNET, DEMO).
  • Custom endpoint overrides for HTTP and WebSocket URLs.
  • Proxy support.
  • Execution-specific flags: GTD handling, reduce-only forwarding, position ID usage, trade-lite events, retry configuration, futures leverage and margin type presets.

Usage

Import these configs when setting up a TradingNodeConfig that connects to Binance. They are passed as values in the data_clients and exec_clients dictionaries of the node configuration.

Code Reference

Source Location

Item Path
BinanceDataClientConfig nautilus_trader/adapters/binance/config.py lines 72-125
BinanceExecClientConfig nautilus_trader/adapters/binance/config.py lines 127-223

Signature

class BinanceDataClientConfig(LiveDataClientConfig, frozen=True):
    venue: Venue = BINANCE_VENUE
    api_key: str | None = None
    api_secret: str | None = None
    key_type: BinanceKeyType = BinanceKeyType.HMAC
    account_type: BinanceAccountType = BinanceAccountType.SPOT
    base_url_http: str | None = None
    base_url_ws: str | None = None
    proxy_url: str | None = None
    environment: BinanceEnvironment | None = None
    us: bool = False
    testnet: bool = False
    update_instruments_interval_mins: PositiveInt | None = 60
    use_agg_trade_ticks: bool = False
class BinanceExecClientConfig(LiveExecClientConfig, frozen=True):
    venue: Venue = BINANCE_VENUE
    api_key: str | None = None
    api_secret: str | None = None
    key_type: BinanceKeyType = BinanceKeyType.HMAC
    account_type: BinanceAccountType = BinanceAccountType.SPOT
    base_url_http: str | None = None
    base_url_ws: str | None = None
    base_url_ws_stream: str | None = None
    proxy_url: str | None = None
    environment: BinanceEnvironment | None = None
    us: bool = False
    testnet: bool = False
    use_gtd: bool = True
    use_reduce_only: bool = True
    use_position_ids: bool = True
    use_trade_lite: bool = False
    treat_expired_as_canceled: bool = False
    recv_window_ms: PositiveInt = 5_000
    max_retries: PositiveInt | None = None
    retry_delay_initial_ms: PositiveInt | None = None
    retry_delay_max_ms: PositiveInt | None = None
    futures_leverages: dict[BinanceSymbol, PositiveInt] | None = None
    futures_margin_types: dict[BinanceSymbol, BinanceFuturesMarginType] | None = None
    log_rejected_due_post_only_as_warning: bool = True

Import

from nautilus_trader.adapters.binance.config import BinanceDataClientConfig
from nautilus_trader.adapters.binance.config import BinanceExecClientConfig

I/O Contract

BinanceDataClientConfig -- Key Inputs

Parameter Type Required Description
api_key None No Binance API public key. If None, the client works for public market data only.
api_secret None No Binance API secret key.
account_type BinanceAccountType No Account type: SPOT, USDT_FUTURE, or COIN_FUTURE. Default SPOT.
environment None No LIVE, TESTNET, or DEMO. Defaults to LIVE.
use_agg_trade_ticks bool No Use aggregated trade ticks instead of raw trades. Default False.

BinanceExecClientConfig -- Key Inputs

Parameter Type Required Description
api_key None No Binance API public key. Sourced from env var if None.
api_secret None No Binance API secret key. Sourced from env var if None.
account_type BinanceAccountType No Account type. Default SPOT.
max_retries None No Max retry attempts for order operations.
retry_delay_initial_ms None No Initial delay between retries in milliseconds.
futures_leverages None No Per-symbol initial leverage for futures.
futures_margin_types None No Per-symbol margin type (ISOLATED or CROSS) for futures.

Outputs

Output Type Description
Config instance BinanceDataClientConfig or BinanceExecClientConfig Frozen, validated configuration object ready to be passed to the node's client dictionaries.

Usage Examples

Binance Spot Configuration

from nautilus_trader.adapters.binance.config import BinanceDataClientConfig
from nautilus_trader.adapters.binance.config import BinanceExecClientConfig
from nautilus_trader.adapters.binance.common.enums import BinanceAccountType

data_config = BinanceDataClientConfig(
    api_key="YOUR_API_KEY",
    api_secret="YOUR_API_SECRET",
    account_type=BinanceAccountType.SPOT,
)

exec_config = BinanceExecClientConfig(
    api_key="YOUR_API_KEY",
    api_secret="YOUR_API_SECRET",
    account_type=BinanceAccountType.SPOT,
    max_retries=3,
    retry_delay_initial_ms=500,
)

Binance Futures with Testnet

from nautilus_trader.adapters.binance.config import BinanceDataClientConfig
from nautilus_trader.adapters.binance.config import BinanceExecClientConfig
from nautilus_trader.adapters.binance.common.enums import BinanceAccountType
from nautilus_trader.adapters.binance.common.enums import BinanceEnvironment

data_config = BinanceDataClientConfig(
    api_key="YOUR_TESTNET_KEY",
    api_secret="YOUR_TESTNET_SECRET",
    account_type=BinanceAccountType.USDT_FUTURE,
    environment=BinanceEnvironment.TESTNET,
)

exec_config = BinanceExecClientConfig(
    api_key="YOUR_TESTNET_KEY",
    api_secret="YOUR_TESTNET_SECRET",
    account_type=BinanceAccountType.USDT_FUTURE,
    environment=BinanceEnvironment.TESTNET,
    use_reduce_only=True,
    use_position_ids=True,
)

Wiring into TradingNodeConfig

from nautilus_trader.config import TradingNodeConfig

config = TradingNodeConfig(
    trader_id="TRADER-001",
    data_clients={"BINANCE": data_config},
    exec_clients={"BINANCE": exec_config},
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment