# OKX Futures

OKX historical data for **all its futures instruments** is available since **2019-03-30**.

{% embed url="<https://api.tardis.dev/v1/exchanges/okex-futures>" %}
See OKX Futures historical data coverage: available symbols, channels, date ranges and incidents
{% endembed %}

### Downloadable **CSV** files

Historical CSV datasets for the first day of each month are **available to download without API key**. See [downloadable CSV files documentation](/downloadable-csv-files/overview.md).

{% hint style="info" %}
Liquidations datasets are available since 2020-12-18.
{% endhint %}

| data type             | symbol         | date       |                                                                                                                     |
| --------------------- | -------------- | ---------- | ------------------------------------------------------------------------------------------------------------------- |
| incremental\_book\_L2 | BTC-USD-200103 | 2020-01-01 | [Download sample](https://datasets.tardis.dev/v1/okex-futures/incremental_book_L2/2020/01/01/BTC-USD-200103.csv.gz) |
| trades                | BTC-USD-200103 | 2020-01-01 | [Download sample](https://datasets.tardis.dev/v1/okex-futures/trades/2020/01/01/BTC-USD-200103.csv.gz)              |
| derivative\_ticker    | BTC-USD-200103 | 2020-01-01 | [Download sample](https://datasets.tardis.dev/v1/okex-futures/derivative_ticker/2020/01/01/BTC-USD-200103.csv.gz)   |

### API Access and data format

Historical data format is the same as provided by real-time OKX WebSocket **v5** API with addition of local timestamps (before 2021-12-23 it was **v3** API version). If you'd like to work with **normalized data format** instead (same format for each exchange) see [downloadable CSV files](/downloadable-csv-files/overview.md) or official [client libs](/api/quickstart.md) that can perform data normalization client-side.

{% tabs %}
{% tab title="Python" %}

```python
# pip install tardis-dev
import asyncio
from tardis_dev import Channel, replay

async def main():
    async for local_timestamp, message in replay(
        exchange="okex-futures",
        from_date="2024-01-01",
        to_date="2024-01-02",
        filters=[Channel(name="books-l2-tbt", symbols=["BTC-USD-240329"])],
        api_key="YOUR_API_KEY",
    ):
        # messages as provided by OKX real-time stream
        print(message)

asyncio.run(main())
```

See [Python client docs](/python-client/quickstart.md).
{% endtab %}

{% tab title="Node.js" %}

```javascript
// npm install tardis-dev
import { replay } from 'tardis-dev';

const messages = replay({
  exchange: 'okex-futures',
  from: '2024-01-01',
  to: '2024-01-02',
  filters: [{ channel: 'books-l2-tbt', symbols: ['BTC-USD-240329'] }],
  apiKey: 'YOUR_API_KEY'
});

// messages as provided by OKX real-time stream
for await (const { localTimestamp, message } of messages) {
  console.log(localTimestamp, message);
}
```

See [Node.js client docs](/node-client/quickstart.md).
{% endtab %}

{% tab title="cURL & HTTP API" %}

```bash
curl --compressed -g 'https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01&filters=[{"channel":"books-l2-tbt","symbols":["BTC-USD-240329"]}]&offset=0'
```

{% embed url="<https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01&filters=[{%22channel%22:%22books-l2-tbt%22,%22symbols%22:[%22BTC-USD-240329%22]}]&offset=0>" %}
Example API response for OKX Futures historical market data request
{% endembed %}

See [HTTP API docs](/api/http-api-reference.md).
{% endtab %}

{% tab title="cURL & tardis-machine" %}

```bash
curl -g 'localhost:8000/replay?options={"exchange":"okex-futures","filters":[{"channel":"books-l2-tbt","symbols":["BTC-USD-240329"]}],"from":"2024-01-01","to":"2024-01-02"}'
```

[Tardis-machine](/tardis-machine/quickstart.md) is a locally runnable server that exposes API allowing efficiently requesting historical market data for whole time periods in contrast to [HTTP API](/api/http-api-reference.md) that provides data only in minute by minute slices.

See [tardis-machine](/tardis-machine/quickstart.md) docs.
{% endtab %}
{% endtabs %}

### Captured real-time channels

{% embed url="<https://www.okx.com/docs-v5/en/>" %}
See OKX Futures WebSocket API docs providing documentation for each captured channel's format
{% endembed %}

{% hint style="info" %}
Click any channel below to see [HTTP API](/api/http-api-reference.md#data-feeds-exchange) response with historical data recorded for it.
{% endhint %}

**Current channels (API v5, since 2021-12-23):**

* [trades](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22trades%22}]) Public futures trade executions stream
* [trades-all](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22trades-all%22}]) — available since **2023-10-19** All trades stream including non-aggregated trade messages
* [books-l2-tbt](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22books-l2-tbt%22}]) Tick-by-tick L2 futures order book updates
* [books](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22books%22}]) — available since **2023-02-24**, until **2024-07-19** Incremental futures order book depth updates
* [bbo-tbt](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22bbo-tbt%22}]) — available since **2022-05-05** Tick-by-tick best bid and offer updates
* [tickers](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22tickers%22}]) 24h futures ticker updates
* [liquidations](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22liquidations%22}]) Liquidation events with at most one update per second per contract
* [liquidation-orders](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-03-01\&filters=\[{%22channel%22:%22liquidation-orders%22}]) — available since **2023-03-30** Liquidation orders with at most one update per second per contract
* [open-interest](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22open-interest%22}]) Open interest updates
* [mark-price](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22mark-price%22}]) Mark price updates with keepalive up to 10s when unchanged
* [index-tickers](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22index-tickers%22}]) Index ticker updates with keepalive up to 1m when unchanged
* [price-limit](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22price-limit%22}]) Price limit updates
* [status](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22status%22}]) Exchange status and maintenance notifications
* [instruments](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22instruments%22}]) Instrument state updates (listing, suspension, parameter changes)
* [long-short-account-ratio](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22long-short-account-ratio%22}]) — generated channel Long/short account ratio snapshots from REST statistics endpoint
* [taker-volume](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22taker-volume%22}]) — generated channel Taker buy/sell volume snapshots from REST statistics endpoint
* [estimated-price](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22estimated-price%22}]) Estimated delivery/settlement price updates
* [public-block-trades](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22public-block-trades%22}]) — available since **2023-01-01** Public block trades stream
* [public-struc-block-trades](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-01-01\&filters=\[{%22channel%22:%22public-struc-block-trades%22}]) — available since **2023-01-01** Public structured block trades stream
* [taker-volume-contract](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-09-01\&filters=\[{%22channel%22:%22taker-volume-contract%22}]) — generated channel, available since **2024-08-08** Contract-level taker buy/sell volume snapshots from REST statistics endpoint
* [long-short-account-ratio-contract-top-trader](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-09-01\&filters=\[{%22channel%22:%22long-short-account-ratio-contract-top-trader%22}]) — generated channel, available since **2024-08-08** Contract-level top-trader long/short account ratio snapshots from REST statistics endpoint
* [long-short-position-ratio-contract-top-trader](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-09-01\&filters=\[{%22channel%22:%22long-short-position-ratio-contract-top-trader%22}]) — generated channel, available since **2024-08-08** Contract-level top-trader long/short position ratio snapshots from REST statistics endpoint
* [long-short-account-ratio-contract](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2024-09-01\&filters=\[{%22channel%22:%22long-short-account-ratio-contract%22}]) — generated channel, available since **2024-08-08** Contract-level long/short account ratio snapshots from REST statistics endpoint

**Legacy channels (API v3, until 2021-12-23):**

* [futures/trade](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2019-12-01\&filters=\[{%22channel%22:%22futures/trade%22}]) Public futures trade executions stream
* [futures/depth](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2019-12-01\&filters=\[{%22channel%22:%22futures/depth%22}]) — available **until 2020-01-29** Incremental futures order book updates (legacy depth channel)
* [futures/depth\_l2\_tbt](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2020-01-01\&filters=\[{%22channel%22:%22futures/depth_l2_tbt%22,%22symbols%22:\[%22BTC-USD-200103%22]}]) — available since **2019-12-03** Tick-by-tick L2 futures order book updates with sequencing
* [futures/ticker](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2020-01-01\&filters=\[{%22channel%22:%22futures/ticker%22,%22symbols%22:\[%22BTC-USD-200103%22]}]) 24h futures ticker updates
* [futures/liquidation](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2021-01-01\&filters=\[{%22channel%22:%22futures/liquidation%22}]) — available since **2020-12-17** Futures liquidation events
* [futures/mark\_price](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2020-01-01\&filters=\[{%22channel%22:%22futures/mark_price%22,%22symbols%22:\[%22BTC-USD-200103%22]}]) Mark price with keepalive up to 10s when unchanged
* [index/ticker](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2020-01-01\&filters=\[{%22channel%22:%22index/ticker%22}]) — available since **2019-09-20** Index ticker for futures contracts with keepalive up to 1m when unchanged
* [system/status](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2020-08-01\&filters=\[{%22channel%22:%22system/status%22}]) — available since **2020-07-01** Exchange status and maintenance notifications
* [information/sentiment](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2021-01-01\&filters=\[{%22channel%22:%22information/sentiment%22}]) — generated channel, available since **2020-10-28** Market sentiment ratio metrics
* [information/long\_short\_ratio](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2021-01-01\&filters=\[{%22channel%22:%22information/long_short_ratio%22}]) — generated channel, available since **2020-10-28** Long/short account ratio metrics
* [information/margin](https://api.tardis.dev/v1/data-feeds/okex-futures?from=2021-01-01\&filters=\[{%22channel%22:%22information/margin%22}]) — generated channel, available since **2020-10-28** Margin ratio metrics

### Market data collection details

[Market data collection infrastructure](/faq/general.md#what-is-your-infrastructure-setup) for OKX Futures since **2022-05-04** is located in AWS HK region (Hong Kong, China, VPC colo setup), before that, since **2020-05-15** it was located in GCP asia-northeast1 region (Tokyo, Japan) and initially it was located in GCP europe-west2 region (London, UK).

Real-time market data is captured via **multiple WebSocket connections** to `wss://awscolows1.okx.com:8443/ws/v5/public`.

{% hint style="info" %}
OKX servers are located in Alibaba Cloud cn-hongkong region (Hong Kong, China).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tardis.dev/historical-data-details/okex-futures.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
