Python (SDK)
from compass_api_sdk import CompassAPI
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.perpetual_trading.perpetual_trading_positions(owner="0x06A9aF046187895AcFc7258450B15397CAc67400")
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.perpetualTrading.perpetualTradingPositions({
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
});
console.log(result);
}
run();curl --request GET \
--url https://api.compasslabs.ai/v2/perpetual_trading/positions \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.compasslabs.ai/v2/perpetual_trading/positions', 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://api.compasslabs.ai/v2/perpetual_trading/positions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <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"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v2/perpetual_trading/positions"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.compasslabs.ai/v2/perpetual_trading/positions")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/perpetual_trading/positions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"account_value": "1058.32",
"positions": [
{
"asset": "AAPL",
"asset_id": 12,
"entry_price": "212.40",
"funding_accrued": "-0.12",
"leverage": "3",
"liquidation_price": "180.12",
"margin_used": "354.00",
"mark_price": "213.88",
"side": "long",
"size": "5.00",
"unrealized_pnl": "7.40"
}
],
"withdrawable": "704.32"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Perpetual Trading
List perpetual trading positions
List open perpetual futures positions for a user.
Returns position data including size, entry price, mark price, PnL, liquidation price, leverage, and cumulative funding. Optionally filter by asset ticker. Returns an empty list if no positions are open.
GET
/
v2
/
perpetual_trading
/
positions
Python (SDK)
from compass_api_sdk import CompassAPI
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.perpetual_trading.perpetual_trading_positions(owner="0x06A9aF046187895AcFc7258450B15397CAc67400")
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.perpetualTrading.perpetualTradingPositions({
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
});
console.log(result);
}
run();curl --request GET \
--url https://api.compasslabs.ai/v2/perpetual_trading/positions \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.compasslabs.ai/v2/perpetual_trading/positions', 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://api.compasslabs.ai/v2/perpetual_trading/positions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <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"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v2/perpetual_trading/positions"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.compasslabs.ai/v2/perpetual_trading/positions")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/perpetual_trading/positions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"account_value": "1058.32",
"positions": [
{
"asset": "AAPL",
"asset_id": 12,
"entry_price": "212.40",
"funding_accrued": "-0.12",
"leverage": "3",
"liquidation_price": "180.12",
"margin_used": "354.00",
"mark_price": "213.88",
"side": "long",
"size": "5.00",
"unrealized_pnl": "7.40"
}
],
"withdrawable": "704.32"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Query Parameters
User's EOA address (looks up their perpetual trading product account)
Filter to a specific asset ticker (e.g. AAPL)
Response
Successful Response
List of open perpetual trading positions with account balance.
Was this page helpful?
⌘I