Exchange guide

OKX trade history CSV: instruments, sizes, and fills

OKX exports are rich but compact: instrument names, position side, fees and timestamps all matter. This guide explains how to read the file and how to avoid the two most common OKX import errors: contract size and side confusion.

Free · local-first · no exchange API key required

How to export OKX trade history

1

Open Trade History

Log in to OKX on desktop. Open Orders → Order History, then switch to Trade History. For derivatives, choose the instrument type and the contract you want.

2

Set the date range

Pick the period and instrument. If you trade many contracts, export one instrument at a time so contract sizes are easier to verify.

3

Export CSV

Use the Export or Download button and choose CSV. OKX may place the file in a Data Center or email it to you.

4

Keep the Position Side column

If your export includes PosSide (Long/Short), keep it. It tells the importer which side a fill opens or closes in hedge mode.

CSV columns you need to understand

Exact headers vary by export type and region. These are the columns that change the import result.

ColumnWhat it means
InstrumentMarket or contract, for example BTC-USDT or BTC-USDT-SWAP.
SideBuy or Sell on the fill.
PriceFill price.
SizeQuantity. On derivatives this is often contracts, not BTC.
FeeTrading fee; check the fee currency.
TimestampFill time, often in milliseconds.
Trade IDUnique fill ID; useful for deduplication.
PosSideLong, Short or BOTH in hedge/one-way mode.

Common OKX CSV mistakes

  • OKX derivatives Size is usually contracts. Set the contract multiplier (for example 0.01 BTC per contract) before comparing P&L.
  • Timestamp can be a 13-digit millisecond value; a date parser that only accepts YYYY-MM-DD will reject it.
  • Hedge mode uses PosSide. Without it, a Buy may look like a new long when it is actually closing a short.
  • Fee currency may not be USDT. Convert it before relying on net P&L.
The importer

How SureGain handles OKX files

SureGain detects Instrument, Size and Trade ID, keeps PosSide when present, and accepts both ISO dates and epoch timestamps. Use Pair exchange fills for trade history; use the closed-trade importer for position history with open and close prices.

Position history is already one row per position, so it does not need FIFO pairing. Trade history is fills, so it does.

FAQ

Is OKX Size in coins or contracts?+

For derivatives it is usually contracts. Spot Size is the base asset. Check the instrument and set the contract multiplier for futures before importing.

Can I import OKX position history instead of fills?+

Yes. Position history with Open Price and Close Price is a closed-trade file; use the closed-trade importer. Trade history is a fills file; use fills pairing.

Why does my OKX file fail on dates?+

OKX often exports millisecond timestamps. SureGain now accepts 10-digit seconds, 13-digit milliseconds and ISO dates.

Does SureGain need my OKX API key?+

No. The current importer uses CSV only. There is no API key, withdrawal permission, or exchange login.

Other exchange guides

SureGain is a trade journaling tool, not an exchange or financial adviser. CSV exports can be incomplete; verify imported numbers before making decisions.