Overview of OKX Spot Historical Data
OKX (formerly OKEx) provides comprehensive historical data for spot trading pairs:
- High-cap currency pairs available since March 30, 2019
- All spot currency pairs available since March 11, 2021
๐ Explore OKX trading platforms for real-time market access alongside historical data analysis.
Downloadable CSV Files
Monthly historical datasets in CSV format are available without requiring an API key:
Key Features:
- First-day-of-month snapshots
- Open access (no authentication required)
- Standardized file formats
Bulk Download Process
To download all OKX datasets programmatically:
# Python 3.6+ required
# pip install tardis-dev
from tardis_dev import datasets, get_exchange_details
import logging
exchange = 'okex'
exchange_details = get_exchange_details(exchange)
for symbol in exchange_details["datasets"]["symbols"]:
data_types = symbol["dataTypes"]
symbol_id = symbol["id"]
from_date = symbol["availableSince"]
to_date = symbol["availableTo"]
if symbol_id in ['PERPETUALS', 'SPOT', 'FUTURES']:
continue
print(f"Downloading {exchange} {data_types} for {symbol_id} from {from_date} to {to_date}")
datasets.download(
exchange = exchange,
data_types = data_types,
from_date = from_date,
to_date = to_date,
symbols = [symbol_id],
api_key = "YOUR_API_KEY",
download_dir = "./datasets"
)๐ Complete CSV download guide with advanced options and file specifications.
API Access Methods
WebSocket API Compatibility
Historical data maintains identical format to OKX's real-time WebSocket v3 API, enhanced with local timestamps.
Python Client Example:
import asyncio
from tardis_client import TardisClient, Channel
tardis_client = TardisClient(api_key="YOUR_API_KEY")
async def replay():
messages = tardis_client.replay(
exchange="okex",
from_date="2020-01-01",
to_date="2020-01-02",
filters=[Channel(name="spot/trade", symbols=[])]
)
async for local_timestamp, message in messages:
print(message)
asyncio.run(replay())Market Data Collection Infrastructure
Current Setup (Since May 2022)
- Location: AWS Hong Kong (HK) region
- Configuration: VPC colocation
- Capture Method: Multiple WebSocket connections
Previous Configurations:
- May 2020-May 2022: GCP Tokyo (asia-northeast1)
- Initial deployment: GCP London (europe-west2)
Frequently Asked Questions
What data types are available for OKX Spot?
Available data includes:
- Trades
- Order book updates
- Historical quotes
How frequently is the historical data updated?
The system provides daily snapshots with monthly first-day datasets available for bulk download.
Can I access normalized data formats?
Yes, through either:
- Downloadable CSV files with standardized formats
- Client libraries that perform normalization
What's the advantage of using the API over CSV downloads?
API access provides:
- More granular time selection
- Real-time format compatibility
- Programmatic streaming capabilities
Where are OKX's servers physically located?
All OKX servers operate from Alibaba Cloud's Hong Kong region (cn-hongkong).
This comprehensive guide provides all necessary information for accessing and utilizing OKX Spot historical market data through both CSV downloads and API integration methods.