-
bitcoin $87959.907984 USD
1.34% -
ethereum $2920.497338 USD
3.04% -
tether $0.999775 USD
0.00% -
xrp $2.237324 USD
8.12% -
bnb $860.243768 USD
0.90% -
solana $138.089498 USD
5.43% -
usd-coin $0.999807 USD
0.01% -
tron $0.272801 USD
-1.53% -
dogecoin $0.150904 USD
2.96% -
cardano $0.421635 USD
1.97% -
hyperliquid $32.152445 USD
2.23% -
bitcoin-cash $533.301069 USD
-1.94% -
chainlink $12.953417 USD
2.68% -
unus-sed-leo $9.535951 USD
0.73% -
zcash $521.483386 USD
-2.87%
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.
- Bitcoin, eCash Fork, and Airdrop Dynamics: A Deep Dive into Crypto's Latest Controversies
- 2026-05-03 12:55:01
- Consensus 2026 Miami: Web3, Blockchain, Cryptocurrency, NFTs, Metaverse, Conference, May 5th — Where Wall Street Meets the Digital Frontier
- 2026-05-02 12:45:01
- Fed Holds Rates Steady, Triggering Bitcoin Price Drop Amidst Geopolitical Tensions
- 2026-05-01 06:45:01
- Bitcoin Miners Electrify the Grid: Ohio Gas Plant Acquisition Powers Up a New Era for Digital Gold
- 2026-05-01 00:45:01
- MegaETH's MEGA Token Hits the Big Apple: Setting New Performance Benchmarks for Real-Time Blockchain
- 2026-05-01 00:55:01
- Solana's Slippery Slope: Price Prediction Points to Resistance Loss and Potential Further Drops
- 2026-05-01 06:45:01
Related knowledge
How Is AVAX Futures Margin Requirement Calculated?
Jul 23,2026 at 03:40pm
AVAX Futures Margin Structure1. AVAX futures margin consists of two distinct components: initial margin and maintenance margin. These are calculated i...
Why Does ADA Contract Margin Ratio Trigger Warnings?
Jul 22,2026 at 09:00am
ADA Contract Margin Ratio Mechanics1. The ADA perpetual contract on major exchanges uses a dynamic margin ratio calculated in real time based on posit...
What Is ADAUSDT Perpetual Contract Funding Rate?
Jul 24,2026 at 08:19pm
Definition and Purpose of ADAUSDT Perpetual Contract Funding Rate1. The ADAUSDT perpetual contract funding rate is a periodic fee exchange mechanism a...
How Much Leverage Is Recommended for TON Perpetual Trading?
Jul 27,2026 at 05:20pm
TON Perpetual Trading Mechanics1. TON perpetual contracts operate on decentralized and centralized exchanges with varying margin models. 2. Funding ra...
What Is TON Futures Liquidation Price Formula?
Jul 23,2026 at 09:19am
TON Futures Liquidation Mechanism1. Liquidation in TON futures occurs when a trader’s margin balance falls below the maintenance margin requirement se...
What Is TONUSDT Perpetual Contract Funding Rate?
Jul 27,2026 at 02:39am
Definition and Core Mechanics1. TONUSDT perpetual contract funding rate is a periodic fee exchange mechanism applied exclusively to TON/USDT perpetual...
How Is AVAX Futures Margin Requirement Calculated?
Jul 23,2026 at 03:40pm
AVAX Futures Margin Structure1. AVAX futures margin consists of two distinct components: initial margin and maintenance margin. These are calculated i...
Why Does ADA Contract Margin Ratio Trigger Warnings?
Jul 22,2026 at 09:00am
ADA Contract Margin Ratio Mechanics1. The ADA perpetual contract on major exchanges uses a dynamic margin ratio calculated in real time based on posit...
What Is ADAUSDT Perpetual Contract Funding Rate?
Jul 24,2026 at 08:19pm
Definition and Purpose of ADAUSDT Perpetual Contract Funding Rate1. The ADAUSDT perpetual contract funding rate is a periodic fee exchange mechanism a...
How Much Leverage Is Recommended for TON Perpetual Trading?
Jul 27,2026 at 05:20pm
TON Perpetual Trading Mechanics1. TON perpetual contracts operate on decentralized and centralized exchanges with varying margin models. 2. Funding ra...
What Is TON Futures Liquidation Price Formula?
Jul 23,2026 at 09:19am
TON Futures Liquidation Mechanism1. Liquidation in TON futures occurs when a trader’s margin balance falls below the maintenance margin requirement se...
What Is TONUSDT Perpetual Contract Funding Rate?
Jul 27,2026 at 02:39am
Definition and Core Mechanics1. TONUSDT perpetual contract funding rate is a periodic fee exchange mechanism applied exclusively to TON/USDT perpetual...
See all articles














