Skip to content

Get backtest positions

GET https://rest.haasapi.com/v1/backtests/{backtest_id}/positions

The positions of a finished backtest, paged: every closed position plus any position still open when the window ended.

Requires the read scope.

Parameter Type Required Description
limit integer no Page size, 1–500. Defaults to 100.
cursor string no Opaque cursor from a previous response’s next_cursor.
Terminal window
curl "https://rest.haasapi.com/v1/backtests/{backtest_id}/positions?limit=100" \
-H "Authorization: Bearer hk_live_YOUR_KEY"

200 OK. Returns a BacktestPositionsPage.

{
"data": [
{
"position_id": "9a1de95cf1f0459b8b6a7d6a41f6c9d2",
"direction": "long",
"market_tag": "BINANCE_BTC_USDT",
"is_closed": true,
"opened_at": "2026-08-29T02:15:00Z",
"closed_at": "2026-08-29T07:40:00Z",
"amount": "0.00128",
"average_price": "78011.42",
"realized_profit": "1.83",
"fees": "0.2",
"roi": "1.83",
"profit_currency": "USDT"
}
],
"next_cursor": null
}
Field Type Description
data array of BacktestPosition One page of the backtest’s positions: every closed position plus any position still open when the window ended.
next_cursor string, nullable Pass as cursor to fetch the next page; null on the last page. Opaque - never construct or decode one.
Field Type Description
position_id string Position identifier, unique within the backtest.
direction PositionDirection Position direction.
market_tag string, nullable The market the position traded - joins against market_tag on /v1/markets.
is_closed boolean Whether the position was closed before the window ended.
opened_at string, nullable When the position opened (simulated time), RFC 3339 UTC.
closed_at string, nullable When the position closed (simulated time), RFC 3339 UTC. null while is_closed is false.
amount string (decimal) Total amount in the position, in the market’s base currency.
average_price string (decimal) Average entry price.
realized_profit string (decimal) Realized profit of the position (fees already deducted), in profit_currency.
fees string (decimal) Combined fee costs of the position’s orders, in profit_currency.
roi string (decimal) Return on investment of the position, percent.
profit_currency string, nullable The currency the position’s profit and fee figures are denominated in.

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 backtest with that id, or it is still executing. (code: backtest_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"
}