curl --request POST \
--url https://whitebit.com/api/v4/collateral-account/positions/closed-pnl \
--header 'Content-Type: application/json' \
--header 'X-TXC-APIKEY: <api-key>' \
--header 'X-TXC-PAYLOAD: <api-key>' \
--header 'X-TXC-SIGNATURE: <api-key>' \
--data '
{
"startDate": 1778000000,
"endDate": 1778100000,
"limit": 50,
"offset": 0,
"request": "{{request}}",
"nonce": 1594297865000
}
'import requests
url = "https://whitebit.com/api/v4/collateral-account/positions/closed-pnl"
payload = {
"startDate": 1778000000,
"endDate": 1778100000,
"limit": 50,
"offset": 0,
"request": "{{request}}",
"nonce": 1594297865000
}
headers = {
"X-TXC-APIKEY": "<api-key>",
"X-TXC-PAYLOAD": "<api-key>",
"X-TXC-SIGNATURE": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-TXC-APIKEY': '<api-key>',
'X-TXC-PAYLOAD': '<api-key>',
'X-TXC-SIGNATURE': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
startDate: 1778000000,
endDate: 1778100000,
limit: 50,
offset: 0,
request: '{{request}}',
nonce: 1594297865000
})
};
fetch('https://whitebit.com/api/v4/collateral-account/positions/closed-pnl', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://whitebit.com/api/v4/collateral-account/positions/closed-pnl",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'startDate' => 1778000000,
'endDate' => 1778100000,
'limit' => 50,
'offset' => 0,
'request' => '{{request}}',
'nonce' => 1594297865000
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-TXC-APIKEY: <api-key>",
"X-TXC-PAYLOAD: <api-key>",
"X-TXC-SIGNATURE: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://whitebit.com/api/v4/collateral-account/positions/closed-pnl"
payload := strings.NewReader("{\n \"startDate\": 1778000000,\n \"endDate\": 1778100000,\n \"limit\": 50,\n \"offset\": 0,\n \"request\": \"{{request}}\",\n \"nonce\": 1594297865000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-TXC-APIKEY", "<api-key>")
req.Header.Add("X-TXC-PAYLOAD", "<api-key>")
req.Header.Add("X-TXC-SIGNATURE", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://whitebit.com/api/v4/collateral-account/positions/closed-pnl")
.header("X-TXC-APIKEY", "<api-key>")
.header("X-TXC-PAYLOAD", "<api-key>")
.header("X-TXC-SIGNATURE", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"startDate\": 1778000000,\n \"endDate\": 1778100000,\n \"limit\": 50,\n \"offset\": 0,\n \"request\": \"{{request}}\",\n \"nonce\": 1594297865000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://whitebit.com/api/v4/collateral-account/positions/closed-pnl")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-TXC-APIKEY"] = '<api-key>'
request["X-TXC-PAYLOAD"] = '<api-key>'
request["X-TXC-SIGNATURE"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"startDate\": 1778000000,\n \"endDate\": 1778100000,\n \"limit\": 50,\n \"offset\": 0,\n \"request\": \"{{request}}\",\n \"nonce\": 1594297865000\n}"
response = http.request(request)
puts response.read_body[
{
"positionId": 111,
"market": "BTC_USDT",
"grossPnl": "43.85",
"netPnl": "42.6",
"totalTradeFee": "6.15",
"totalFunding": "1.25",
"avgEntryPrice": "61000",
"avgExitPrice": "62000",
"closedSize": "0.05",
"amount": "0",
"side": "LONG",
"isHedge": true,
"openDate": 1778000000,
"closeDate": 1778077400
},
{
"positionId": 98,
"market": "ETH_USDT",
"grossPnl": "-82.425",
"netPnl": "-83.225",
"totalTradeFee": "7.425",
"totalFunding": "0.8",
"avgEntryPrice": "2500",
"avgExitPrice": "2450",
"closedSize": "1.5",
"amount": "0",
"side": "BOTH",
"isHedge": false,
"openDate": 1777900000,
"closeDate": 1778050000
}
]{
"code": 30,
"message": "Validation failed",
"errors": {}
}{
"code": 30,
"message": "Validation failed",
"errors": {}
}Closed-position PNL
The endpoint returns one aggregated profit-and-loss record per closed collateral position for the authenticated account — the same closed-position PNL the trading terminal shows. Records are sorted by closeDate descending, then positionId descending. Use the optional startDate and endDate parameters to narrow the window; the filter applies to the position close time.
The endpoint supports pagination via limit (default: 50, max: 100) and offset (default: 0); the sum of offset and limit must not exceed 10000. A response that returns fewer than limit records indicates the last page.
Close-time windowing: a position opened before the requested window but closed inside the window returns complete aggregates — fees, average prices, and closed size cover the full position lifetime, not only the requested window.
Rate limit: 12000 requests/10 sec.
curl --request POST \
--url https://whitebit.com/api/v4/collateral-account/positions/closed-pnl \
--header 'Content-Type: application/json' \
--header 'X-TXC-APIKEY: <api-key>' \
--header 'X-TXC-PAYLOAD: <api-key>' \
--header 'X-TXC-SIGNATURE: <api-key>' \
--data '
{
"startDate": 1778000000,
"endDate": 1778100000,
"limit": 50,
"offset": 0,
"request": "{{request}}",
"nonce": 1594297865000
}
'import requests
url = "https://whitebit.com/api/v4/collateral-account/positions/closed-pnl"
payload = {
"startDate": 1778000000,
"endDate": 1778100000,
"limit": 50,
"offset": 0,
"request": "{{request}}",
"nonce": 1594297865000
}
headers = {
"X-TXC-APIKEY": "<api-key>",
"X-TXC-PAYLOAD": "<api-key>",
"X-TXC-SIGNATURE": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-TXC-APIKEY': '<api-key>',
'X-TXC-PAYLOAD': '<api-key>',
'X-TXC-SIGNATURE': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
startDate: 1778000000,
endDate: 1778100000,
limit: 50,
offset: 0,
request: '{{request}}',
nonce: 1594297865000
})
};
fetch('https://whitebit.com/api/v4/collateral-account/positions/closed-pnl', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://whitebit.com/api/v4/collateral-account/positions/closed-pnl",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'startDate' => 1778000000,
'endDate' => 1778100000,
'limit' => 50,
'offset' => 0,
'request' => '{{request}}',
'nonce' => 1594297865000
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-TXC-APIKEY: <api-key>",
"X-TXC-PAYLOAD: <api-key>",
"X-TXC-SIGNATURE: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://whitebit.com/api/v4/collateral-account/positions/closed-pnl"
payload := strings.NewReader("{\n \"startDate\": 1778000000,\n \"endDate\": 1778100000,\n \"limit\": 50,\n \"offset\": 0,\n \"request\": \"{{request}}\",\n \"nonce\": 1594297865000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-TXC-APIKEY", "<api-key>")
req.Header.Add("X-TXC-PAYLOAD", "<api-key>")
req.Header.Add("X-TXC-SIGNATURE", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://whitebit.com/api/v4/collateral-account/positions/closed-pnl")
.header("X-TXC-APIKEY", "<api-key>")
.header("X-TXC-PAYLOAD", "<api-key>")
.header("X-TXC-SIGNATURE", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"startDate\": 1778000000,\n \"endDate\": 1778100000,\n \"limit\": 50,\n \"offset\": 0,\n \"request\": \"{{request}}\",\n \"nonce\": 1594297865000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://whitebit.com/api/v4/collateral-account/positions/closed-pnl")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-TXC-APIKEY"] = '<api-key>'
request["X-TXC-PAYLOAD"] = '<api-key>'
request["X-TXC-SIGNATURE"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"startDate\": 1778000000,\n \"endDate\": 1778100000,\n \"limit\": 50,\n \"offset\": 0,\n \"request\": \"{{request}}\",\n \"nonce\": 1594297865000\n}"
response = http.request(request)
puts response.read_body[
{
"positionId": 111,
"market": "BTC_USDT",
"grossPnl": "43.85",
"netPnl": "42.6",
"totalTradeFee": "6.15",
"totalFunding": "1.25",
"avgEntryPrice": "61000",
"avgExitPrice": "62000",
"closedSize": "0.05",
"amount": "0",
"side": "LONG",
"isHedge": true,
"openDate": 1778000000,
"closeDate": 1778077400
},
{
"positionId": 98,
"market": "ETH_USDT",
"grossPnl": "-82.425",
"netPnl": "-83.225",
"totalTradeFee": "7.425",
"totalFunding": "0.8",
"avgEntryPrice": "2500",
"avgExitPrice": "2450",
"closedSize": "1.5",
"amount": "0",
"side": "BOTH",
"isHedge": false,
"openDate": 1777900000,
"closeDate": 1778050000
}
]{
"code": 30,
"message": "Validation failed",
"errors": {}
}{
"code": 30,
"message": "Validation failed",
"errors": {}
}Authorizations
Body
Response
Successful response - returns an array with one aggregated record per closed position, sorted by closeDate descending, then positionId descending. Returns an empty array when no closed positions match the filters.
Position direction. Returns BOTH for positions opened with hedge mode disabled. See positionSide.
LONG, SHORT, BOTH "LONG"
Whether the position was opened in hedge mode.
true
Was this page helpful?