API reference ยท Exits and strategies
/v1/accounts/{account_id}/positions/{market}/exitsChange a position's exits.
Read and trade
Places, changes and cancels take-profit and stop-loss legs together, against the state you read: when the position or a leg changed since, nothing is done (409 exits_changed, with the state now). The legs are reduce-only and never larger than the position.
Path parameters#
-
The account number.
-
A market id.
Request body#
-
The position you saw: { side, size }, or null.
-
Every leg you saw (an empty list when there were none): if anything differs now, nothing is done and the answer is 409 exits_changed with the state now.
-
Applied in this order: cancels, changes, then new legs (stop-losses first). An engine refusal stops the batch: 422 exit_operation_failed says what each operation did.
Show 10 fields
-
What to do.
One of
placemodifycancel -
idstringmodify, cancel: the leg.
-
groupstringplace: the group of the new leg.
One of
take_profitstop_loss -
typestringplace: limit for a take-profit (the default); stop_market (the default) or stop_limit for a stop-loss.
One of
limitstop_marketstop_limit -
pricedecimal stringThe take-profit price, or the stop price.
-
limit_pricedecimal stringThe limit of a stop_limit leg.
-
sizedecimal stringThe size; absent on a place: what the group leaves of the position.
-
trailobject or nullA stop-loss that follows the price: { distance } (a price difference) or { percent }, with activation_price to start only once the price reaches it. Without a price and an activation price it starts from the price now. null removes it.
Show 3 fields
-
distancedecimal stringHow far behind the best price.
-
percentdecimal stringHow far behind, in percent of the best price.
-
activation_pricedecimal stringStart once the price reaches this.
-
-
break_evenobject or nullMove the stop-loss to the entry price (plus offset_ticks) once the price has gone your way by trigger_distance, trigger_percent or to trigger_price. Without a price, the stop is placed only then. null removes it.
Show 4 fields
-
trigger_distancedecimal stringHow far from the entry.
-
trigger_percentdecimal stringHow far from the entry, in percent.
-
trigger_pricedecimal stringOr this price.
-
offset_ticksintegerTicks beyond the entry, on the profit side.
-
-
cleararray of stringmodify: the settings to remove from a stop-loss (the same as sending them null).
-
-
resize_with_positionbooleanThe legs grow with the position (default true).
Responses#
200OK
-
The account number.
-
A market id: the asset and USD; an option adds its venue or hours after a dot.
-
The strategy that keeps these exits (type exits); null when there are none.
-
The open position; null when flat.
-
The take-profit legs: together at most the position.
Show 9 fields
-
The leg: an order of this API, also listed under the account's orders.
-
take_profit: a limit on the profit side. stop_loss: a stop on the loss side.
One of
take_profitstop_loss -
take_profit legs are limits; stop_loss legs are stop_market or stop_limit.
One of
limitstop_marketstop_limit -
The order's status; waiting: a stop-loss not placed yet (it waits for its activation price or its break-even).
One of
pendingworkingfilledcanceledrejectedexpiredunconfirmedwaiting -
Its size.
-
The take-profit price, or the stop price.
-
The limit of a stop_limit leg.
-
A trailing stop-loss: how it follows the price.
Show 5 fields
-
How far behind the best price (or null: percent).
-
How far behind, in percent of the best price (or null: distance).
-
It starts once the price reaches this; null: from the start.
-
It follows the price now (its activation price was reached, or it had none).
-
The best price since it started, which the stop follows.
-
-
A stop-loss moved to the entry price once the price has gone your way far enough.
Show 5 fields
-
How far from the entry the price must go (or null: another trigger).
-
The same, in percent of the entry.
-
Or once the price reaches this.
-
Ticks beyond the entry, on the profit side.
-
The stop-loss was moved to the entry already.
-
-
-
The stop-loss legs: together at most the position.
Show 9 fields
-
The leg: an order of this API, also listed under the account's orders.
-
take_profit: a limit on the profit side. stop_loss: a stop on the loss side.
One of
take_profitstop_loss -
take_profit legs are limits; stop_loss legs are stop_market or stop_limit.
One of
limitstop_marketstop_limit -
The order's status; waiting: a stop-loss not placed yet (it waits for its activation price or its break-even).
One of
pendingworkingfilledcanceledrejectedexpiredunconfirmedwaiting -
Its size.
-
The take-profit price, or the stop price.
-
The limit of a stop_limit leg.
-
A trailing stop-loss: how it follows the price.
Show 5 fields
-
How far behind the best price (or null: percent).
-
How far behind, in percent of the best price (or null: distance).
-
It starts once the price reaches this; null: from the start.
-
It follows the price now (its activation price was reached, or it had none).
-
The best price since it started, which the stop follows.
-
-
A stop-loss moved to the entry price once the price has gone your way far enough.
Show 5 fields
-
How far from the entry the price must go (or null: another trigger).
-
The same, in percent of the entry.
-
Or once the price reaches this.
-
Ticks beyond the entry, on the profit side.
-
The stop-loss was moved to the entry already.
-
-
-
The legs grow with the position, keeping their share of it (rounded down to the size step).
400The request is malformed.
{
"error": {
"type": "invalid_request",
"code": "invalid_request",
"message": "The request is not valid.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#invalid_request"
}
}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"
}
}422The account passed, failed, or was closed (details.reason).
{
"error": {
"type": "rule_rejection",
"code": "account_not_tradable",
"message": "This account cannot trade.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#account_not_tradable"
}
}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.
- 401
missing_api_key - 401
invalid_api_key - 401
expired_api_key - 401
revoked_api_key - 401
invalid_token - 401
expired_token - 401
revoked_token - 401
wrong_resource - 401
wrong_environment - 403
ip_not_allowed - 403
api_disabled - 429
rate_limited - 404
account_not_found - 409
account_not_ready - 422
account_not_tradable - 403
insufficient_permission - 400
invalid_request - 400
unknown_field - 400
idempotency_key_required - 400
invalid_idempotency_key - 400
idempotency_key_reused - 409
operation_in_progress - 503
state_unavailable - 503
stale_quote - 503
engine_unavailable - 503
engine_busy - 422
key_market_not_allowed - 404
market_not_found - 404
position_not_found - 409
exits_changed - 422
exit_operation_failed - 422
exit_would_fill - 422
exits_exceed_position - 422
exit_leg_cap - 422
strategy_limit - 400
invalid_size_step - 400
invalid_price_tick - 422
price_out_of_band - 422
stop_already_triggered