Integration
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.
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
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.
Unified trading account
Spot, margin, swaps, futures, and options share one margin account, with cash, isolated, or cross trade mode selected per instrument.
API-key authentication
Orders are signed with HMAC-SHA256 from an API key, secret, and passphrase, handled inside the Rust core over the REST and WebSocket APIs.
Data and execution
One adapter covers both market data and order execution, with order, fill, position, and balance reconciliation.
Linear and inverse contracts
USDT and USDC-margined linear contracts alongside coin-margined inverse swaps and futures, through a single client.
Options with greeks
Options stream Black-Scholes and price-adjusted greeks from the venue option summary, with position-level greeks carried in account state.
Live and demo
Select the environment with one config flag. The data client runs on public endpoints; execution adds API-key credentials.
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)
OrderBookDeltasSnapshot then incremental deltas; tick-by-tick book depth unlocks with VIP tier.
Order book depth
OrderBookDepth10Top-ten levels maintained from the live order book.
Quotes
QuoteTickBest bid and offer from the BBO tick-by-tick channel.
Trades
TradeTickLive public trades over WebSocket, plus REST trade history.
Bars
BarCandles from 1-minute to 1-year over WebSocket, with REST history.
Mark price
MarkPriceUpdateDerivatives mark price.
Index price
IndexPriceUpdateUnderlying index price.
Funding rate
FundingRateUpdatePerpetual swap funding with funding time and computed interval.
Instruments
CurrencyPairCryptoPerpetualCryptoFutureCryptoOptionSpot, swap, futures, and option definitions fetched per configured instrument type.
Status
InstrumentStatusActive and suspended market snapshots.
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
Spot / Margin
Swap / Futures
Options
Maps to an OKX market order and accepts a quote quantity. Options reject market orders.
Spot / Margin
Swap / Futures
Options
Unfilled remainder rests as a limit order. Not available for options.
Spot / Margin
Swap / Futures
Options
Take-profit trigger to a market order; swaps and futures only.
Spot / Margin
Swap / Futures
Options
Take-profit trigger to a limit order; swaps and futures only.
Spot / Margin
Swap / Futures
Options
Trailing stop via the advance algo endpoint; swaps and futures only.
The three native time-in-force options apply across products. GTD is not native to OKX; NautilusTrader provides strategy-managed GTD.
The execution instructions and account operations traders rely on.
Post-only
Maker-only limit orders using OKX's post-only order type, rejected if they would cross the book.
Reduce-only
Position-reducing flag on swap and futures orders; stripped on spot, margin, and options.
Order amendment
Amend price or quantity in place over REST, without a cancel-and-replace round trip.
Batch operations
Submit, amend, and cancel orders in batches through one request.
OCO and brackets
One-cancels-other and bracket orders pairing a stop-loss with a take-profit, placed as contingent algo orders.
Mass cancel
Cancel-all and the market-maker mass-cancel endpoint, scoped per instrument family.
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.
Adapter crate
Data client
OKXDataClient streams instruments, books, quotes, trades, and bars.Execution client
OKXExecutionClient handles signed orders, account queries, and reconciliation.Signing
Instrument types
OKXInstrumentType.Environments
OKXEnvironment.Authentication
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.
Starting points for the OKX adapter.
Read the integration guide
Installation, account setup, configuration, signing, and order handling for the OKX adapter.
Read guide
Rust adapter examples
Runnable example nodes bundled with the crate: market-data and execution testers, an options greeks streamer, and a delta-neutral strategy.
View on GitHub
Integration guide
Read the full integration guide
The guide covers installation, account setup, configuration, order handling, HMAC signing, and worked examples for trading OKX.
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.