OKX shows your history as orders, fills and bills, spread over several pages. None of them tells you in one line what a trade made once you count the fees and the funding you paid while it was open. This post covers how to get your OKX history out, what each way of doing it misses, and how to work out a trade's result by hand.
Two ways to get your OKX history out
A read-only API key. You create it in your OKX profile under "API and connections", tick only Read, and set a passphrase. A key that can only read cannot place trades or move money. OKX's API serves the last 3 months of history, so a key is the easy way to keep recent trading up to date.
The trading history export. On okx.com in a desktop browser, open Assets, then Order center, then Trading history, and click Download. Keep every instrument and account selected, set the date range to start from your first trade, and export it as CSV. This is how you get history older than 3 months. If OKX will not cover your whole history in one file, export each period on its own.
If your account is with OKX in the EEA, you sign in at my.okx.com instead, and both ways work the same there.
What the export does not tell you
The file is a list of what happened, not a list of trades. A perp position opened in two fills and closed in one is three rows, and funding is not part of any of them.
The file also cannot tell a move between your own OKX trading and funding accounts apart from money leaving OKX. Read on its own, every transfer looks like a deposit or a withdrawal, which makes your net deposits wrong. The API knows the difference.
And a file is a snapshot. It stops at the day you exported it, so to stay up to date you export again.
A worked example: one perp trade with fees and funding
These are example numbers, not real fills or OKX's current rates. Your own fee rate depends on your tier and on whether the fill was maker or taker, and funding changes at every settlement.
Say you go long 0.5 BTC on a perp at $90,000, a position worth $45,000. Both fills are taker fills at an example rate of 0.05%. The perp settles funding every 8 hours, the rate stays at 0.01% per settlement, and you hold for 3 days, through 9 settlements. You close at $91,200.
| Line | How it is worked out | Amount |
|---|---|---|
| Price move | 0.5 × ($91,200 − $90,000) | $600.00 |
| Entry fee | $45,000 × 0.05% | −$22.50 |
| Exit fee | $45,600 × 0.05% | −$22.80 |
| Funding paid | 9 × ($45,000 × 0.01%), so 9 × $4.50 | −$40.50 |
| Net PnL | $514.20 |
Count only the price and the trade made $600. Count the fees too and it made $554.70. The account actually made $514.20, so the funding line alone is about 7% of the gross. On a longer hold, or with a higher rate, it can take more than the fees. To keep the arithmetic simple, funding here uses the $45,000 entry value; in reality each settlement uses the position's value at that time.
OKX lists each contract's funding interval on its page, and not every perp settles every 8 hours, so check yours. The free funding fee calculator works this out for any position size, rate and interval.
If you trade on OKX, connect your account to a free Viktury journal and every funding payment lands on the trade it belongs to.
What Viktury does with your OKX history
In Viktury's OKX trading journal, you add an account with a read-only API key or by uploading your trading history export. With a key you paste the API key, the secret key and your passphrase, and Viktury checks the key with OKX before saving anything. A key that can trade or withdraw is turned down.
From there:
- Spot trades and converts come in as trades.
- Perpetual and futures trades come in as round trips, with every funding payment attached to the trade that was open when it was charged. EEA X-Perps work the same way.
- Deposits and withdrawals come in as money in and out, and with a key, moves between your trading and funding accounts show as internal moves instead.
You can start with a file and add a key later, or the other way round. Both carry OKX's own id for each row, so nothing is counted twice, and rows already imported are skipped when you upload an overlapping file. To fill in anything older than 3 months, upload an export for those dates to the same account.
Some things are not turned into trades yet: margin borrowing and repayment rows, and options. Viktury keeps those rows and tells you how many it could not name, rather than guess at them. Each OKX sub-account has its own key, so add each one as its own account.
Common questions
Can I export my OKX trade history to CSV?
Yes. On okx.com in a desktop browser, open Assets, then Order center, then Trading history, click Download and choose CSV. Upload the file to Viktury as it is: opening and saving it again in a spreadsheet app can break the import.
Which permissions does the API key need?
Only Read. Leave Trade and Withdraw off. OKX shows the passphrase only once, so keep a note of it when you create the key.
How far back does the API go?
OKX's API serves the last 3 months. For anything older, export those dates from OKX and upload the file to the same account.
How do I size my next OKX trade?
From the stop, not from a feeling. The free position size calculator takes your entry, your stop and the amount you want to risk, and counts the entry and exit fees inside that risk.
Open a free Viktury account and add OKX. The OKX setup guide walks through creating the key and downloading the export.