Integration

OKX

Trade OKX with NautilusTrader

Stream OKX market data and execute spot, margin, perpetual swap, futures, options, and event contract markets through an adapter written in Rust, with HMAC-signed REST and WebSocket access, unified-account margin modes, and full order and position reconciliation.

Centralized crypto exchange

Spot, swaps, futures, options

Data and execution

Written in Rust 🦀

OKX is one of the largest centralized cryptocurrency exchanges by trading volume. Its unified account trades spot pairs, margin, linear and inverse perpetual swaps, dated futures, and options on a single margin system, reached over REST and WebSocket APIs with deep liquidity across crypto majors.

NautilusTrader integrates with OKX through nautilus-okx, a platform adapter written in Rust with Python bindings, providing both data and execution clients. It streams order books, quotes, trades, bars, and mark, index, and funding updates, and submits orders signed with HMAC-SHA256 in the Rust core rather than calling an external OKX SDK. Order, fill, position, and balance updates from the unified account drive reconciliation.

Products

Spot and margin, perpetual swaps and futures, and options, traded through one adapter and signing path.

Swaps and futures

Linear and inverse

USDT and USDC-margined linear contracts alongside coin-margined inverse swaps and dated futures, margined in the unified account.

Linear and inverse contracts

Cross and isolated margin

Stop, conditional, and trailing orders

BTC-USDT-SWAP.OKX

Spot and margin

Hundreds of pairs

Spot pairs and margin trading on the same account, with cash or borrowed-margin trade modes selected per instrument.

Market and limit orders

Cash and margin trade modes

Quote-quantity market orders

BTC-USDT.OKX

Options

Calls and puts

Limit-style options on the largest crypto underlyings, with Black-Scholes and price-adjusted greeks streamed from the venue.

Calls and puts across strikes

Option greeks from the venue

Limit-only execution

BTC-USD-251226-100000-C.OKX

Markets

Crypto majors across spot and derivatives, with options on the largest underlyings.

Crypto majors · Hundreds of markets

BTC

Bitcoin

ETH

Ethereum

SOL

Solana

XRP

XRP

BNB

BNB

DOGE

Dogecoin

ADA

Cardano

AVAX

Avalanche

LINK

Chainlink

TRX

TRON

TON

Toncoin

SUI

Sui

DOT

Polkadot

LTC

Litecoin

NEAR

Near

APT

Aptos

ARB

Arbitrum

+ More

Each major lists spot, margin, perpetual swaps, and dated futures, e.g. BTC-USDT-SWAP (linear), BTC-USD-SWAP (inverse), and BTC-USD-251226 (futures).

Options · BTC · ETH · SOL

BTC

Bitcoin

ETH

Ethereum

SOL

Solana

Calls and puts across expiries and strikes, e.g. BTC-USD-251226-100000-C (asset-expiry-strike-call/put).

These are a representative sample. OKX lists hundreds more markets across spot, margin, perpetual swaps, dated futures, and options, plus multi-leg spreads and event contracts, and adds new ones continuously; the adapter discovers the live instrument set for each configured instrument type at startup and maps every OKX instrument to a NautilusTrader instrument.

Data feeds

Each OKX feed maps to a native NautilusTrader data type. Option greeks stream alongside as Black-Scholes and price-adjusted values.

Data feed

NautilusTrader type

Notes

Order book (L2)

OrderBookDeltas

Snapshot then incremental deltas; tick-by-tick book depth unlocks with VIP tier.

Order book depth

OrderBookDepth10

Top-ten levels maintained from the live order book.

Quotes

QuoteTick

Best bid and offer from the BBO tick-by-tick channel.

Trades

TradeTick

Live public trades over WebSocket, plus REST trade history.

Bars

Bar

Candles from 1-minute to 1-year over WebSocket, with REST history.

Mark price

MarkPriceUpdate

Derivatives mark price.

Index price

IndexPriceUpdate

Underlying index price.

Funding rate

FundingRateUpdate

Perpetual swap funding with funding time and computed interval.

Instruments

CurrencyPairCryptoPerpetualCryptoFutureCryptoOption

Spot, swap, futures, and option definitions fetched per configured instrument type.

Status

InstrumentStatus

Active and suspended market snapshots.

Order types

Order types supported per product group. OKX expresses stops and triggers as algo orders on swaps and futures; spot and margin trade market and limit, and options are limit-only.

Type

Spot / Margin

Swap / Futures

Options

Notes

MARKET

Maps to an OKX market order and accepts a quote quantity. Options reject market orders.

MARKET_TO_LIMIT

Unfilled remainder rests as a limit order. Not available for options.

LIMIT

Maps to an OKX limit order; the only order type for options.

STOP_MARKET

Swaps and futures only; routed as an algo order.

STOP_LIMIT

Swaps and futures only; routed as an algo order.

MARKET_IF_TOUCHED

Take-profit trigger to a market order; swaps and futures only.

LIMIT_IF_TOUCHED

Take-profit trigger to a limit order; swaps and futures only.

TRAILING_STOP_MARKET

Trailing stop via the advance algo endpoint; swaps and futures only.

Time in force

The three native time-in-force options apply across products. GTD is not native to OKX; NautilusTrader provides strategy-managed GTD.

Type

Spot / Margin

Swap / Futures

Options

Notes

GTC

Good-till-canceled; the default for resting orders.

IOC

Immediate-or-cancel.

FOK

Fill-or-kill.

Data and execution clients

Data client

Public REST and WebSocket streams

Feeds: order books, top-ten depth, quotes, trades, bars, and mark / index / funding.

No credentials: public market data runs on public endpoints, so research and backtest data need no account.

Resilience: reconnecting WebSocket across public and business channels with subscription tracking.

Execution client

Signed orders over REST and WebSocket

Orders: HMAC-signed entry, in-place amend, batch operations, and algo orders for stops and triggers.

Account: order, fill, position, and balance updates over private channels drive reconciliation.

Unified account: one margin account across spot, margin, swaps, futures, and options.

How the integration works

Adapter crate

nautilus-okx, a Rust core with Python bindings.

Data client

OKXDataClient streams instruments, books, quotes, trades, and bars.

Execution client

OKXExecutionClient handles signed orders, account queries, and reconciliation.

Signing

HMAC-SHA256 over the REST and WebSocket APIs, handled in the Rust core.

Instrument types

Spot, margin, swap, futures, and option, plus spreads and event contracts, selected by OKXInstrumentType.

Environments

Live and demo, selected by OKXEnvironment.

Authentication

API key, secret, and passphrase.

Considerations

•

Public market data needs no credentials; execution needs an API key, secret, and passphrase.

•

The unified account selects cash, isolated, or cross trade mode per instrument; position mode (net or long/short) is set account-wide.

•

Conditional orders (stop, MIT, LIT, trailing) route through OKX algo endpoints on swaps and futures, not spot or margin.

•

Options trade limit-only; market orders are rejected before submission and reduce-only does not apply.

•

Event contracts load as the EVENTS instrument type and map to a NautilusTrader BinaryOption; they trade limit-only with a yes/no outcome parameter and settle by delivery.

•

Time in force is GTC, IOC, or FOK; GTD is strategy-managed rather than venue-native.

•

Client order IDs use letters and numbers up to 32 characters, with no hyphens.

•

Every order from a user-controlled node carries the NautilusTrader integration ID in the OKX order tag for transparent attribution.

Integration guide

Read the full integration guide

The guide covers installation, account setup, configuration, order handling, HMAC signing, and worked examples for trading OKX.

footer-logo

© 2026 Nautech Systems Pty Ltd. All rights reserved.

NautilusTraderâ„¢ is a product of Nautech Systems Pty Ltd (ABN 88 609 589 237). Nautech Systems provides algorithmic trading software only. We do not operate as a broker, dealer, or exchange, nor offer financial advisory services. Users are solely responsible for compliance with applicable laws and regulations. Subject to non-excludable consumer guarantees, we make no warranties and accept no liability for trading losses or regulatory violations arising from use of the software. Read full disclaimer.

We use essential cookies and, with your consent, optional analytics cookies, as described in our Privacy Policy. Manage your Cookie Preferences.