Skip to main content

Get Closed PnL

Query user's closed profit and loss records

info
  • Classic account: the results are sorted by updatedTime in descending order.
  • UTA2.0, UTA1.0(except inverse): the results are sorted by createdTime in descending order, this will be constant with classic account afterwards
  • UTA2.0, UTA1.0(except inverse): support getting the past 730 days historical data

HTTP Request

GET /v5/position/closed-pnl

Request Parameters

ParameterRequiredTypeComments
categorytruestringProduct type
  • UTA2.0, UTA1.0: linear(USDT Perps, USDC Contract), inverse
  • Classic account: linear(USDT Perps), inverse
symbolfalsestringSymbol name, like BTCUSDT, uppercase only
startTimefalseintegerThe start timestamp (ms)
  • startTime and endTime are not passed, return 7 days by default
  • Only startTime is passed, return range between startTime and startTime+7 days
  • Only endTime is passed, return range between endTime-7 days and endTime
  • If both are passed, the rule is endTime - startTime <= 7 days
endTimefalseintegerThe end timestamp (ms)
limitfalseintegerLimit for data size per page. [1, 100]. Default: 50
cursorfalsestringCursor. Use the nextPageCursor token from the response to retrieve the next page of the result set

Response Parameters

ParameterTypeComments
categorystringProduct type
listarrayObject
> symbolstringSymbol name
> orderIdstringOrder ID
> sidestringBuy, Sell
> qtystringOrder qty
> orderPricestringOrder price
> orderTypestringOrder type. Market,Limit
> execTypestringExec type
Trade, BustTrade
SessionSettlePnL
Settle, MovePosition
> closedSizestringClosed size
> cumEntryValuestringCumulated Position value
> avgEntryPricestringAverage entry price
> cumExitValuestringCumulated exit position value
> avgExitPricestringAverage exit price
> closedPnlstringClosed PnL
> fillCountstringThe number of fills in a single order
> leveragestringleverage
> createdTimestringThe created time (ms)
> updatedTimestringThe updated time (ms)
nextPageCursorstringRefer to the cursor request parameter

Request Example

GET /v5/position/closed-pnl?category=linear&limit=1 HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672284128523
X-BAPI-RECV-WINDOW: 5000

Response Example

{
"retCode": 0,
"retMsg": "OK",
"result": {
"nextPageCursor": "5a373bfe-188d-4913-9c81-d57ab5be8068%3A1672214887231423699%2C5a373bfe-188d-4913-9c81-d57ab5be8068%3A1672214887231423699",
"category": "linear",
"list": [
{
"symbol": "ETHPERP",
"orderType": "Market",
"leverage": "3",
"updatedTime": "1672214887236",
"side": "Sell",
"orderId": "5a373bfe-188d-4913-9c81-d57ab5be8068",
"closedPnl": "-47.4065323",
"avgEntryPrice": "1194.97516667",
"qty": "3",
"cumEntryValue": "3584.9255",
"createdTime": "1672214887231423699",
"orderPrice": "1122.95",
"closedSize": "3",
"avgExitPrice": "1180.59833333",
"execType": "Trade",
"fillCount": "4",
"cumExitValue": "3541.795"
}
]
},
"retExtInfo": {},
"time": 1672284129153
}