-
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.
- WisdomTree Eyes Crypto Profitability as Traditional Finance Embraces On-Chain Innovation
- 2026-02-04 10:20:01
- Big Apple Bit: Bitcoin's Rebound Hides a Deeper Dive, Say Wave 3 Watchers
- 2026-02-04 07:00:03
- DeFi Vaults Poised for 2026 Boom: Infrastructure Matures, Yield Optimization and Liquidity Preferences Shape the Future
- 2026-02-04 06:50:01
- Royal Canadian Mint Unveils 'Gold Dime' with Astounding High Value, Captivating Collectors
- 2026-02-04 06:55:01
- Datavault AI Dives into Digital Collectibles with Dream Bowl Meme Coin II, Navigating the Wild West of Web3
- 2026-02-04 06:30:02
- New VistaShares ETF Merges Bitcoin and Treasuries for Enhanced Income
- 2026-02-04 06:55:01
Related knowledge
How to close a crypto contract position manually or automatically?
Feb 01,2026 at 11:19pm
Manual Position Closure Process1. Log into the trading platform where the contract is active and navigate to the 'Positions' or 'Open Orders' tab. 2. ...
How to understand the impact of Bitcoin ETFs on crypto contracts?
Feb 01,2026 at 04:19pm
Bitcoin ETFs and Market Liquidity1. Bitcoin ETFs introduce institutional capital directly into the spot market, increasing order book depth and reduci...
How to trade DeFi contracts during the current liquidity surge?
Feb 01,2026 at 07:00am
Understanding Liquidity Dynamics in DeFi Protocols1. Liquidity surges in DeFi are often triggered by coordinated capital inflows from yield farming in...
How to use social trading to copy crypto contract experts?
Feb 02,2026 at 07:40am
Understanding Social Trading Platforms1. Social trading platforms integrate real-time market data with user interaction features, enabling traders to ...
How to trade BNB contracts and save on transaction fees?
Feb 03,2026 at 12:39am
Understanding BNB Contract Trading Mechanics1. BNB contracts are derivative instruments traded on Binance Futures, allowing users to gain leveraged ex...
How to build a consistent crypto contract trading plan for 2026?
Feb 02,2026 at 10:59pm
Defining Contract Specifications1. Selecting the underlying asset requires evaluating liquidity depth, historical volatility, and exchange support acr...
How to close a crypto contract position manually or automatically?
Feb 01,2026 at 11:19pm
Manual Position Closure Process1. Log into the trading platform where the contract is active and navigate to the 'Positions' or 'Open Orders' tab. 2. ...
How to understand the impact of Bitcoin ETFs on crypto contracts?
Feb 01,2026 at 04:19pm
Bitcoin ETFs and Market Liquidity1. Bitcoin ETFs introduce institutional capital directly into the spot market, increasing order book depth and reduci...
How to trade DeFi contracts during the current liquidity surge?
Feb 01,2026 at 07:00am
Understanding Liquidity Dynamics in DeFi Protocols1. Liquidity surges in DeFi are often triggered by coordinated capital inflows from yield farming in...
How to use social trading to copy crypto contract experts?
Feb 02,2026 at 07:40am
Understanding Social Trading Platforms1. Social trading platforms integrate real-time market data with user interaction features, enabling traders to ...
How to trade BNB contracts and save on transaction fees?
Feb 03,2026 at 12:39am
Understanding BNB Contract Trading Mechanics1. BNB contracts are derivative instruments traded on Binance Futures, allowing users to gain leveraged ex...
How to build a consistent crypto contract trading plan for 2026?
Feb 02,2026 at 10:59pm
Defining Contract Specifications1. Selecting the underlying asset requires evaluating liquidity depth, historical volatility, and exchange support acr...
See all articles














