API reference ยท Orders
/v1/accounts/{account_id}/orders/testPreview an order.
Read
What an order would do now, sent nowhere: whether it would fill, rest or be refused (and why), its price, fee, margin, the position after it and the room under the exposure cap. Any key may call it.
Path parameters#
-
The account number.
Request body#
-
A market id: the asset and USD.
-
The order's side.
One of
buysell -
market: now, at the best price within your worst price. limit: at your price or better. stop_market: a market order once the last price reaches the stop. stop_limit: a limit once the last price reaches the stop.
One of
marketlimitstop_marketstop_limit -
sizedecimal stringThe size, in the base asset: a multiple of the market's size step. Give size or notional_usd.
-
notional_usddecimal stringThe size as a value in USD, rounded down to the size step.
-
limit_pricedecimal stringThe limit price (limit and stop_limit): a multiple of the tick size.
-
stop_pricedecimal stringThe trigger price (stop_market and stop_limit).
-
worst_pricedecimal stringMarket orders: the worst price you accept. Give worst_price or max_slippage_pct.
-
max_slippage_pctdecimal stringMarket orders: how far from the best price you accept, in percent (the default and bounds are in GET /v1/markets).
-
reduce_onlybooleanIt may only reduce or close your position, never open or add to one.
-
post_onlybooleanLimit orders: refused if it would fill at once.
-
time_in_forcestringgtc: until canceled. gtd: until expires_at. ioc and fok: fill now or end (a fill is always the whole order). Default: ioc for market orders, gtc otherwise.
One of
gtcgtdiocfok -
expires_atinteger, Unix msWith gtd: when it ends.
-
client_order_idstringYour own id for the order: unique in this environment, 1 to 64 letters, digits and . _ : -
Responses#
200OK
-
What the order would do now: fill at once, rest, or be refused (reject says why).
One of
would_fillwould_restwould_reject -
A market id: the asset and USD.
-
The order's side.
One of
buysell -
The order's type.
One of
marketlimitstop_marketstop_limit -
Its size (after a notional_usd is rounded to the size step).
-
Show 3 fields
-
It would fill at once.
-
The price it would fill at (at once) or rest at.
-
A market order's worst price.
-
-
Its value in USD.
-
The fee its fill would pay.
-
Show 5 fields
-
The margin mode the position would use.
One of
isolatedcross -
The leverage it would use.
-
The margin the order needs.
-
The margin available now.
-
What would remain available.
-
-
Show 3 fields
-
The position's size after the fill.
-
Its side; null when flat.
One of
longshort -
Its average price.
-
-
Show 3 fields
-
The market's exposure cap across your accounts of this product.
-
Your open value on the market now.
-
What would remain under the cap.
-
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"
}
}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 - 503
state_unavailable - 503
stale_quote - 400
invalid_request - 400
unknown_field - 404
market_not_found - 400
invalid_size_step - 400
invalid_price_tick