PhoenixPerpetualsDocs API v1
Get an API key

API reference ยท Exits and strategies

GET/v1/accounts/{account_id}/positions/{market}/exits

Get a position's exits⁠.

Read

The take-profit and stop-loss legs this API keeps on the position: native orders on the engine, so they protect even when the API is away. Each group is at most the position: a take-profit fill trims the stop-losses by its size, the last fill cancels the rest.

Path parameters#

Responses#

200OK
  • account_idstringrequired

    The account number.

  • marketstringrequired

    A market id: the asset and USD; an option adds its venue or hours after a dot.

  • strategy_idstring or nullrequired

    The strategy that keeps these exits (type exits); null when there are none.

  • positionobject or nullrequired

    The open position; null when flat.

    Show 2 fields
    • sidestringrequired

      Long or short.

      One oflongshort

    • sizedecimal stringrequired

      Its size.

  • take_profitarray of ExitsLegrequired

    The take-profit legs: together at most the position.

    Show 9 fields
    • idstringrequired

      The leg: an order of this API, also listed under the account's orders.

    • groupstringrequired

      take_profit: a limit on the profit side. stop_loss: a stop on the loss side.

      One oftake_profitstop_loss

    • typestringrequired

      take_profit legs are limits; stop_loss legs are stop_market or stop_limit.

      One oflimitstop_marketstop_limit

    • statusstringrequired

      The order's status; waiting: a stop-loss not placed yet (it waits for its activation price or its break-even).

      One ofpendingworkingfilledcanceledrejectedexpiredunconfirmedwaiting

    • sizedecimal stringrequired

      Its size.

    • pricedecimal string or nullrequired

      The take-profit price, or the stop price.

    • limit_pricedecimal string or nullrequired

      The limit of a stop_limit leg.

    • trailobject or nullrequired

      A trailing stop-loss: how it follows the price.

      Show 5 fields
      • distancedecimal string or nullrequired

        How far behind the best price (or null: percent).

      • percentdecimal string or nullrequired

        How far behind, in percent of the best price (or null: distance).

      • activation_pricedecimal string or nullrequired

        It starts once the price reaches this; null: from the start.

      • activebooleanrequired

        It follows the price now (its activation price was reached, or it had none).

      • best_pricedecimal string or nullrequired

        The best price since it started, which the stop follows.

    • break_evenobject or nullrequired

      A stop-loss moved to the entry price once the price has gone your way far enough.

      Show 5 fields
      • trigger_distancedecimal string or nullrequired

        How far from the entry the price must go (or null: another trigger).

      • trigger_percentdecimal string or nullrequired

        The same, in percent of the entry.

      • trigger_pricedecimal string or nullrequired

        Or once the price reaches this.

      • offset_ticksintegerrequired

        Ticks beyond the entry, on the profit side.

      • donebooleanrequired

        The stop-loss was moved to the entry already.

  • stop_lossarray of ExitsLegrequired

    The stop-loss legs: together at most the position.

    Show 9 fields
    • idstringrequired

      The leg: an order of this API, also listed under the account's orders.

    • groupstringrequired

      take_profit: a limit on the profit side. stop_loss: a stop on the loss side.

      One oftake_profitstop_loss

    • typestringrequired

      take_profit legs are limits; stop_loss legs are stop_market or stop_limit.

      One oflimitstop_marketstop_limit

    • statusstringrequired

      The order's status; waiting: a stop-loss not placed yet (it waits for its activation price or its break-even).

      One ofpendingworkingfilledcanceledrejectedexpiredunconfirmedwaiting

    • sizedecimal stringrequired

      Its size.

    • pricedecimal string or nullrequired

      The take-profit price, or the stop price.

    • limit_pricedecimal string or nullrequired

      The limit of a stop_limit leg.

    • trailobject or nullrequired

      A trailing stop-loss: how it follows the price.

      Show 5 fields
      • distancedecimal string or nullrequired

        How far behind the best price (or null: percent).

      • percentdecimal string or nullrequired

        How far behind, in percent of the best price (or null: distance).

      • activation_pricedecimal string or nullrequired

        It starts once the price reaches this; null: from the start.

      • activebooleanrequired

        It follows the price now (its activation price was reached, or it had none).

      • best_pricedecimal string or nullrequired

        The best price since it started, which the stop follows.

    • break_evenobject or nullrequired

      A stop-loss moved to the entry price once the price has gone your way far enough.

      Show 5 fields
      • trigger_distancedecimal string or nullrequired

        How far from the entry the price must go (or null: another trigger).

      • trigger_percentdecimal string or nullrequired

        The same, in percent of the entry.

      • trigger_pricedecimal string or nullrequired

        Or once the price reaches this.

      • offset_ticksintegerrequired

        Ticks beyond the entry, on the profit side.

      • donebooleanrequired

        The stop-loss was moved to the entry already.

  • resize_with_positionbooleanrequired

    The legs grow with the position, keeping their share of it (rounded down to the size step).

401The request has no Authorization header.
{
  "error": {
    "type": "authentication",
    "code": "missing_api_key",
    "message": "No API key: send it as Authorization: Bearer <key>.",
    "request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
    "retryable": false,
    "doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#missing_api_key"
  }
}
403The key only works from the addresses you listed.
{
  "error": {
    "type": "permission",
    "code": "ip_not_allowed",
    "message": "This address is not on the key's allowlist.",
    "request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
    "retryable": false,
    "doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#ip_not_allowed"
  }
}
404The account does not exist in this environment, or the key does not reach it.
{
  "error": {
    "type": "not_found",
    "code": "account_not_found",
    "message": "No account with that id is reachable with this key.",
    "request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
    "retryable": false,
    "doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#account_not_found"
  }
}
429A request budget is used up (details.scope says which).
{
  "error": {
    "type": "rate_limit",
    "code": "rate_limited",
    "message": "Too many requests: slow down.",
    "request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
    "retryable": true,
    "doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#rate_limited"
  }
}
500An error we did not expect.
{
  "error": {
    "type": "server",
    "code": "internal_error",
    "message": "Something went wrong on our side.",
    "request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
    "retryable": true,
    "doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#internal_error"
  }
}
503The trading engine did not give a complete answer in time; nothing partial is returned.
{
  "error": {
    "type": "engine",
    "code": "state_unavailable",
    "message": "The account's figures cannot be read right now.",
    "request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
    "retryable": true,
    "doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#state_unavailable"
  }
}

Errors#

Codes this endpoint can return. Match on the code, never on the message.

Guides, endpoints, fields and error codes.