Get Trade History
Query users' execution records, sorted by execTime
in descending order. However, for Classic spot
, they are sorted by execId
in descending order.
tip
- Response items will have sorting issues When 'execTime' is the same, it is recommended to sort according to
execId+OrderId+leavesQty
. This issue is currently being optimized and will be released. If you want to receive real-time execution information, Use the websocket stream (recommended). - You may have multiple executions in a single order.
- You can query by symbol, baseCoin, orderId and orderLinkId, and if you pass multiple params, the system will process them according to this priority: orderId > orderLinkId > symbol > baseCoin.
info
- Unified account supports getting the past 730 days historical trades data
HTTP Request
GET /v5/execution/list
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
category | true | string | Product type |
symbol | false | string | Symbol name, like BTCUSDT , uppercase only |
orderId | false | string | Order ID |
orderLinkId | false | string | User customised order ID. Classic account does not support this param |
baseCoin | false | string | Base coin, uppercase only |
startTime | false | integer | The start timestamp (ms)
|
endTime | false | integer | The end timestamp (ms) |
execType | false | string | Execution type. Classic spot is not supported |
limit | false | integer | Limit for data size per page. [1 , 100 ]. Default: 50 |
cursor | false | string | Cursor. Use the nextPageCursor token from the response to retrieve the next page of the result set |
Response Parameters
Parameter | Type | Comments |
---|---|---|
category | string | Product type |
list | array | Object |
> symbol | string | Symbol name |
> orderId | string | Order ID |
> orderLinkId | string | User customized order ID. Classic spot is not supported |
> side | string | Side. Buy ,Sell |
> orderPrice | string | Order price |
> orderQty | string | Order qty |
> leavesQty | string | The remaining qty not executed. Classic spot is not supported |
> createType | string | Order create type "" |
> orderType | string | Order type. Market ,Limit |
> stopOrderType | string | Stop order type. If the order is not stop order, it either returns UNKNOWN or "" . Classic spot is not supported |
> execFee | string | Executed trading fee. You can get spot fee currency instruction here |
> execId | string | Execution ID |
> execPrice | string | Execution price |
> execQty | string | Execution qty |
> execType | string | Executed type. Classic spot is not supported |
> execValue | string | Executed order value. Classic spot is not supported |
> execTime | string | Executed timestamp(ms) |
> feeCurrency | string | Spot trading fee currency Classic spot is not supported |
> isMaker | boolean | Is maker order. true : maker, false : taker |
> feeRate | string | Trading fee rate. Classic spot is not supported |
> tradeIv | string | Implied volatility. Valid for option |
> markIv | string | Implied volatility of mark price. Valid for option |
> markPrice | string | The mark price of the symbol when executing. Classic spot is not supported |
> indexPrice | string | The index price of the symbol when executing. Valid for option only |
> underlyingPrice | string | The underlying price of the symbol when executing. Valid for option |
> blockTradeId | string | Paradigm block trade ID |
> closedSize | string | Closed position size |
> seq | long | Cross sequence, used to associate each fill and each position update
|
nextPageCursor | string | Refer to the cursor request parameter |
Request Example
- HTTP
- Python
- Java
- Node.js
GET /v5/execution/list?category=linear&limit=1 HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672283754132
X-BAPI-RECV-WINDOW: 5000
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.get_executions(
category="linear",
limit=1,
))
import com.bybit.api.client.config.BybitApiConfig;
import com.bybit.api.client.domain.trade.request.TradeOrderRequest;
import com.bybit.api.client.domain.*;
import com.bybit.api.client.domain.trade.*;
import com.bybit.api.client.service.BybitApiClientFactory;
var client = BybitApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_API_SECRET", BybitApiConfig.TESTNET_DOMAIN).newTradeRestClient();
var tradeHistoryRequest = TradeOrderRequest.builder().category(CategoryType.LINEAR).symbol("BTCUSDT").execType(ExecType.Trade).limit(100).build();
System.out.println(client.getTradeHistory(tradeHistoryRequest));
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getExecutionList({
category: 'linear',
symbol: 'BTCUSDT',
margin: '10',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
Response Example
{
"retCode": 0,
"retMsg": "OK",
"result": {
"nextPageCursor": "132766%3A2%2C132766%3A2",
"category": "linear",
"list": [
{
"symbol": "ETHPERP",
"orderType": "Market",
"underlyingPrice": "",
"orderLinkId": "",
"side": "Buy",
"indexPrice": "",
"orderId": "8c065341-7b52-4ca9-ac2c-37e31ac55c94",
"stopOrderType": "UNKNOWN",
"leavesQty": "0",
"execTime": "1672282722429",
"feeCurrency": "",
"isMaker": false,
"execFee": "0.071409",
"feeRate": "0.0006",
"execId": "e0cbe81d-0f18-5866-9415-cf319b5dab3b",
"tradeIv": "",
"blockTradeId": "",
"markPrice": "1183.54",
"execPrice": "1190.15",
"markIv": "",
"orderQty": "0.1",
"orderPrice": "1236.9",
"execValue": "119.015",
"execType": "Trade",
"execQty": "0.1",
"closedSize": "",
"seq": 4688002127
}
]
},
"retExtInfo": {},
"time": 1672283754510
}