OKX (perpetual swaps)
Sync your OKX USDT- and USDC-margined perpetual swap trades with a read-only API key, funding payments included.
New and not yet tested against a live OKX account. The steps follow OKX's API documentation; if something differs on your screen, tell us with Support in the Settings menu on the left.
Steps
- 1In OKX open Profile → API (the API page under your account menu) and click Create API key. Use a new key just for Tradeopath.
- 2Give it a name and a passphrase you will remember (this is not your login password). Under Permission choose Read only. Leave Trade and Withdraw off.
- 3You can leave the IP restriction empty: OKX allows that for read-only keys. If you do restrict IPs, our sync service must be on the list, so leaving it open is simplest.
- 4Create the key and copy the API key, the secret key and your passphrase straight away. The secret is shown once.
- 5In Tradeopath open Connections, click Add connection and pick OKX. Choose Live, paste the three values, then Connect. Tradeopath asks OKX what the key may do before saving anything.
- 6Your swap account appears in your journal by itself within a couple of minutes, named like OKX-<uid>-SWAP. The dashboard then asks once what kind of account each one is (personal, prop or demo). New accounts use the UTC-midnight trading day.
Good to know
- Read-only is enforced. Tradeopath refuses a key that can trade or withdraw, and a key with any permission it does not recognise. If you made the key with Trade enabled, create a new read-only key instead of editing the old one. Every few hours the sync service checks the key again; if the key has gained trade or withdraw rights the connection stops with an error.
- Only perpetual swaps margined in USDT or USDC are synced. Coin-margined swaps (like BTC-USD-SWAP), dated futures, options and spot are not synced yet.
- OKX reports quantity in contracts. Tradeopath converts to coins with the contract value OKX publishes for each instrument (for example 0.01 BTC per BTC-USDT-SWAP contract), so the quantity you see is in BTC, ETH and so on.
- The last 3 months of fills are read when you connect (OKX keeps no more), then the last 2 hours are re-read every minute. Fills are never counted twice.
- Fees: OKX reports a fee as a negative number and a rebate as a positive one. Tradeopath shows a fee as a cost and a rebate as a credit.
- Funding: OKX funding payments come as account entries, not fills. Tradeopath attaches each one to the trade that was open at that moment and shows it as Funding on the closing fill. A trade is imported once it has closed (plus a few minutes for OKX to post the last funding entry), so a position that is still open appears when you close it.
- A position that was already open before the 3-month window is not seen from its start, so its first trade can look incomplete. Hedge mode (long and short on one contract at once) is netted per contract.
- Demo trading keys work too: choose Demo in the connect form. Demo keys are created in OKX's demo mode and are separate from live keys.
- OKX US (app.okx.com) and the EEA site are separate sites with their own API; keys from them will be refused as unknown. Only okx.com is supported.
- Your key, secret and passphrase are encrypted with a key only the sync service holds and cannot be read back, not even by this website. To stop syncing, click Disconnect on the Connections page and delete the key in OKX.
- A wrong key, secret or passphrase, or a key that is not read-only, shows an error and is not retried until you disconnect and connect again.
- Use one source per account. Importing the same trades from a CSV file as well can count them twice.