-
bitcoin $76464.156879 USD
0.86% -
ethereum $2445.495804 USD
1.91% -
tether $0.999058 USD
-0.01% -
bnb $725.991560 USD
1.93% -
xrp $1.303704 USD
0.85% -
usd-coin $0.999942 USD
0.00% -
solana $100.064497 USD
3.06% -
tron $0.335357 USD
0.24% -
zcash $1358.632097 USD
14.53% -
hyperliquid $79.355311 USD
2.37% -
dogecoin $0.081165 USD
1.50% -
monero $495.294239 USD
-2.55% -
chainlink $11.205049 USD
3.83% -
unus-sed-leo $8.932502 USD
0.55% -
cardano $0.198341 USD
1.78%
How to access historical trading data for Bybit contracts?
Bybit provides historical contract trade data via API or web interface, enabling backtesting and analysis for perpetual and futures contracts.
Aug 13, 2025 at 11:36 am
Understanding Historical Trading Data on Bybit
Historical trading data for Bybit contracts refers to past records of executed trades, including information such as price, quantity, timestamp, side (buy/sell), and contract type. This data is essential for traders who engage in technical analysis, backtesting strategies, or auditing their trading performance. Bybit provides access to this data through multiple methods, including its official API and web interface. The data typically covers perpetual contracts and futures contracts across various cryptocurrencies like BTCUSD, ETHUSD, and others.
It is important to distinguish between public trade history and personal trade history. Public data reflects all trades executed on the order book and is available to any user. Personal trade history includes only the trades executed by your account and requires authentication to access. Both types of data are structured in JSON format when retrieved via API, making them suitable for integration into analytical tools.
Accessing Public Trade History via Bybit API
To retrieve public historical trade data for Bybit contracts, use the official Bybit REST API endpoint:
- API Endpoint:
https://api.bybit.com/v5/market/recent-trade
This endpoint returns the most recent trades for a specified symbol. To access deeper historical records, you must paginate using the cursor parameter returned in each response. Here’s how to make the request:
- Use an HTTP GET request with required parameters:
category: Set tolinearfor USDT contracts orinversefor inverse contractssymbol: Specify the contract, e.g.,BTCUSDTlimit: Number of records per request (maximum 1000)cursor: Use the cursor from the previous response to fetch the next batch
Example request in Python:
import requests
url = 'https://api.bybit.com/v5/market/recent-trade'params = {
'category': 'linear',
'symbol': 'BTCUSDT',
'limit': 100
}
response = requests.get(url, params=params)data = response.json()
The returned JSON includes fields like price, size, side, time, and symbol. To retrieve older data, extract the cursor from the next_page_cursor field and include it in the next request.
Retrieving Personal Trade History Using API Authentication
To access your personal contract trade history, authentication is required. You must generate an API key with 'Order' and 'Read' permissions from your Bybit account settings. The relevant endpoint is:
- API Endpoint:
https://api.bybit.com/v5/order/execution-list
This endpoint returns filled contract orders associated with your account. Required parameters include:
category:linearorinversesymbol: e.g.,BTCUSDTstart_timeandend_time: Unix timestamps to define the time rangelimit: Max 50 records per requestapi_key,timestamp, andsign: Authentication headers
Steps to generate the request:
- Generate a timestamp in milliseconds
- Create a signature using HMAC SHA256 with your API secret
- Include headers:
X-BAPI-API-KEY,X-BAPI-TIMESTAMP,X-BAPI-SIGN
Example Python code for signing:
import hmacimport time
api_key = 'your_api_key'api_secret = 'your_api_secret'timestamp = str(int(time.time() * 1000))
param_str = f'category=linear&symbol=BTCUSDT&limit=50&start_time=1700000000000&end_time=1701000000000'signature = hmac.new(api_secret.encode(), param_str.encode(), digestmod='sha256').hexdigest()
headers = {
'X-BAPI-API-KEY': api_key,
'X-BAPI-TIMESTAMP': timestamp,
'X-BAPI-SIGN': signature
}
response = requests.get(url, params=params, headers=headers)
Each record includes exec_price, exec_qty, side, fee, and order_id.
Using Bybit Web Interface for Trade History
For users who prefer not to use APIs, Bybit offers a web-based interface to view personal contract trade history. Log in to your Bybit account and navigate to:
- Derivatives → Order → Trade History
Here, you can:
- Select Linear Contracts or Inverse Contracts
- Choose a specific symbol from the dropdown
- Filter by date range
- Export up to 100 records at a time in CSV format
The displayed columns include Symbol, Side, Quantity, Price, Fee, Closed PnL, and Time. Note that the web interface does not allow bulk export of all historical data in one click. You must manually paginate through dates and download multiple CSV files if needed.
Processing and Storing Historical Data
Once retrieved, historical trade data should be stored for analysis. Recommended formats include CSV, Parquet, or database tables. For continuous data collection, set up a cron job or script that periodically calls the API and appends new records.
Key considerations:
- Rate limits: Bybit allows 60 requests per minute for public endpoints and 120 for private
- Data deduplication: Use exec_id or trade_time as unique identifiers
- Timezone handling: All timestamps are in UTC
- Data retention: Bybit retains personal trade history for up to 6 months on the web interface, but API access may allow retrieval of older data depending on account activity
Store data in structured directories:
/trade_data/ /public/
btcusdt_20231201.csv
/private/
my_trades_20231201.csv
Use pandas in Python to merge and analyze:
import pandas as pd
df = pd.read_csv('btcusdt_20231201.csv')df['time'] = pd.to_datetime(df['time'], unit='ms')
Frequently Asked Questions
How far back does Bybit’s contract trade history go?Bybit’s public API typically retains recent trade data for up to 7 days in the recent-trade endpoint. For older public data, third-party aggregators or custom data collection scripts are needed. Personal trade history via the private API can go back several months, depending on account creation date and Bybit’s internal retention policy.
Can I get tick-level historical data for backtesting?Yes, the /v5/market/recent-trade endpoint provides tick-level data including price and volume per trade. To build a complete tick history, you must continuously poll the API or use WebSocket streams (publicTrade topic) to capture real-time trades and store them.
Why am I getting an “Invalid signature” error when accessing private data?This error occurs when the HMAC signature does not match. Ensure the parameter string is correctly sorted alphabetically, the timestamp is in milliseconds, and the API secret is correctly entered. Also verify that the HTTP method (GET/POST) matches the expected format for the endpoint.
Is historical data available for expired futures contracts?Yes, historical trade data for expired futures contracts can be accessed via the API by specifying the correct symbol name used during the contract’s active period. For example, BTCUSD231229 for the December 2023 BTC inverse futures. The same API endpoints apply, with category=inverse and the appropriate symbol.
Disclaimer:info@kdj.com
The information provided is not trading advice. kdj.com does not assume any responsibility for any investments made based on the information provided in this article. Cryptocurrencies are highly volatile and it is highly recommended that you invest with caution after thorough research!
If you believe that the content used on this website infringes your copyright, please contact us immediately (info@kdj.com) and we will delete it promptly.
- HBO Max Reddit Account Hijacked for Crypto-Stealing Malware Attack: A New Wave of Sophisticated Scams
- 2026-09-17 12:50:01
- House Committee Advances Strategic Bitcoin Reserve Bill, Shaping Future of Federal Crypto Holdings
- 2026-09-17 12:40:01
- Crypto Tax Bill: Digital Assets Face New Tax Rules, But Clarity Remains Elusive
- 2026-09-17 09:10:02
- MemeToro Revolutionizes Memecoin Launches on BNB Chain with AI and Fair-Launch Smart Contracts
- 2026-09-17 09:10:01
- Bitcoin, Ether Brace for Continued Volatility as Fed's Unanimous Rate Hike Signals Hawkish Resolve
- 2026-09-17 09:20:02
- Navigating Crypto Presales Safely: Essential Tips for Buying Crypto, Trust Wallet Safety, and Verifying Contracts
- 2026-09-17 08:50:02
Related knowledge
How to Check SOL Futures Volume and Open Interest?
Sep 14,2026 at 12:40am
Accessing SOL Futures Market Data1. Navigate to the official exchange platform where SOL perpetual or quarterly futures are listed, such as Bybit, OKX...
How to Check XRP Futures Volume and Open Interest?
Sep 15,2026 at 05:00am
Accessing Real-Time XRP Futures Data1. Visit major derivatives exchanges that list XRP perpetual and quarterly futures contracts, including Binance, B...
How to Check DOGE Futures Volume and Open Interest?
Sep 12,2026 at 08:39am
Understanding DOGE Futures Volume1. Futures volume refers to the total number of DOGE futures contracts traded within a specific time frame, usually m...
How to Check ETH Futures Volume and Open Interest?
Sep 16,2026 at 07:00pm
Accessing Real-Time ETH Futures Data1. Major centralized exchanges such as Binance, Bybit, and OKX provide live dashboards displaying ETH perpetual an...
How to Check BTC Futures Volume and Open Interest?
Sep 12,2026 at 03:19pm
Data Sources for BTC Futures Metrics1. CoinGlass API v4 delivers real-time funding rates, liquidation heatmaps, and granular open interest breakdowns ...
How to Read the DOGEUSDT Perpetual Contract Chart?
Sep 11,2026 at 07:19pm
Understanding Price Action on DOGEUSDT Perpetual Charts1. Candlestick formation reveals immediate market sentiment—green candles indicate buying domin...
How to Check SOL Futures Volume and Open Interest?
Sep 14,2026 at 12:40am
Accessing SOL Futures Market Data1. Navigate to the official exchange platform where SOL perpetual or quarterly futures are listed, such as Bybit, OKX...
How to Check XRP Futures Volume and Open Interest?
Sep 15,2026 at 05:00am
Accessing Real-Time XRP Futures Data1. Visit major derivatives exchanges that list XRP perpetual and quarterly futures contracts, including Binance, B...
How to Check DOGE Futures Volume and Open Interest?
Sep 12,2026 at 08:39am
Understanding DOGE Futures Volume1. Futures volume refers to the total number of DOGE futures contracts traded within a specific time frame, usually m...
How to Check ETH Futures Volume and Open Interest?
Sep 16,2026 at 07:00pm
Accessing Real-Time ETH Futures Data1. Major centralized exchanges such as Binance, Bybit, and OKX provide live dashboards displaying ETH perpetual an...
How to Check BTC Futures Volume and Open Interest?
Sep 12,2026 at 03:19pm
Data Sources for BTC Futures Metrics1. CoinGlass API v4 delivers real-time funding rates, liquidation heatmaps, and granular open interest breakdowns ...
How to Read the DOGEUSDT Perpetual Contract Chart?
Sep 11,2026 at 07:19pm
Understanding Price Action on DOGEUSDT Perpetual Charts1. Candlestick formation reveals immediate market sentiment—green candles indicate buying domin...
See all articles














