PhoenixPerpetualsDocs API v1
Get an API key

API reference ยท Risk and history

GET/v1/accounts/{account_id}/risk

Get live risk⁠.

Read

Equity, open P&L, margin, exposure per market, the room to each loss limit, the profit target and the nearest liquidation: the figures of your dashboard, computed the same way.

Path parameters#

Responses#

200OK
  • as_ofinteger, Unix msrequired

    When the oldest figure here was read.

  • stalebooleanrequired

    Some figures are older than usual (the engine was busy).

  • balancedecimal stringrequired

    The balance.

  • equitydecimal stringrequired

    The balance plus the open P&L at the market price.

  • unrealized_pnldecimal stringrequired

    The open P&L.

  • pnl_todaydecimal stringrequired

    The P&L of the trading day: closed and open.

  • realized_todaydecimal stringrequired

    The P&L closed today.

  • fees_todaydecimal stringrequired

    The fees paid today.

  • trades_todayintegerrequired

    Trades closed today.

  • margin_useddecimal stringrequired

    The margin your positions hold.

  • margin_availabledecimal string or nullrequired

    What is left of the balance for new positions.

  • exposureobjectrequired
    Show 5 fields
    • grossdecimal stringrequired

      The value of every open position.

    • longdecimal stringrequired

      The value of the long ones.

    • shortdecimal stringrequired

      The value of the short ones.

    • effective_leveragedecimal string or nullrequired

      Gross exposure over equity.

    • marketsarray of objectrequired

      Per market, largest first.

      Show 5 fields
      • marketstringrequired

        A market id: the asset and USD.

      • notionaldecimal stringrequired

        The value held on it.

      • leveragedecimal string or nullrequired

        That value over equity.

      • capdecimal string or nullrequired

        The exposure cap of the market.

      • cap_used_pctdecimal string or nullrequired

        How much of the cap is used, counting your other accounts on the same rule, in percent.

  • daily_lossLimit or nullrequired

    A loss limit and the room left to it.

    Show 10 fields
    • limitdecimal string

      The limit, in USD.

    • floordecimal string

      The equity at which it is breached.

    • roomdecimal string

      How much more the account may lose before it.

    • used_pctdecimal string or null

      How much of it is used, in percent.

    • resets_atinteger, Unix ms

      Daily loss only: when it resets (midnight New York).

    • on_breachstring

      Daily loss only: what happens when it is reached.

      One offail_accountflattenflatten_and_pause

    • estimatedboolean

      Daily loss only: the day's start is estimated (the engine does not publish it).

    • modestring

      Max drawdown only: how the reference moves.

      One ofend_of_dayend_of_tradestaticintraday_equity

    • at_leastboolean

      Max drawdown only: the engine may hold a higher floor than shown (it follows equity highs).

    • liftedbooleanrequired

      The rule no longer applies this limit (its cut-off was reached).

  • max_drawdownLimit or nullrequired

    A loss limit and the room left to it.

    Show 10 fields
    • limitdecimal string

      The limit, in USD.

    • floordecimal string

      The equity at which it is breached.

    • roomdecimal string

      How much more the account may lose before it.

    • used_pctdecimal string or null

      How much of it is used, in percent.

    • resets_atinteger, Unix ms

      Daily loss only: when it resets (midnight New York).

    • on_breachstring

      Daily loss only: what happens when it is reached.

      One offail_accountflattenflatten_and_pause

    • estimatedboolean

      Daily loss only: the day's start is estimated (the engine does not publish it).

    • modestring

      Max drawdown only: how the reference moves.

      One ofend_of_dayend_of_tradestaticintraday_equity

    • at_leastboolean

      Max drawdown only: the engine may hold a higher floor than shown (it follows equity highs).

    • liftedbooleanrequired

      The rule no longer applies this limit (its cut-off was reached).

  • profit_targetobject or nullrequired
    Show 4 fields
    • goal_balancedecimal stringrequired

      The balance that reaches it.

    • remainingdecimal stringrequired

      Still to make.

    • progress_pctdecimal string or nullrequired

      How far, in percent.

    • requires_flatbooleanrequired

      Positions must be closed when it is reached.

  • trading_daysobjectrequired
    Show 2 fields
    • countinteger or nullrequired

      Days with a trade so far.

    • requiredinteger or nullrequired

      Days the rule needs.

  • nearest_liquidationobject or nullrequired
    Show 3 fields
    • marketstringrequired

      A market id: the asset and USD.

    • pricedecimal stringrequired

      Its liquidation price.

    • distance_pctdecimal stringrequired

      How far the price is from it, in percent.

  • trading_day_ends_atinteger, Unix msrequired

    When the trading day ends (midnight New York).

  • warningsarray of Warningrequired

    What needs your attention, most serious first.

    Show 4 fields
    • codestringrequired

      What it is about.

      One ofdaily_loss_usedmax_drawdown_usedliquidation_nearno_stop_lossmargin_usedorder_without_position

    • levelstringrequired

      How serious.

      One ofinfowarningcritical

    • marketstring

      The market it is about.

    • valuedecimal string

      The figure behind it, in percent.

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"
  }
}
409The account exists but is not open on the trading engine yet.
{
  "error": {
    "type": "conflict",
    "code": "account_not_ready",
    "message": "This account is still being opened.",
    "request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
    "retryable": true,
    "doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#account_not_ready"
  }
}
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.