> For the complete documentation index, see [llms.txt](https://docs.unix.market/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unix.market/rest-api/trading.md).

# Trading

## Place Order

> Submit a signed order for a supported market, including market, limit, conditional, or TP/SL order types.

```json
{"openapi":"3.0.3","info":{"title":"UniX API","version":"1.11.0"},"tags":[{"name":"Trading"}],"servers":[{"url":"https://api.unixtrade.pro/v1","description":"Production"}],"paths":{"/trade/orders":{"post":{"tags":["Trading"],"summary":"Place Order","operationId":"placeOrder","description":"Submit a signed order for a supported market, including market, limit, conditional, or TP/SL order types.","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/WriteCommonParams"},{"type":"object","required":["symbol_id","is_buy","order_type","quantity"],"properties":{"client_order_id":{"type":"string","maxLength":36,"description":"Custom order ID (≤ 36 chars)."},"symbol_id":{"type":"integer"},"is_buy":{"type":"boolean"},"order_type":{"type":"string","enum":["limit","market"]},"time_in_force":{"type":"string","enum":["gtc","fok","ioc"],"description":"Limit orders only — defaults to `gtc`. Market orders ignore this field."},"quantity":{"type":"string","description":"Order quantity (decimal string)."},"price":{"type":"string","description":"Limit price. For limit orders, supply exactly one of `price` or `price_match` (supplying both is an error). Must NOT be supplied for market orders."},"slippage":{"type":"string","description":"Market-order slippage protection (decimal string, range [0.0001, 0.1], e.g. `\"0.01\"` = 1%). Market orders only — must NOT be supplied for limit orders."},"position_side":{"type":"string","enum":["both","long","short"],"description":"Perpetuals only (required): one-way mode → `both`; hedge mode → `long` / `short`. Must NOT be supplied for spot."},"margin_mode":{"type":"string","enum":["cross","isolated"],"description":"Perpetuals only (required): `cross` / `isolated`. Must NOT be supplied for spot."},"market_order_type":{"type":"string","enum":["base","quote"],"description":"Market orders only (conditionally required). Perp: must be `base`. Spot: required, `base` or `quote`."},"stp_mode":{"type":"string","enum":["cancel_maker","cancel_taker","cancel_both","none"],"default":"cancel_maker"},"price_match":{"type":"string","enum":["queue_1","queue_5","counter_party_1","counter_party_5"],"description":"Limit orders only — supply exactly one of `price` or `price_match` (supplying both is an error)."},"tpsl":{"$ref":"#/components/schemas/OrderTpslParams"},"conditional":{"$ref":"#/components/schemas/OrderConditionalParams"},"algo_order_type":{"type":"string","enum":["conditional","tpsl","attached_tpsl"]},"flags":{"type":"array","items":{"type":"string","enum":["post_only","reduce_only"]},"description":"`post_only` requires `time_in_force` = `gtc` (other values rejected). `reduce_only` requires `tpsl` to be non-null."}}}]}}}},"responses":{"200":{"description":"Order accepted","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ResponseEnvelope"},{"type":"object","properties":{"data":{"type":"object","properties":{"tx_hash":{"type":"string"},"order_id":{"type":"string"},"client_order_id":{"type":"string","nullable":true}}}}}]}}}},"400":{"$ref":"#/components/responses/BadRequest"}}}}},"components":{"schemas":{"WriteCommonParams":{"type":"object","required":["address","nonce","expires_after","signature"],"properties":{"address":{"type":"string","description":"Signer's Ethereum address (`0x`-prefixed, lowercase hex). The node uses `ecrecover` to verify this matches the recovered signer.","pattern":"^0x[a-fA-F0-9]{40}$"},"nonce":{"type":"integer","format":"int64","description":"Millisecond Unix timestamp (`Date.now()`). Tracked **per signer** — each Agent Key has an independent nonce space."},"expires_after":{"type":"integer","format":"int64","description":"Expiration timestamp (ms). Recommended `Date.now() + 600_000` (10 minutes)."},"target_address":{"type":"string","description":"Optional target account address. Omit to operate on the signer's own account.\nUsed when an Agent operates on a sub-account.\n**Conditionally signed**: it does not enter `actionHash`, but when present it must be\nincluded as `Agent.targetAddress` in the EIP-712 struct (6-field Agent — see Signing\nMethod A). **Not allowed** on private-key-only endpoints.\n","pattern":"^0x[a-fA-F0-9]{40}$"},"signature":{"$ref":"#/components/schemas/Signature"}}},"Signature":{"type":"object","description":"ECDSA signature components `(r, s, v)` over the EIP-712 signing hash.","required":["r","s","v"],"properties":{"r":{"type":"string","description":"32-byte hex string with `0x` prefix."},"s":{"type":"string","description":"32-byte hex string with `0x` prefix."},"v":{"type":"integer","description":"Recovery identifier — typically 27 or 28.","enum":[27,28]}}},"OrderTpslParams":{"type":"object","description":"Take-profit / stop-loss parameters. Required when `algo_order_type` is `tpsl` or `attached_tpsl`; optional for normal/conditional orders.","properties":{"tpsl_mode":{"type":"string","enum":["full","partial"],"description":"`full` closes the full position when triggered; `partial` closes only the original quantity."},"tp_trigger_price":{"type":"string","description":"Take-profit trigger price (decimal string)."},"tp_trigger_by":{"type":"string","enum":["last_price","mark_price","oracle_price"],"description":"Spot supports `last_price` only; perp supports all three."},"tp_order_type":{"type":"string","enum":["market","limit"]},"tp_order_price":{"type":"string","description":"Take-profit limit price (required when `tp_order_type=limit`)."},"sl_trigger_price":{"type":"string","description":"Stop-loss trigger price."},"sl_trigger_by":{"type":"string","enum":["last_price","mark_price","oracle_price"],"description":"Spot supports `last_price` only; perp supports all three."},"sl_order_type":{"type":"string","enum":["market","limit"]},"sl_order_price":{"type":"string"}}},"OrderConditionalParams":{"type":"object","description":"Conditional order trigger. Required when `algo_order_type=conditional`.","required":["trigger_price","trigger_by"],"properties":{"trigger_price":{"type":"string"},"trigger_by":{"type":"string","enum":["last_price","mark_price","oracle_price"],"description":"Spot supports `last_price` only; perp supports all three."}}},"ResponseEnvelope":{"type":"object","description":"Standard response envelope shared by every endpoint.","required":["code","msg","data"],"properties":{"code":{"type":"string","description":"`\"0\"` for success. Non-zero indicates an error code — see [Error Codes](/reference/error-codes)."},"msg":{"type":"string","description":"Empty on success; human-readable error description on failure."},"data":{"description":"Endpoint-specific payload on success; `null` on failure.","nullable":true},"trace_code":{"type":"string","description":"Backend trace identifier. Empty on success; populated on failure for support diagnostics."}}}},"responses":{"BadRequest":{"description":"Invalid parameters","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ResponseEnvelope"},{"type":"object"}]}}}}}}}
```

## Modify Order

> Modify selected fields of an existing active order, such as price, quantity, or attached TP/SL settings.

```json
{"openapi":"3.0.3","info":{"title":"UniX API","version":"1.11.0"},"tags":[{"name":"Trading"}],"servers":[{"url":"https://api.unixtrade.pro/v1","description":"Production"}],"paths":{"/trade/orders/modify":{"post":{"tags":["Trading"],"summary":"Modify Order","operationId":"modifyOrder","description":"Modify selected fields of an existing active order, such as price, quantity, or attached TP/SL settings.","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/WriteCommonParams"},{"type":"object","description":"Provide at least one of `order_id`/`client_order_id`.","properties":{"order_id":{"type":"string"},"client_order_id":{"type":"string"},"price":{"type":"string"},"quantity":{"type":"string","description":"New quantity (must be > already-filled quantity)."},"conditional":{"type":"object","properties":{"trigger_price":{"type":"string"},"trigger_by":{"type":"string","enum":["last_price","mark_price","index_price"]}}},"tpsl":{"$ref":"#/components/schemas/OrderTpslParams"}}}]}}}},"responses":{"200":{"description":"Modify acknowledged"}}}}},"components":{"schemas":{"WriteCommonParams":{"type":"object","required":["address","nonce","expires_after","signature"],"properties":{"address":{"type":"string","description":"Signer's Ethereum address (`0x`-prefixed, lowercase hex). The node uses `ecrecover` to verify this matches the recovered signer.","pattern":"^0x[a-fA-F0-9]{40}$"},"nonce":{"type":"integer","format":"int64","description":"Millisecond Unix timestamp (`Date.now()`). Tracked **per signer** — each Agent Key has an independent nonce space."},"expires_after":{"type":"integer","format":"int64","description":"Expiration timestamp (ms). Recommended `Date.now() + 600_000` (10 minutes)."},"target_address":{"type":"string","description":"Optional target account address. Omit to operate on the signer's own account.\nUsed when an Agent operates on a sub-account.\n**Conditionally signed**: it does not enter `actionHash`, but when present it must be\nincluded as `Agent.targetAddress` in the EIP-712 struct (6-field Agent — see Signing\nMethod A). **Not allowed** on private-key-only endpoints.\n","pattern":"^0x[a-fA-F0-9]{40}$"},"signature":{"$ref":"#/components/schemas/Signature"}}},"Signature":{"type":"object","description":"ECDSA signature components `(r, s, v)` over the EIP-712 signing hash.","required":["r","s","v"],"properties":{"r":{"type":"string","description":"32-byte hex string with `0x` prefix."},"s":{"type":"string","description":"32-byte hex string with `0x` prefix."},"v":{"type":"integer","description":"Recovery identifier — typically 27 or 28.","enum":[27,28]}}},"OrderTpslParams":{"type":"object","description":"Take-profit / stop-loss parameters. Required when `algo_order_type` is `tpsl` or `attached_tpsl`; optional for normal/conditional orders.","properties":{"tpsl_mode":{"type":"string","enum":["full","partial"],"description":"`full` closes the full position when triggered; `partial` closes only the original quantity."},"tp_trigger_price":{"type":"string","description":"Take-profit trigger price (decimal string)."},"tp_trigger_by":{"type":"string","enum":["last_price","mark_price","oracle_price"],"description":"Spot supports `last_price` only; perp supports all three."},"tp_order_type":{"type":"string","enum":["market","limit"]},"tp_order_price":{"type":"string","description":"Take-profit limit price (required when `tp_order_type=limit`)."},"sl_trigger_price":{"type":"string","description":"Stop-loss trigger price."},"sl_trigger_by":{"type":"string","enum":["last_price","mark_price","oracle_price"],"description":"Spot supports `last_price` only; perp supports all three."},"sl_order_type":{"type":"string","enum":["market","limit"]},"sl_order_price":{"type":"string"}}}}}}
```

## Cancel Order

> Cancel one active order by providing either its \`order\_id\` or \`client\_order\_id\`.

```json
{"openapi":"3.0.3","info":{"title":"UniX API","version":"1.11.0"},"tags":[{"name":"Trading"}],"servers":[{"url":"https://api.unixtrade.pro/v1","description":"Production"}],"paths":{"/trade/orders/cancel":{"post":{"tags":["Trading"],"summary":"Cancel Order","operationId":"cancelOrder","description":"Cancel one active order by providing either its `order_id` or `client_order_id`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/WriteCommonParams"},{"type":"object","description":"Provide at least one of `order_id` or `client_order_id`.","properties":{"order_id":{"type":"string"},"client_order_id":{"type":"string"}}}]}}}},"responses":{"200":{"description":"Cancel acknowledged","content":{"application/json":{}}}}}}},"components":{"schemas":{"WriteCommonParams":{"type":"object","required":["address","nonce","expires_after","signature"],"properties":{"address":{"type":"string","description":"Signer's Ethereum address (`0x`-prefixed, lowercase hex). The node uses `ecrecover` to verify this matches the recovered signer.","pattern":"^0x[a-fA-F0-9]{40}$"},"nonce":{"type":"integer","format":"int64","description":"Millisecond Unix timestamp (`Date.now()`). Tracked **per signer** — each Agent Key has an independent nonce space."},"expires_after":{"type":"integer","format":"int64","description":"Expiration timestamp (ms). Recommended `Date.now() + 600_000` (10 minutes)."},"target_address":{"type":"string","description":"Optional target account address. Omit to operate on the signer's own account.\nUsed when an Agent operates on a sub-account.\n**Conditionally signed**: it does not enter `actionHash`, but when present it must be\nincluded as `Agent.targetAddress` in the EIP-712 struct (6-field Agent — see Signing\nMethod A). **Not allowed** on private-key-only endpoints.\n","pattern":"^0x[a-fA-F0-9]{40}$"},"signature":{"$ref":"#/components/schemas/Signature"}}},"Signature":{"type":"object","description":"ECDSA signature components `(r, s, v)` over the EIP-712 signing hash.","required":["r","s","v"],"properties":{"r":{"type":"string","description":"32-byte hex string with `0x` prefix."},"s":{"type":"string","description":"32-byte hex string with `0x` prefix."},"v":{"type":"integer","description":"Recovery identifier — typically 27 or 28.","enum":[27,28]}}}}}}
```

## Batch Place Orders

> Submit multiple orders for the same symbol in one signed request.

```json
{"openapi":"3.0.3","info":{"title":"UniX API","version":"1.11.0"},"tags":[{"name":"Trading"}],"servers":[{"url":"https://api.unixtrade.pro/v1","description":"Production"}],"paths":{"/trade/orders/batch":{"post":{"tags":["Trading"],"summary":"Batch Place Orders","operationId":"batchPlaceOrders","description":"Submit multiple orders for the same symbol in one signed request.","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/WriteCommonParams"},{"type":"object","required":["symbol_id","orders"],"properties":{"symbol_id":{"type":"integer"},"orders":{"type":"array","maxItems":20,"items":{"description":"Same shape as the [Place Order](#operation/placeOrder) request body (business fields only).","type":"object"}}}}]}}}},"responses":{"200":{"description":"Batch acknowledged with per-order results","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ResponseEnvelope"},{"type":"object","properties":{"data":{"type":"object","properties":{"tx_hash":{"type":"string"},"results":{"type":"array","items":{"type":"object","properties":{"order_id":{"type":"string","nullable":true},"client_order_id":{"type":"string","nullable":true},"state":{"type":"string"},"error_code":{"type":"string"}}}}}}}}]}}}}}}}},"components":{"schemas":{"WriteCommonParams":{"type":"object","required":["address","nonce","expires_after","signature"],"properties":{"address":{"type":"string","description":"Signer's Ethereum address (`0x`-prefixed, lowercase hex). The node uses `ecrecover` to verify this matches the recovered signer.","pattern":"^0x[a-fA-F0-9]{40}$"},"nonce":{"type":"integer","format":"int64","description":"Millisecond Unix timestamp (`Date.now()`). Tracked **per signer** — each Agent Key has an independent nonce space."},"expires_after":{"type":"integer","format":"int64","description":"Expiration timestamp (ms). Recommended `Date.now() + 600_000` (10 minutes)."},"target_address":{"type":"string","description":"Optional target account address. Omit to operate on the signer's own account.\nUsed when an Agent operates on a sub-account.\n**Conditionally signed**: it does not enter `actionHash`, but when present it must be\nincluded as `Agent.targetAddress` in the EIP-712 struct (6-field Agent — see Signing\nMethod A). **Not allowed** on private-key-only endpoints.\n","pattern":"^0x[a-fA-F0-9]{40}$"},"signature":{"$ref":"#/components/schemas/Signature"}}},"Signature":{"type":"object","description":"ECDSA signature components `(r, s, v)` over the EIP-712 signing hash.","required":["r","s","v"],"properties":{"r":{"type":"string","description":"32-byte hex string with `0x` prefix."},"s":{"type":"string","description":"32-byte hex string with `0x` prefix."},"v":{"type":"integer","description":"Recovery identifier — typically 27 or 28.","enum":[27,28]}}},"ResponseEnvelope":{"type":"object","description":"Standard response envelope shared by every endpoint.","required":["code","msg","data"],"properties":{"code":{"type":"string","description":"`\"0\"` for success. Non-zero indicates an error code — see [Error Codes](/reference/error-codes)."},"msg":{"type":"string","description":"Empty on success; human-readable error description on failure."},"data":{"description":"Endpoint-specific payload on success; `null` on failure.","nullable":true},"trace_code":{"type":"string","description":"Backend trace identifier. Empty on success; populated on failure for support diagnostics."}}}}}}
```

## Batch Modify Orders

> Modify multiple existing orders for the same symbol in one signed request.

```json
{"openapi":"3.0.3","info":{"title":"UniX API","version":"1.11.0"},"tags":[{"name":"Trading"}],"servers":[{"url":"https://api.unixtrade.pro/v1","description":"Production"}],"paths":{"/trade/orders/batch/modify":{"post":{"tags":["Trading"],"summary":"Batch Modify Orders","operationId":"batchModifyOrders","description":"Modify multiple existing orders for the same symbol in one signed request.","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/WriteCommonParams"},{"type":"object","required":["symbol_id","orders"],"properties":{"symbol_id":{"type":"integer"},"orders":{"type":"array","maxItems":20,"items":{"description":"Same shape as the [Modify Order](#operation/modifyOrder) request body (business fields only).","type":"object"}}}}]}}}},"responses":{"200":{"description":"Batch modify acknowledged"}}}}},"components":{"schemas":{"WriteCommonParams":{"type":"object","required":["address","nonce","expires_after","signature"],"properties":{"address":{"type":"string","description":"Signer's Ethereum address (`0x`-prefixed, lowercase hex). The node uses `ecrecover` to verify this matches the recovered signer.","pattern":"^0x[a-fA-F0-9]{40}$"},"nonce":{"type":"integer","format":"int64","description":"Millisecond Unix timestamp (`Date.now()`). Tracked **per signer** — each Agent Key has an independent nonce space."},"expires_after":{"type":"integer","format":"int64","description":"Expiration timestamp (ms). Recommended `Date.now() + 600_000` (10 minutes)."},"target_address":{"type":"string","description":"Optional target account address. Omit to operate on the signer's own account.\nUsed when an Agent operates on a sub-account.\n**Conditionally signed**: it does not enter `actionHash`, but when present it must be\nincluded as `Agent.targetAddress` in the EIP-712 struct (6-field Agent — see Signing\nMethod A). **Not allowed** on private-key-only endpoints.\n","pattern":"^0x[a-fA-F0-9]{40}$"},"signature":{"$ref":"#/components/schemas/Signature"}}},"Signature":{"type":"object","description":"ECDSA signature components `(r, s, v)` over the EIP-712 signing hash.","required":["r","s","v"],"properties":{"r":{"type":"string","description":"32-byte hex string with `0x` prefix."},"s":{"type":"string","description":"32-byte hex string with `0x` prefix."},"v":{"type":"integer","description":"Recovery identifier — typically 27 or 28.","enum":[27,28]}}}}}}
```

## Batch Cancel Orders

> Cancel multiple active orders in one signed request by order identifiers.

```json
{"openapi":"3.0.3","info":{"title":"UniX API","version":"1.11.0"},"tags":[{"name":"Trading"}],"servers":[{"url":"https://api.unixtrade.pro/v1","description":"Production"}],"paths":{"/trade/orders/batch/cancel":{"post":{"tags":["Trading"],"summary":"Batch Cancel Orders","operationId":"batchCancelOrders","description":"Cancel multiple active orders in one signed request by order identifiers.","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/WriteCommonParams"},{"type":"object","required":["orders"],"properties":{"orders":{"type":"array","maxItems":20,"items":{"type":"object","properties":{"order_id":{"type":"string"},"client_order_id":{"type":"string"}}}}}}]}}}},"responses":{"200":{"description":"Batch cancel acknowledged. Per-order results pushed via `order` WS channel."}}}}},"components":{"schemas":{"WriteCommonParams":{"type":"object","required":["address","nonce","expires_after","signature"],"properties":{"address":{"type":"string","description":"Signer's Ethereum address (`0x`-prefixed, lowercase hex). The node uses `ecrecover` to verify this matches the recovered signer.","pattern":"^0x[a-fA-F0-9]{40}$"},"nonce":{"type":"integer","format":"int64","description":"Millisecond Unix timestamp (`Date.now()`). Tracked **per signer** — each Agent Key has an independent nonce space."},"expires_after":{"type":"integer","format":"int64","description":"Expiration timestamp (ms). Recommended `Date.now() + 600_000` (10 minutes)."},"target_address":{"type":"string","description":"Optional target account address. Omit to operate on the signer's own account.\nUsed when an Agent operates on a sub-account.\n**Conditionally signed**: it does not enter `actionHash`, but when present it must be\nincluded as `Agent.targetAddress` in the EIP-712 struct (6-field Agent — see Signing\nMethod A). **Not allowed** on private-key-only endpoints.\n","pattern":"^0x[a-fA-F0-9]{40}$"},"signature":{"$ref":"#/components/schemas/Signature"}}},"Signature":{"type":"object","description":"ECDSA signature components `(r, s, v)` over the EIP-712 signing hash.","required":["r","s","v"],"properties":{"r":{"type":"string","description":"32-byte hex string with `0x` prefix."},"s":{"type":"string","description":"32-byte hex string with `0x` prefix."},"v":{"type":"integer","description":"Recovery identifier — typically 27 or 28.","enum":[27,28]}}}}}}
```

## Chase Order

> Re-price an existing limit order so it follows the current best bid or best ask.

```json
{"openapi":"3.0.3","info":{"title":"UniX API","version":"1.11.0"},"tags":[{"name":"Trading"}],"servers":[{"url":"https://api.unixtrade.pro/v1","description":"Production"}],"paths":{"/trade/orders/chase":{"post":{"tags":["Trading"],"summary":"Chase Order","operationId":"chaseOrder","description":"Re-price an existing limit order so it follows the current best bid or best ask.","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/WriteCommonParams"},{"type":"object","properties":{"order_id":{"type":"string"},"client_order_id":{"type":"string"}}}]}}}},"responses":{"200":{"description":"Chase acknowledged"}}}}},"components":{"schemas":{"WriteCommonParams":{"type":"object","required":["address","nonce","expires_after","signature"],"properties":{"address":{"type":"string","description":"Signer's Ethereum address (`0x`-prefixed, lowercase hex). The node uses `ecrecover` to verify this matches the recovered signer.","pattern":"^0x[a-fA-F0-9]{40}$"},"nonce":{"type":"integer","format":"int64","description":"Millisecond Unix timestamp (`Date.now()`). Tracked **per signer** — each Agent Key has an independent nonce space."},"expires_after":{"type":"integer","format":"int64","description":"Expiration timestamp (ms). Recommended `Date.now() + 600_000` (10 minutes)."},"target_address":{"type":"string","description":"Optional target account address. Omit to operate on the signer's own account.\nUsed when an Agent operates on a sub-account.\n**Conditionally signed**: it does not enter `actionHash`, but when present it must be\nincluded as `Agent.targetAddress` in the EIP-712 struct (6-field Agent — see Signing\nMethod A). **Not allowed** on private-key-only endpoints.\n","pattern":"^0x[a-fA-F0-9]{40}$"},"signature":{"$ref":"#/components/schemas/Signature"}}},"Signature":{"type":"object","description":"ECDSA signature components `(r, s, v)` over the EIP-712 signing hash.","required":["r","s","v"],"properties":{"r":{"type":"string","description":"32-byte hex string with `0x` prefix."},"s":{"type":"string","description":"32-byte hex string with `0x` prefix."},"v":{"type":"integer","description":"Recovery identifier — typically 27 or 28.","enum":[27,28]}}}}}}
```

## Cancel All Orders

> Cancel all active orders that match the optional symbol, side, or order-type filters.

```json
{"openapi":"3.0.3","info":{"title":"UniX API","version":"1.11.0"},"tags":[{"name":"Trading"}],"servers":[{"url":"https://api.unixtrade.pro/v1","description":"Production"}],"paths":{"/trade/orders/cancel-all":{"post":{"tags":["Trading"],"summary":"Cancel All Orders","operationId":"cancelAllOrders","description":"Cancel all active orders that match the optional symbol, side, or order-type filters.","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/WriteCommonParams"},{"type":"object","properties":{"symbol_id":{"type":"integer"},"is_buy":{"type":"boolean"},"position_side":{"type":"string","enum":["both","long","short"]},"margin_mode":{"type":"string","enum":["cross","isolated"]},"order_type":{"type":"string","description":"Optional filter: market, limit, conditional, partial_tpsl, full_tpsl."}}}]}}}},"responses":{"200":{"description":"Cancel-all acknowledged","content":{"application/json":{}}}}}}},"components":{"schemas":{"WriteCommonParams":{"type":"object","required":["address","nonce","expires_after","signature"],"properties":{"address":{"type":"string","description":"Signer's Ethereum address (`0x`-prefixed, lowercase hex). The node uses `ecrecover` to verify this matches the recovered signer.","pattern":"^0x[a-fA-F0-9]{40}$"},"nonce":{"type":"integer","format":"int64","description":"Millisecond Unix timestamp (`Date.now()`). Tracked **per signer** — each Agent Key has an independent nonce space."},"expires_after":{"type":"integer","format":"int64","description":"Expiration timestamp (ms). Recommended `Date.now() + 600_000` (10 minutes)."},"target_address":{"type":"string","description":"Optional target account address. Omit to operate on the signer's own account.\nUsed when an Agent operates on a sub-account.\n**Conditionally signed**: it does not enter `actionHash`, but when present it must be\nincluded as `Agent.targetAddress` in the EIP-712 struct (6-field Agent — see Signing\nMethod A). **Not allowed** on private-key-only endpoints.\n","pattern":"^0x[a-fA-F0-9]{40}$"},"signature":{"$ref":"#/components/schemas/Signature"}}},"Signature":{"type":"object","description":"ECDSA signature components `(r, s, v)` over the EIP-712 signing hash.","required":["r","s","v"],"properties":{"r":{"type":"string","description":"32-byte hex string with `0x` prefix."},"s":{"type":"string","description":"32-byte hex string with `0x` prefix."},"v":{"type":"integer","description":"Recovery identifier — typically 27 or 28.","enum":[27,28]}}}}}}
```

## List Active Orders

> Return active non-terminal orders for an address, with optional symbol and order-type filters.

```json
{"openapi":"3.0.3","info":{"title":"UniX API","version":"1.11.0"},"tags":[{"name":"Trading"}],"servers":[{"url":"https://api.unixtrade.pro/v1","description":"Production"}],"paths":{"/trade/orders":{"get":{"tags":["Trading"],"summary":"List Active Orders","operationId":"listActiveOrders","description":"Return active non-terminal orders for an address, with optional symbol and order-type filters.","parameters":[{"$ref":"#/components/parameters/AddressQuery"},{"$ref":"#/components/parameters/SymbolIdQuery"},{"name":"order_type","in":"query","required":false,"schema":{"type":"string"},"description":"Filter by market, limit, conditional, partial_tpsl, or full_tpsl. Comma-join multiple values."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":50,"maximum":500}},{"name":"cursor","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Active orders sorted by `updated_time` desc.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ResponseEnvelope"},{"type":"object","properties":{"data":{"type":"object","properties":{"list":{"type":"array","items":{"$ref":"#/components/schemas/Order"}}}}}}]}}}}}}}},"components":{"parameters":{"AddressQuery":{"name":"address","in":"query","required":true,"schema":{"type":"string","pattern":"^0x[a-fA-F0-9]{40}$"},"description":"Account address (`0x`-prefixed hex)."},"SymbolIdQuery":{"name":"symbol_id","in":"query","required":false,"schema":{"type":"integer"},"description":"Symbol ID. Omit to match all symbols."}},"schemas":{"ResponseEnvelope":{"type":"object","description":"Standard response envelope shared by every endpoint.","required":["code","msg","data"],"properties":{"code":{"type":"string","description":"`\"0\"` for success. Non-zero indicates an error code — see [Error Codes](/reference/error-codes)."},"msg":{"type":"string","description":"Empty on success; human-readable error description on failure."},"data":{"description":"Endpoint-specific payload on success; `null` on failure.","nullable":true},"trace_code":{"type":"string","description":"Backend trace identifier. Empty on success; populated on failure for support diagnostics."}}},"Order":{"type":"object","description":"Full Order object returned by query endpoints and the `order` WebSocket channel.","properties":{"order_id":{"type":"string","description":"System-generated order ID."},"client_order_id":{"type":"string","nullable":true,"description":"Custom client order ID (≤ 36 chars)."},"address":{"type":"string"},"created_time":{"type":"integer","format":"int64"},"updated_time":{"type":"integer","format":"int64"},"symbol_id":{"type":"integer"},"is_buy":{"type":"boolean"},"order_type":{"type":"string","enum":["market","limit"]},"algo_order_type":{"type":"string","nullable":true,"enum":["conditional","tpsl","attached_tpsl",null]},"time_in_force":{"type":"string","nullable":true,"enum":["gtc","ioc","fok",null]},"quantity":{"type":"string"},"price":{"type":"string","nullable":true},"price_match":{"type":"string","nullable":true,"enum":["queue_1","queue_5","counter_party_1","counter_party_5",null]},"position_side":{"type":"string","nullable":true,"enum":["both","long","short",null]},"margin_mode":{"type":"string","nullable":true,"enum":["cross","isolated",null]},"market_order_type":{"type":"string","enum":["base","quote"],"description":"Perp defaults to `base`; spot is required (`base` / `quote`)."},"stp_mode":{"type":"string","nullable":true,"enum":["cancel_maker","cancel_taker","cancel_both","none",null]},"flags":{"type":"array","nullable":true,"items":{"type":"string","enum":["post_only","reduce_only"]}},"state":{"type":"string","description":"Order state — see [Order Object](/reference/order-object) for full state machine.","enum":["pending_new","new","partially_filled","filled","pending_cancel","canceled","rejected","inactive","pending_trigger","triggered"]},"cum_filled_quantity":{"type":"string"},"cum_filled_amount":{"type":"string"},"remaining_quantity":{"type":"string"},"original_quantity":{"type":"string"},"cum_fee":{"type":"string"},"order_source":{"type":"string","nullable":true},"conditional":{"$ref":"#/components/schemas/OrderConditionalParams"},"tpsl":{"$ref":"#/components/schemas/OrderTpslParams"},"parent_order_id":{"type":"string","nullable":true},"slippage":{"type":"string","nullable":true},"tx_hash":{"type":"string","description":"Creation/last-update transaction hash."},"leverage":{"type":"integer","description":"Leverage used when the order was placed."}}},"OrderConditionalParams":{"type":"object","description":"Conditional order trigger. Required when `algo_order_type=conditional`.","required":["trigger_price","trigger_by"],"properties":{"trigger_price":{"type":"string"},"trigger_by":{"type":"string","enum":["last_price","mark_price","oracle_price"],"description":"Spot supports `last_price` only; perp supports all three."}}},"OrderTpslParams":{"type":"object","description":"Take-profit / stop-loss parameters. Required when `algo_order_type` is `tpsl` or `attached_tpsl`; optional for normal/conditional orders.","properties":{"tpsl_mode":{"type":"string","enum":["full","partial"],"description":"`full` closes the full position when triggered; `partial` closes only the original quantity."},"tp_trigger_price":{"type":"string","description":"Take-profit trigger price (decimal string)."},"tp_trigger_by":{"type":"string","enum":["last_price","mark_price","oracle_price"],"description":"Spot supports `last_price` only; perp supports all three."},"tp_order_type":{"type":"string","enum":["market","limit"]},"tp_order_price":{"type":"string","description":"Take-profit limit price (required when `tp_order_type=limit`)."},"sl_trigger_price":{"type":"string","description":"Stop-loss trigger price."},"sl_trigger_by":{"type":"string","enum":["last_price","mark_price","oracle_price"],"description":"Spot supports `last_price` only; perp supports all three."},"sl_order_type":{"type":"string","enum":["market","limit"]},"sl_order_price":{"type":"string"}}}}}}
```

## Order History

> Return historical terminal orders for an address, including filled, canceled, rejected, or triggered orders.

```json
{"openapi":"3.0.3","info":{"title":"UniX API","version":"1.11.0"},"tags":[{"name":"Trading"}],"servers":[{"url":"https://api.unixtrade.pro/v1","description":"Production"}],"paths":{"/trade/orders/history":{"get":{"tags":["Trading"],"summary":"Order History","operationId":"orderHistory","description":"Return historical terminal orders for an address, including filled, canceled, rejected, or triggered orders.","parameters":[{"$ref":"#/components/parameters/AddressQuery"},{"$ref":"#/components/parameters/SymbolIdQuery"},{"name":"order_type","in":"query","required":false,"schema":{"type":"string"},"description":"Filter by market, limit, conditional, partial_tpsl, or full_tpsl. Comma-join multiple values."},{"$ref":"#/components/parameters/StartTimeQuery"},{"$ref":"#/components/parameters/EndTimeQuery"},{"$ref":"#/components/parameters/LimitQuery"},{"$ref":"#/components/parameters/CursorQuery"}],"responses":{"200":{"description":"Order history (paginated, `updated_time` desc)","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ResponseEnvelope"},{"type":"object","properties":{"data":{"type":"object","properties":{"list":{"type":"array","items":{"$ref":"#/components/schemas/Order"}},"next_cursor":{"type":"string","nullable":true},"has_more":{"type":"boolean"}}}}}]}}}}}}}},"components":{"parameters":{"AddressQuery":{"name":"address","in":"query","required":true,"schema":{"type":"string","pattern":"^0x[a-fA-F0-9]{40}$"},"description":"Account address (`0x`-prefixed hex)."},"SymbolIdQuery":{"name":"symbol_id","in":"query","required":false,"schema":{"type":"integer"},"description":"Symbol ID. Omit to match all symbols."},"StartTimeQuery":{"name":"start_time","in":"query","required":false,"schema":{"type":"integer","format":"int64"},"description":"Start time (Unix ms)."},"EndTimeQuery":{"name":"end_time","in":"query","required":false,"schema":{"type":"integer","format":"int64"},"description":"End time (Unix ms)."},"LimitQuery":{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":50},"description":"Page size."},"CursorQuery":{"name":"cursor","in":"query","required":false,"schema":{"type":"string"},"description":"Pagination cursor from the previous response's `next_cursor`."}},"schemas":{"ResponseEnvelope":{"type":"object","description":"Standard response envelope shared by every endpoint.","required":["code","msg","data"],"properties":{"code":{"type":"string","description":"`\"0\"` for success. Non-zero indicates an error code — see [Error Codes](/reference/error-codes)."},"msg":{"type":"string","description":"Empty on success; human-readable error description on failure."},"data":{"description":"Endpoint-specific payload on success; `null` on failure.","nullable":true},"trace_code":{"type":"string","description":"Backend trace identifier. Empty on success; populated on failure for support diagnostics."}}},"Order":{"type":"object","description":"Full Order object returned by query endpoints and the `order` WebSocket channel.","properties":{"order_id":{"type":"string","description":"System-generated order ID."},"client_order_id":{"type":"string","nullable":true,"description":"Custom client order ID (≤ 36 chars)."},"address":{"type":"string"},"created_time":{"type":"integer","format":"int64"},"updated_time":{"type":"integer","format":"int64"},"symbol_id":{"type":"integer"},"is_buy":{"type":"boolean"},"order_type":{"type":"string","enum":["market","limit"]},"algo_order_type":{"type":"string","nullable":true,"enum":["conditional","tpsl","attached_tpsl",null]},"time_in_force":{"type":"string","nullable":true,"enum":["gtc","ioc","fok",null]},"quantity":{"type":"string"},"price":{"type":"string","nullable":true},"price_match":{"type":"string","nullable":true,"enum":["queue_1","queue_5","counter_party_1","counter_party_5",null]},"position_side":{"type":"string","nullable":true,"enum":["both","long","short",null]},"margin_mode":{"type":"string","nullable":true,"enum":["cross","isolated",null]},"market_order_type":{"type":"string","enum":["base","quote"],"description":"Perp defaults to `base`; spot is required (`base` / `quote`)."},"stp_mode":{"type":"string","nullable":true,"enum":["cancel_maker","cancel_taker","cancel_both","none",null]},"flags":{"type":"array","nullable":true,"items":{"type":"string","enum":["post_only","reduce_only"]}},"state":{"type":"string","description":"Order state — see [Order Object](/reference/order-object) for full state machine.","enum":["pending_new","new","partially_filled","filled","pending_cancel","canceled","rejected","inactive","pending_trigger","triggered"]},"cum_filled_quantity":{"type":"string"},"cum_filled_amount":{"type":"string"},"remaining_quantity":{"type":"string"},"original_quantity":{"type":"string"},"cum_fee":{"type":"string"},"order_source":{"type":"string","nullable":true},"conditional":{"$ref":"#/components/schemas/OrderConditionalParams"},"tpsl":{"$ref":"#/components/schemas/OrderTpslParams"},"parent_order_id":{"type":"string","nullable":true},"slippage":{"type":"string","nullable":true},"tx_hash":{"type":"string","description":"Creation/last-update transaction hash."},"leverage":{"type":"integer","description":"Leverage used when the order was placed."}}},"OrderConditionalParams":{"type":"object","description":"Conditional order trigger. Required when `algo_order_type=conditional`.","required":["trigger_price","trigger_by"],"properties":{"trigger_price":{"type":"string"},"trigger_by":{"type":"string","enum":["last_price","mark_price","oracle_price"],"description":"Spot supports `last_price` only; perp supports all three."}}},"OrderTpslParams":{"type":"object","description":"Take-profit / stop-loss parameters. Required when `algo_order_type` is `tpsl` or `attached_tpsl`; optional for normal/conditional orders.","properties":{"tpsl_mode":{"type":"string","enum":["full","partial"],"description":"`full` closes the full position when triggered; `partial` closes only the original quantity."},"tp_trigger_price":{"type":"string","description":"Take-profit trigger price (decimal string)."},"tp_trigger_by":{"type":"string","enum":["last_price","mark_price","oracle_price"],"description":"Spot supports `last_price` only; perp supports all three."},"tp_order_type":{"type":"string","enum":["market","limit"]},"tp_order_price":{"type":"string","description":"Take-profit limit price (required when `tp_order_type=limit`)."},"sl_trigger_price":{"type":"string","description":"Stop-loss trigger price."},"sl_trigger_by":{"type":"string","enum":["last_price","mark_price","oracle_price"],"description":"Spot supports `last_price` only; perp supports all three."},"sl_order_type":{"type":"string","enum":["market","limit"]},"sl_order_price":{"type":"string"}}}}}}
```

## Executions

> Return trade execution records for an address, including fills generated by matched orders.

```json
{"openapi":"3.0.3","info":{"title":"UniX API","version":"1.11.0"},"tags":[{"name":"Trading"}],"servers":[{"url":"https://api.unixtrade.pro/v1","description":"Production"}],"paths":{"/trade/executions":{"get":{"tags":["Trading"],"summary":"Executions","operationId":"listExecutions","description":"Return trade execution records for an address, including fills generated by matched orders.","parameters":[{"$ref":"#/components/parameters/AddressQuery"},{"$ref":"#/components/parameters/SymbolIdQuery"},{"name":"order_id","in":"query","required":false,"schema":{"type":"string"},"description":"Filter by order ID."},{"$ref":"#/components/parameters/StartTimeQuery"},{"$ref":"#/components/parameters/EndTimeQuery"},{"$ref":"#/components/parameters/LimitQuery"},{"$ref":"#/components/parameters/CursorQuery"}],"responses":{"200":{"description":"Executions (paginated)","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ResponseEnvelope"},{"type":"object","properties":{"data":{"type":"object","properties":{"list":{"type":"array","items":{"$ref":"#/components/schemas/Execution"}},"next_cursor":{"type":"string","nullable":true},"has_more":{"type":"boolean"}}}}}]}}}}}}}},"components":{"parameters":{"AddressQuery":{"name":"address","in":"query","required":true,"schema":{"type":"string","pattern":"^0x[a-fA-F0-9]{40}$"},"description":"Account address (`0x`-prefixed hex)."},"SymbolIdQuery":{"name":"symbol_id","in":"query","required":false,"schema":{"type":"integer"},"description":"Symbol ID. Omit to match all symbols."},"StartTimeQuery":{"name":"start_time","in":"query","required":false,"schema":{"type":"integer","format":"int64"},"description":"Start time (Unix ms)."},"EndTimeQuery":{"name":"end_time","in":"query","required":false,"schema":{"type":"integer","format":"int64"},"description":"End time (Unix ms)."},"LimitQuery":{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":50},"description":"Page size."},"CursorQuery":{"name":"cursor","in":"query","required":false,"schema":{"type":"string"},"description":"Pagination cursor from the previous response's `next_cursor`."}},"schemas":{"ResponseEnvelope":{"type":"object","description":"Standard response envelope shared by every endpoint.","required":["code","msg","data"],"properties":{"code":{"type":"string","description":"`\"0\"` for success. Non-zero indicates an error code — see [Error Codes](/reference/error-codes)."},"msg":{"type":"string","description":"Empty on success; human-readable error description on failure."},"data":{"description":"Endpoint-specific payload on success; `null` on failure.","nullable":true},"trace_code":{"type":"string","description":"Backend trace identifier. Empty on success; populated on failure for support diagnostics."}}},"Execution":{"type":"object","properties":{"trade_id":{"type":"string"},"order_id":{"type":"string"},"symbol_id":{"type":"integer"},"is_buy":{"type":"boolean","description":"`true` = buy, `false` = sell."},"price":{"type":"string"},"quantity":{"type":"string"},"amount":{"type":"string"},"fee":{"type":"string"},"fee_coin_id":{"type":"integer"},"is_maker":{"type":"boolean"},"tx_hash":{"type":"string"},"time":{"type":"integer","format":"int64"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.unix.market/rest-api/trading.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
