Get account margin#
GET https://api.pro.anboto.xyz/api/v2/trading/margin
Account value is equity, which already includes unrealised PnL. position_value is exposure, not money. remaining_cushion, liq_distance, and vol_cover measure margin the same way on every exchange; they are absent for Binance portfolio-margin and Kraken accounts, and when price history is missing. raw_margin_ratio is the exchange's own account ratio, as the exchange reports it. Fields the exchange does not report are omitted. An exchange without support, or a venue-side failure, returns 400 with {"error": "..."}. ApiKeyAuth required.
Query params#
The exchange —
BINANCE, HUOBI, GATEIO, KRAKEN, KUCOIN, OKX, BYBIT, BITGET, WOO, MEXC, BULLISH, B2C2, COINBASE_PRIME, COINBASE_INTL, … (17 values)subaccount stringSub-account
Headers#
| Header | ||
|---|---|---|
X-API-KEY |
string | required |
X-TIMESTAMP |
int64 ms | required |
X-SIGN |
string | required |
X-RECV-WINDOW |
int, default 5000 |
Responses#
| 200 | The account margin summary |
| 400 | The exchange does not support a margin summary, or the venue call failed |
| 401 | Unauthorized: missing or unknown API key |
| 429 | Rate limit exceeded, retry later |
Response fields — AccountMarginResponse#
equity numberAccount equity: wallet balance plus unrealised PnL
balance numberWallet balance, excluding unrealised PnL
unrealized_pnl numberUnrealised PnL across open positions
position_value numberTotal notional of open positions (exposure, not account value)
total_initial_margin numberInitial margin locked by open positions
total_maint_margin numberMaintenance margin requirement
total_order_margin numberMargin locked by open orders, where the exchange reports it separately
margin_ratio numberMaintenance margin over equity, normalised to 0..1 (liquidation approached at 1)
raw_margin_ratio numberVenue-native account margin ratio as sent (conventions differ). Omitted when the venue has no native account ratio.
raw_margin_field stringVenue JSON key for raw_margin_ratio, e.g. uniMMR, mgnRatio, accountMMRate.
remaining_cushion number1 minus margin_ratio. Negative once equity is already below maintenance margin.
liq_distance number(equity − maintenance margin) / notional. Absent for Binance portfolio-margin and Kraken accounts.
vol_cover numberPessimistic volatility cover: (equity − maintenance margin) / Σ(|notional| × σ). Absent for Binance portfolio-margin and Kraken accounts, with no open positions, or when price history is missing.
vol_sigma_window stringLabel for the σ window used in vol_cover, e.g. 24h
margin_estimated booleanTrue when maintenance margin was estimated (Lighter) rather than reported by the venue
effective_leverage numberPosition value over equity
available_balance numberBalance available to open new positions
account_mode stringExchange account mode, where reported (for example cross or isolated)
curl -X GET "$BASE/api/v2/trading/margin?exchange=BINANCE" \
-H "X-API-KEY: $API_KEY" -H "X-TIMESTAMP: $ts" \
-H "X-SIGN: $sign"
params = {"exchange": ..., "subaccount": ...}
r = requests.get(f"{BASE}/api/v2/trading/margin",
params=params
headers=signed_headers_query(params))
print(r.json())
let resp = client
.get(format!("{BASE}/api/v2/trading/margin?exchange=BINANCE"))
.headers(signed_headers_query(¶ms))
.send()?;
println!("{}", resp.text()?);
req, _ := http.NewRequest("GET", BASE+"/api/v2/trading/margin?exchange=BINANCE", nil)
for k, v := range signedHeadersQuery(req.URL.Query()) {
req.Header.Set(k, v)
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
io.Copy(os.Stdout, resp.Body)
HttpResponse<String> resp = client.send(
signedGet("/api/v2/trading/margin?exchange=BINANCE"),
HttpResponse.BodyHandlers.ofString());
const res = await fetch(`${BASE}/api/v2/trading/margin?exchange=BINANCE`, {
method: "GET",
headers: signedHeadersQuery(params),
});
const data: AccountMarginResponse = await res.json();
val request = signedGet("/api/v2/trading/margin?exchange=BINANCE")
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
cpr::Response r = cpr::Get(
cpr::Url{BASE + "/api/v2/trading/margin?exchange=BINANCE"},
signedHeadersQuery(params));
std::cout << r.text << std::endl;
const res = await fetch(`${BASE}/api/v2/trading/margin?exchange=BINANCE`, {
method: "GET",
headers: signedHeadersQuery(params),
});
console.log(await res.json());
Response 200
{
"equity": 0.0,
"balance": 0.0,
"unrealized_pnl": 0.0,
"position_value": 0.0,
"total_initial_margin": 0.0,
"total_maint_margin": 0.0,
"total_order_margin": 0.0,
"margin_ratio": 0.0,
"raw_margin_ratio": 0.0,
"raw_margin_field": "string",
"remaining_cushion": 0.0,
"liq_distance": 0.0,
"vol_cover": 0.0,
"vol_sigma_window": "string",
"margin_estimated": true,
"effective_leverage": 0.0,
"available_balance": 0.0,
"account_mode": "string"
}