Skip to content

List open positions

GET https://rest.haasapi.com/v1/accounts/{account_id}/positions

Returns the account’s open positions. Returned whole, no pagination. Positions are a margin/futures concept - the list is always empty on spot accounts.

Requires the read scope.

Terminal window
curl "https://rest.haasapi.com/v1/accounts/{account_id}/positions" \
-H "Authorization: Bearer hk_live_YOUR_KEY"

200 OK. Returns a PositionsPage.

{
"data": [
{
"position_id": "0aa7bd9309cf4a2a99a9d3aab2534fbe",
"direction": "long",
"market_tag": "BYBIT_BTC_USD_BTCUSD",
"amount": "100",
"entry_price": "78150.5",
"leverage": "5",
"margin": "0.000255",
"unrealized_profit": "0.0000121",
"roi": "4.7451",
"liquidation_price": "65230.5"
}
]
}
Field Type Description
data array of Position The account’s open positions. Returned whole - no cursor. Always empty on spot accounts - positions are a margin/futures concept.
Field Type Description
position_id string Position identifier, unique within the account.
direction PositionDirection Position direction.
market_tag string, nullable The market the position is on - joins against market_tag on /v1/markets.
amount string (decimal) Position size, in the market’s base currency (contracts on contract-sized markets).
entry_price string (decimal) Average entry price.
leverage string (decimal) The position’s leverage. 0 when the venue does not report one.
margin string (decimal) Margin the position reserves, in the market’s margin currency.
unrealized_profit string (decimal) Unrealized profit or loss at the current mark, in the market’s margin currency.
roi string (decimal) Unrealized profit as a percentage of the position’s margin.
liquidation_price string (decimal) Estimated liquidation price. 0 when the venue does not report one.

All errors are RFC 9457 problem documents.

Status Description
400 The request is malformed (invalid limit, unusable cursor, …). (code: invalid_request)
401 Missing, malformed, disabled, or revoked API key. (code: invalid_api_key)
404 No accessible account with that id. (code: account_not_found)
500 An unexpected error inside the API. Nothing about the request caused it; retry, and quote the instance value if it persists. (code: internal_error)
502 An internal service answered in a way the API could not serve. Retry. (code: upstream_error)
503 The request could not be served right now. Retry with the same key - do not discard it. (code: temporarily_unavailable)
504 An internal service did not answer within the deadline. Retry with backoff. (code: upstream_timeout)
{
"type": "https://docs.haasapi.com/errors/invalid_request",
"title": "Invalid request",
"status": 400,
"detail": "The request is malformed (invalid limit, unusable cursor, …).",
"code": "invalid_request"
}