OKX DCA bot: setup and first settings
To run a DCA bot on OKX you need an API key with Read and Trade permission and the passphrase you chose for it, USDT in your trading account, and, for perpetuals, an account mode above Spot mode. OKX sizes perpetuals in contracts, so every order is rounded up to a whole lot: the 283.75 USDT ladder worked here uses 294.11 USDT on BTC-USDT-SWAP.
In short
- OKX keys have three parts: API key, secret key and a passphrase you choose. OKX cannot recover a lost passphrase; you make a new key.
- Give the key Read and Trade. Never Withdraw.
- Perpetuals need the OKX account out of Spot mode; spot bots do not.
- OKX perpetuals trade in contracts (BTC-USDT-SWAP: 0.01 BTC each). QuantPhi converts and rounds every entry up to the lot, so a deal uses a little more than its settings say.
- The money a deal needs is the whole ladder: 294.11 USDT for the example here, as margin divided by the leverage on perpetuals.
What you need before you start
- An OKX account with USDT in the trading account. OKX’s funding account cannot trade: move the USDT across first. One trading account serves both spot and perpetuals.
- A QuantPhi account. You can start free; create one here.
- Ten minutes. The bot then runs on QuantPhi’s servers around the clock and trades on your OKX account through the API key; your funds never leave OKX.
This guide is about a DCA trading bot: one that adds to a position through safety orders when the price moves against it and closes the whole position at a take profit. If the idea is new, read What is a DCA bot? first. Setting up on Bybit instead? The Bybit DCA bot guide covers it.
Step 1: create an API key with a passphrase on OKX
- On OKX, open the API page of your account and create a new key for the bot.
- Tick Read and Trade. Leave Withdraw off: a trading bot never needs it.
- Choose a passphrase and write it down. OKX keeps only a salted hash of it and cannot show it to you again; if it is lost, the only way back is a new key.
- Copy the API key and the secret key. Together with the passphrase these are the three fields the bot asks for.
On OKX one key covers both spot and perpetuals: there is no separate spot or contract permission to tick, as there is on some other exchanges. OKX also notes that a key with Trade permission and no IP address bound to it expires after 14 days without use; a bot that is running uses its key all the time. OKX changes its screens from time to time, so follow the wording on OKX’s own page. Why withdrawals must stay off, and what a sub-account adds, is in how to connect a trading bot safely.
Step 2: connect the key to QuantPhi
- In QuantPhi open Exchange accounts and choose Add account.
- Pick OKX, give the account a name, and paste the API key, the API secret and the API passphrase. Without the passphrase QuantPhi refuses the key at once and tells you which field is missing.
- Press Verify and save. QuantPhi asks OKX what the key may do and shows it on the account: Spot + futures trading, spot only or futures only, and No withdrawal.
If the account shows “No trading permission”, the key was created read-only: make a new one with Trade ticked.
Want a dry run first? OKX’s Demo Trading works too, but it needs its own key: on OKX go to Trade → Demo Trading, open the demo Personal Center and create a Demo Trading API key there. Add it in QuantPhi with Testnet account ticked. A live key on a testnet account, or a demo key on a live one, is refused by OKX.
Step 3: spot or USDT perpetual, and OKX’s account mode
| Spot | USDT perpetual | |
|---|---|---|
| The bot trades | The coin itself, bought with your USDT | A perpetual swap settled in USDT (for example BTC-USDT-SWAP) |
| Direction | Long only | Long or short |
| Leverage | None | You choose it in the bot |
| Liquidation | None: a deal in loss can wait | Yes: the exchange can close the position |
| Order size on OKX | Coins | Contracts; QuantPhi converts |
| OKX account mode | Any | Not Spot mode |
Account mode. An OKX account left in Spot mode can hold coins but cannot open perpetual positions. Switch it to Futures mode (or a margin mode) in OKX’s trading settings before you run a futures bot. QuantPhi checks this when you connect the key; an account still in Spot mode has its futures side refused, with that reason, instead of every futures order failing later.
Margin mode (cross or isolated) is chosen in QuantPhi on the exchange account and applies to every futures bot on it; QuantPhi sends it with each OKX order. The position mode (one-way or long/short) is read from your OKX account and followed; QuantPhi never switches it. Coin-margined (inverse) contracts are not supported.
Step 4: a first ladder, converted into OKX contracts
These are the numbers the DCA bot calculator opens with: base order 20 USDT, first safety order 20 USDT, 5 safety orders, price deviation 1.5 %, step scale 1.2, volume scale 1.5, take profit 1.5 %. Here they are placed on OKX’s BTC-USDT-SWAP, with the entry at 69,000 USDT (BTC traded near 69,003 on OKX on 13 November 2026). OKX’s own instrument list gives this perpetual a contract value of 0.01 BTC, and a lot size and minimum order of 0.01 contracts: the smallest order is 0.0001 BTC.
| Order | Fills at | Settings ask | Contracts, exact | Contracts sent | BTC | USDT used |
|---|---|---|---|---|---|---|
| Base | 69,000.0 | 20 USDT | 0.029 | 0.03 | 0.0003 | 20.70 |
| Safety 1 (−1.5 %) | 67,965.0 | 20 USDT | 0.029 | 0.03 | 0.0003 | 20.39 |
| Safety 2 (−3.3 %) | 66,723.0 | 30 USDT | 0.045 | 0.05 | 0.0005 | 33.36 |
| Safety 3 (−5.5 %) | 65,232.6 | 45 USDT | 0.069 | 0.07 | 0.0007 | 45.66 |
| Safety 4 (−8.1 %) | 63,444.1 | 67.50 USDT | 0.106 | 0.11 | 0.0011 | 69.79 |
| Safety 5 (−11.2 %) | 61,297.9 | 101.25 USDT | 0.165 | 0.17 | 0.0017 | 104.21 |
The settings add up to 283.75 USDT. The orders actually sent add up to 0.46 contracts and 294.11 USDT, 3.7 % more. QuantPhi rounds every entry up to the lot, so an order is never worth less than you asked and never falls below OKX’s minimum by a rounding; the cost is at most one lot per order, here never more than 0.0001 BTC (6.90 USDT at this price). Exits round down, because a deal cannot sell more than it holds.
At 3× leverage the full ladder ties up about 98.04 USDT of margin. The position is still 294.11 USDT: leverage divides the margin, not the risk. Check your OKX trading balance against the full ladder times the deals the bot may have open at once: two deals, 588.22 USDT.
The ladder ends 11.2 % below the entry, and the price then has to come back about 5.8 % from the lowest fill to reach the take profit. If it falls further, there is nothing left to average with: the deal waits with its money tied up until the price returns, or until a stop loss or a time limit closes it at a loss, and on a perpetual a further fall can reach the liquidation price. A DCA bot does not predict the price and does not guarantee a profit.
Small coins have their own contract value, so the rounding matters more or less from pair to pair; QuantPhi reads each one from OKX. On spot, BTC-USDT trades in steps of 0.00000001 BTC, so the rounding is too small to see. Fees are not in the table. What each field does is in DCA bot settings explained, and how many safety orders to use in safety orders explained.
Step 5: create the bot and start it
- Choose New bot and the DCA strategy.
- Pair & capital: your OKX account, the market (spot or futures), the pairs the bot may trade, the direction, the base order; on futures, the leverage.
- Safety orders: the ladder: safety order size, max safety orders, price deviation, step scale, volume scale.
- Entry and Exit & limits: how many deals may be open at once (max active deals), the take profit and an optional stop loss.
- Review: the form lists every order of the ladder with its price and warns how much each pair needs if the whole ladder fills. Compare that with your balance, and leave a few percent for the rounding above.
- Create the bot. It starts paused; press Start when you are ready. Pause later stops new deals only; open deals run to their end.
Before real money, a backtest replays the same settings on the pair’s OKX price history, with fees. The first download of a long OKX history takes a while (15–25 minutes for 12 months); you can leave the page while it runs. The live results page shows how real bots have done, in percent; past results do not guarantee future returns.
If OKX refuses an order
- 50123, no trading permission: the key can read but not trade. Create a new key with Trade ticked, then use Test connection on the account.
- 50119, API key doesn’t exist: usually a Demo Trading key added as a live account, or a live key added as a testnet account. Add it again with Testnet account set the right way.
- The account is in Spot mode: futures cannot open. Switch the account mode on OKX, then test the connection again.
- Not enough balance: the ladder needs more than the trading account holds, or the USDT is still in the funding account. Move it, or lower the order sizes, the number of safety orders or max active deals.
- The order is too small: below one lot of the pair. Raise the base order and the safety order size.
A key that stopped working has been deleted on OKX or has expired. Deleting the key on OKX is also how you cut the bot’s access at once.
Questions
Why does OKX ask for a passphrase?
It is a third secret you choose when you create the key, sent with every request alongside the key and the secret. OKX cannot recover it; a lost passphrase means a new key.
Which API permissions does an OKX DCA bot need?
Read and Trade. Never Withdraw.
How much money do I need for a DCA bot on OKX?
The whole ladder of one deal, times the deals open at once, plus a little for rounding to whole lots on perpetuals. The example ladder here uses 294.11 USDT per deal on BTC-USDT-SWAP.
Why can’t my bot trade OKX futures?
Most often the OKX account is still in Spot mode, which cannot hold perpetual positions. Switch it to Futures mode in OKX’s trading settings, then test the connection again.
Can a DCA bot short on OKX?
Yes, on USDT perpetuals: the bot sells first, adds as the price rises and buys back at a take profit below the average. Spot bots are long only.
Try it on your own exchange account
QuantPhi runs DCA, grid, rebalance and Hedge Stop bots on Bybit, OKX, Bitget, Binance, BingX, Coinbase and Hyperliquid. There is a free plan; your funds never leave your exchange.
Create a free accountCrypto trading involves risk; past results and backtests do not guarantee future returns. This guide is education, not investment advice.