AI-native runtime for OKX trading strategies
Author in Cursor, Claude Code or any AI IDE. Deploy from GitHub into a managed cloud runtime with first-class MCP control, logs and region selection.
Section 01 · At a glance
At a glance
- Venue
- OKX
- Venue type
- Crypto exchange
- Asset class
- Crypto
- Supported products
- Spot, perpetual swaps, expiry futures, options (BTC and ETH), margin, Simple Earn (flexible and fixed). USDT-margined BTC/ETH expiry futures wind down by June 26, 2026, after which USD-margined expiry futures continue.
- Runtime model
- Containerised strategy runtime
- Deployment source
- GitHub
- Languages
- Any language that runs in a container
- Common integrations
- Native OKX v5 REST and WebSocket, CCXT (okx), Hummingbot (okx, okx_perpetual), Freqtrade (spot and futures, with caveats), custom
- AI workflow integration
- MCP control surface for Cursor, Claude Code, GitHub Copilot and CLI agents
- TradingHost role
- Runtime, deployment, logs, health checks, region selection, MCP control
- OKX role
- Exchange account, API access, market access, execution venue
- Affiliation
- TradingHost is independent and is not affiliated with OKX
Section 02 · What OKX offers
What OKX offers
OKX offers spot, perpetual swaps, expiry futures, options on BTC and ETH, and margin trading through a Unified Account that supports multi-currency and portfolio margin modes. The v5 API exposes REST plus three WebSocket URLs (Public, Private, Business), and a demo environment that uses production hostnames with an `x-simulated-trading: 1` header rather than a separate testnet host. Endpoint specifics change over time. The shape is durable; precise rate-limit weights, fee tiers and symbol lists live in OKX's docs.
Markets and strategy patterns
- Perpetual swaps, USDT-margined and coin-margined
- Options strategies on BTC and ETH (covered calls, spreads, expiry plays)
- Portfolio margin mode (cross-product risk-based margin)
- Multi-currency margin mode (multiple assets as shared USD-value margin)
- Unified Account spanning spot, margin, perps, futures and options
- Sub-account hierarchy under a master account
- Simulated trading via demo API keys with x-simulated-trading: 1 header
- Demo-to-prod promotion (separate demo keys, then switch to live keys without rewrites)
API surface
- Product surfaces
- Spot, perpetual swaps, expiry futures, options (BTC, ETH), margin, plus a demo (simulated trading) environment that mirrors the same endpoints. There is no separate testnet.okx.com host: demo uses production hostnames with x-simulated-trading: 1 set on every request and a demo API key created from the demo trading panel.
- Connection methods
- REST v5, WebSocket Public (wss://ws.okx.com:8443/ws/v5/public), WebSocket Private (wss://ws.okx.com:8443/ws/v5/private), WebSocket Business (wss://ws.okx.com:8443/ws/v5/business). Orders can be placed, amended and cancelled over WebSocket in addition to REST.
- Authentication
- HMAC-SHA256 signature, API key, secret and passphrase (3-part credential). Headers: OK-ACCESS-KEY, OK-ACCESS-SIGN, OK-ACCESS-TIMESTAMP (ISO 8601 UTC, ms), OK-ACCESS-PASSPHRASE. Up to 20 IPs per API key in the allowlist. Demo trading uses separate demo keys plus the x-simulated-trading: 1 header.
For specifics, refer to OKX
Specific endpoints, rate-limit weights, symbol lists, fee tiers and version history live in OKX's documentation. Treat these as the source of truth.
Section 03 · Build with AI
Build your OKX strategy with AI
Pick an integration method, fork a TradingHost framework starter, and author your strategy in an AI IDE. Cursor, Claude Code, GitHub Copilot and CLI-based AI agents all work with the same GitHub-native deployment loop.
Native OKX v5 API
Direct control over OKX-specific behaviour, Unified Account state, sub-account routing and order execution logic.
Freqtrade or Hummingbot
Framework-based deployments using their strategy structure and configuration model.
Custom connector
Your own internal trading engine or proprietary OKX integration.
Framework support for OKX products
Coverage varies by framework. CCXT spans the broadest OKX surface; Freqtrade and Hummingbot cover spot and perpetuals (Freqtrade also covers expiry futures); native OKX v5 API access covers everything OKX offers, including options on BTC and ETH.
✓ confirmed support per official framework docs. "partial" indicates limited or market-data-only coverage. "no" indicates not officially documented as supported.
TradingHost does not force a framework. It runs your project.
Author with AI
The framework starters above pair naturally with AI IDEs. The TradingHost MCP control surface closes the loop: AI tools can inspect deployments, review logs and manage the runtime alongside you, never the trade execution path.
Section 04 · Run on TradingHost
Run your code on TradingHost
OKX provides the exchange and API access. TradingHost provides the production environment where your OKX-connected strategy runs.
Instead of running strategy code on a laptop, desktop machine, generic VPS or manually configured server, you deploy from GitHub into a TradingHost-managed container runtime.
You
- Your repo contains your code.
- Your deployment defines how it runs.
- Your strategy connects to OKX.
TradingHost
- Keeps the runtime online.
- Surfaces logs and health checks.
- Region selection.
- Controlled deployment surface.
Deployment flow
- STEP 01
Connect GitHub
Authorise TradingHost to access your GitHub account.
- STEP 02
Link a repo or start from a framework
Point TradingHost at your existing strategy repo, or fork a TradingHost framework runtime (CCXT, Freqtrade or Hummingbot) for a working baseline.
- STEP 03
Deploy into a TradingHost container
Pick a region (EU or US-East), supply the environment values your strategy needs (OKX API key, secret and passphrase, the 3-part credential), and deploy. TradingHost builds your container from the repo and runs your strategy on managed Kubernetes infrastructure. No local Docker install required.
- STEP 04
Monitor logs and health
Watch live logs, health and runtime state from the TradingHost dashboard. The same surface is reachable through MCP from any AI IDE, so Cursor, Claude Code or a CLI agent can read deployment state and manage the runtime alongside you.
- STEP 05
Update and redeploy
Push changes to your GitHub main branch and TradingHost redeploys automatically.
Section 05 · Operational notes
Operational notes for OKX
Things that bite you when you actually run an OKX strategy in a containerised cloud runtime, not in OKX's docs, not in framework READMEs. Every claim below is quoted or paraphrased from OKX's own documentation; the deployment-side guidance is from running these strategies on TradingHost.
01 · API version
OKX is on v5; v3 retired in 2022, no v4
OKX skipped v4 (number 4 connotation) and went directly from v3 to v5. The v3 API was sunset on January 5, 2022 once Unified Account migration was largely complete. There is no v3 fallback today: every integration should target v5 endpoints.
02 · Demo trading
Demo is a header flag plus separate keys, not a separate host
OKX does not run a separate testnet.okx.com host. Demo trading uses production hostnames with x-simulated-trading: 1 set on every request, plus a demo API key created from the demo trading panel. Live keys won't authenticate against demo, and demo keys will silently fail without the header.
03 · Authentication
Three-part credential plus signed timestamp
OKX requires API key, secret and passphrase (the passphrase is set at key creation, not the account password). Requests sign timestamp + method + requestPath + body with HMAC-SHA256 base64 and send the result in OK-ACCESS-SIGN. Code 50111 maps to invalid key, 50113 to invalid signature, both common when the passphrase is missing or the timestamp drifts.
04 · WebSockets
Three WebSocket URLs, not one
OKX splits WebSocket traffic across Public (market data, no auth), Private (account, fills, positions, orders, authenticated login required), and Business (algo, grid and some specialised channels). A strategy subscribing to a Business-only channel on the Public URL gets nothing and looks "silent". Channel-to-URL mapping changes occasionally; check migration notes before adding subscriptions.
05 · Account mode
Portfolio margin mode is opt-in and changes margin math
Unified Account has multiple modes (cash, single-currency margin, multi-currency margin, portfolio margin). Multi-currency uses USD-converted assets as shared margin. Portfolio margin applies a risk-based model across spot, margin, perps, futures and options for capital efficiency. OKX has discontinued isolated margin positions inside multi-currency and portfolio margin modes, so position-sizing logic written for isolated mode does not transfer.
06 · US access
Global OKX blocks US retail; OKX US is a separate venue
In February 2025 the DOJ announced that OKX-affiliated entity Aux Cayes FinTech Co. Ltd. pleaded guilty to operating an unlicensed money transmitting business and agreed to penalties totalling about $505M ($420.3M forfeiture, $84.4M fine). Global OKX has restricted US persons as a matter of policy since 2017; that restriction continues on okx.com. OKX subsequently relaunched a separate US entity on okx.com/en-us in 2025 (live in 41 states; KY, NY, TX and a few territories excluded at launch). Strategies should target the OKX endpoint matching the account's licensed entity.
07 · IP allowlist
API keys without an IP allowlist are policy risks
OKX supports up to 20 IPs per key in the allowlist and strongly recommends binding keys to specific IPs. Without an IP bind, a leaked key can be used from anywhere. For containerised runtimes, use the static egress IP for the strategy's region and add it to the key's allowlist; rotate passphrase and secret on any suspected exposure (the passphrase cannot be retrieved).
SourceOKX API FAQ
Section 06 · Built for
Built for
TradingHost OKX runtimes are best suited to:
- Developers building strategies in AI IDEs (Cursor, Claude Code)
- Systematic crypto traders
- Quant developers
- CCXT, Freqtrade and Hummingbot users
- Teams moving from VPS hosting to containerised deployment
Connecting GitHub and creating your first strategy is free.
Section 08 · FAQ
FAQ
No. TradingHost is independent and is not affiliated with OKX.
No. Your strategy code connects to OKX and sends instructions according to your own logic, account permissions and integration method. TradingHost provides the runtime where that code runs.
No. OKX API access is provided by OKX. You are responsible for your OKX account, API permissions, credentials and compliance with OKX’s terms.
No. TradingHost is the cloud runtime where your strategy code runs. We do not provide signals, AI prediction models or pre-built strategies. With TradingHost you write or generate the strategy yourself (often with Cursor or Claude Code), keep it in GitHub as your code, and use TradingHost to run it in production. 3Commas, Cryptohopper and similar products own the strategy logic; TradingHost runs your strategy.
AWS and DigitalOcean give you raw compute. You handle OS updates, container orchestration, log shipping, secret rotation, region failover and uptime monitoring yourself. TradingHost gives you a managed runtime purpose-built for trading strategies: GitHub-native deployment, MCP-driven control from AI IDEs, log and health surfaces out of the box. If you want to operate the infrastructure yourself, AWS works. If you want the runtime as a managed service, TradingHost is the shorter path.
Yes. TradingHost runs Python strategies; pick the framework runtime that matches your stack or deploy your own repo.
Yes. TradingHost supports any language that can run inside a container.
CCXT exposes OKX (okx, formerly okex) for spot and perpetual swap trading and for account, market and historical data. Futures are also supported. Options market data is accessible via OKX's symbology, but options order execution through CCXT's unified methods is limited; route options orders through the native OKX v5 client. The OKX exchange object requires apiKey, secret, and password (the passphrase) plus standard sub-account headers. See the CCXT framework runtime for the full setup story.
Yes, if your project is designed that way. You can run multiple strategy processes or services inside one runtime, or separate them into different runtimes for isolation and operational clarity. See the TradingHost runtime page for the multi-strategy model.
The fastest path is to fork a TradingHost framework runtime: CCXT, Freqtrade or Hummingbot for a ready-to-deploy project. Or connect your own GitHub strategy repo. Linking a GitHub repo and creating a strategy is free; runtime plans are listed on the pricing page.
In your GitHub-controlled secrets workflow. TradingHost reads them at runtime through GitHub repository secrets, environment secrets or your own approved secret-management process. TradingHost does not need custody of your API key, secret or passphrase. See platform secrets for the full handling model.
No. Strategies should never need withdrawal permissions. Use scoped permissions (read, trade) and bind the key to your runtime's egress IP using OKX's IP allowlist (up to 20 IPs per key).
OKX uses a 3-part credential: API key, secret and passphrase. The passphrase is a user-set string entered at API key creation, sent on every authenticated request via OK-ACCESS-PASSPHRASE, and mixed into the HMAC-SHA256 signature alongside the secret. OKX cannot recover the passphrase if lost; you regenerate the key. Treat it as another secret.
Yes. TradingHost supports MCP-based control for AI IDEs including Cursor, Claude Code, GitHub Copilot and CLI-based AI agents. AI tools can inspect deployments, review logs, restart strategies and manage runtime workflows. MCP is a control and observability surface, not the trade execution path. See the MCP control surface for the full picture.
Both. The MCP control surface works equally well from CLI-based agents (Claude Code CLI, custom MCP clients, scripted MCP calls) and from inside an IDE. The GitHub-native deployment loop also works without any AI tooling: a regular git push to your main branch triggers a redeploy.
The runtime detects the crash and exposes the relevant logs and health information. Where supported, the affected strategy can be restarted without disrupting other strategies running in the same container. Your strategy code is still responsible for safe error handling, duplicate-order protection and risk controls. See observability for the logs and health surface.
50111 means OKX couldn't find the API key (wrong key, wrong environment, or demo key used against live). 50113 means the signature didn't validate. Usual causes: wrong or missing passphrase, wrong secret, clock drift in OK-ACCESS-TIMESTAMP (must be ISO 8601 UTC with ms precision), wrong pre-hash string order (timestamp + method + requestPath + body), or missing x-simulated-trading: 1 when using a demo key. Run NTP sync in the container and log the pre-hash string in non-production builds.
Yes. Create a demo API key from the OKX demo trading panel and add x-simulated-trading: 1 to every REST and WebSocket header. The host stays the same. Demo keys cannot trade live, live keys cannot trade demo, and the header is required on every call; flip both together when promoting.
Account mode is set at the Unified Account level and affects margin math. Multi-currency treats USD-converted assets as shared margin. Portfolio margin applies a risk-based model netting exposure across spot, margin, perps, futures and options. Isolated margin positions are no longer supported inside multi-currency or portfolio modes.
Global OKX (okx.com) restricts US persons under a 2017 policy. In February 2025, Aux Cayes FinTech (OKX-affiliated) pleaded guilty to operating an unlicensed money transmitting business in the US and paid $505M. A separate US entity (okx.com/en-us) relaunched in 2025 in 41 US states. OKX US and global OKX are different venues; confirm which entity your account belongs to before deploying.
TradingHost runs in the EU and US-East regions. Pick the region closest to the matching engine your strategy depends on. See the regions page for routing and proximity details.
No. TradingHost is focused on production runtime and deployment. Backtesting belongs in your research stack, framework or AlgoBuilder.