# Trading

Order management — place, modify, cancel, batch operations, and order/execution queries. All write endpoints accept an Agent Key signature.

## List Active Orders

> Return all non-terminal orders for \`address\`.

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"tags":[{"name":"Trading","description":"Order management — place, modify, cancel, batch operations, and order/execution queries.\nAll write endpoints accept an Agent Key signature.\n"}],"servers":[{"url":"http://10.34.8.77:8481/v1","description":"Production"}],"paths":{"/trade/orders":{"get":{"tags":["Trading"],"summary":"List Active Orders","operationId":"listActiveOrders","description":"Return all non-terminal orders for `address`.","parameters":[{"$ref":"#/components/parameters/AddressQuery"},{"$ref":"#/components/parameters/SymbolIdQuery"},{"name":"order_type","in":"query","required":false,"schema":{"type":"string"},"description":"Filter by order type: `market` / `limit` / `conditional` / `tpsl`. Comma-join for multiple, e.g. `limit,tpsl`."}],"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","nullable":true},"tpsl":{"$ref":"#/components/schemas/OrderTpslParams","nullable":true},"parent_order_id":{"type":"string","nullable":true},"slippage":{"type":"string","nullable":true},"tx_hash":{"type":"string","description":"Creation/last-update transaction hash."}}},"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","index_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","index_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","index_price"],"description":"Spot supports `last_price` only; perp supports all three."},"sl_order_type":{"type":"string","enum":["market","limit"]},"sl_order_price":{"type":"string"}}}}}}
```

## Place Order

> Submit a new order. Supports \`market\`, \`limit\`, \`conditional\`, \`tpsl\`, and \`attached\_tpsl\` order types.\
> \
> \- \*\*Sign with\*\*: Agent Key or user private key (Method A — ActionHash, \`tag = 7\`).\
> \- Returns synchronously once the block including this transaction is finalized (\~50 ms).<br>

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"tags":[{"name":"Trading","description":"Order management — place, modify, cancel, batch operations, and order/execution queries.\nAll write endpoints accept an Agent Key signature.\n"}],"servers":[{"url":"http://10.34.8.77:8481/v1","description":"Production"}],"paths":{"/trade/orders":{"post":{"tags":["Trading"],"summary":"Place Order","operationId":"placeOrder","description":"Submit a new order. Supports `market`, `limit`, `conditional`, `tpsl`, and `attached_tpsl` order types.\n\n- **Sign with**: Agent Key or user private key (Method A — ActionHash, `tag = 7`).\n- Returns synchronously once the block including this transaction is finalized (~50 ms).\n","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","index_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","index_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","index_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"}]}}}}}}}
```

## Cancel Order

> Cancel a single order by \`order\_id\` or \`client\_order\_id\`.\
> Cancelable states: \`new\` / \`partially\_filled\` (limit/post\_only), \`pending\_trigger\` (conditional/tpsl), \`inactive\` (attached\_tpsl).\
> \
> Method A signature (\`tag = 8\`).<br>

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"tags":[{"name":"Trading","description":"Order management — place, modify, cancel, batch operations, and order/execution queries.\nAll write endpoints accept an Agent Key signature.\n"}],"servers":[{"url":"http://10.34.8.77:8481/v1","description":"Production"}],"paths":{"/trade/orders/cancel":{"post":{"tags":["Trading"],"summary":"Cancel Order","operationId":"cancelOrder","description":"Cancel a single order by `order_id` or `client_order_id`.\nCancelable states: `new` / `partially_filled` (limit/post_only), `pending_trigger` (conditional/tpsl), `inactive` (attached_tpsl).\n\nMethod A signature (`tag = 8`).\n","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]}}}}}}
```

## Cancel All Orders

> Cancel all active orders matching the optional filters. All filter fields are AND-combined; omit to match everything.\
> \
> Method A signature (\`tag = 9\`). Per-order results are pushed asynchronously via the \`order\` WebSocket channel.<br>

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"tags":[{"name":"Trading","description":"Order management — place, modify, cancel, batch operations, and order/execution queries.\nAll write endpoints accept an Agent Key signature.\n"}],"servers":[{"url":"http://10.34.8.77:8481/v1","description":"Production"}],"paths":{"/trade/orders/cancel-all":{"post":{"tags":["Trading"],"summary":"Cancel All Orders","operationId":"cancelAllOrders","description":"Cancel all active orders matching the optional filters. All filter fields are AND-combined; omit to match everything.\n\nMethod A signature (`tag = 9`). Per-order results are pushed asynchronously via the `order` WebSocket channel.\n","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"]}}}]}}}},"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]}}}}}}
```

## Modify Order

> Atomically modify price/quantity/TPSL of an existing order. Only include the fields you wish to change.\
> Immutable fields: \`symbol\_id\`, \`is\_buy\`, \`position\_side\`, \`margin\_mode\`, \`order\_type\`, \`flags\`, \`tpsl\_mode\`.\
> \
> Method A signature (\`tag = 12\`).\
> \
> \*\*Queue position\*\*: shrinking quantity (same price) keeps queue position; price change or quantity increase moves to the end of the price level.\
> \
> \*\*Removing attached TPSL\*\*: set both \`tp\_trigger\_price\` and \`sl\_trigger\_price\` to \`"0"\`.<br>

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"tags":[{"name":"Trading","description":"Order management — place, modify, cancel, batch operations, and order/execution queries.\nAll write endpoints accept an Agent Key signature.\n"}],"servers":[{"url":"http://10.34.8.77:8481/v1","description":"Production"}],"paths":{"/trade/orders/modify":{"post":{"tags":["Trading"],"summary":"Modify Order","operationId":"modifyOrder","description":"Atomically modify price/quantity/TPSL of an existing order. Only include the fields you wish to change.\nImmutable fields: `symbol_id`, `is_buy`, `position_side`, `margin_mode`, `order_type`, `flags`, `tpsl_mode`.\n\nMethod A signature (`tag = 12`).\n\n**Queue position**: shrinking quantity (same price) keeps queue position; price change or quantity increase moves to the end of the price level.\n\n**Removing attached TPSL**: set both `tp_trigger_price` and `sl_trigger_price` to `\"0\"`.\n","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","index_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","index_price"],"description":"Spot supports `last_price` only; perp supports all three."},"sl_order_type":{"type":"string","enum":["market","limit"]},"sl_order_price":{"type":"string"}}}}}}
```

## Chase Order

> Re-price a limit order to the current best bid (buy) or best ask (sell).\
> \
> Method A signature (\`tag = 13\`).<br>

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"tags":[{"name":"Trading","description":"Order management — place, modify, cancel, batch operations, and order/execution queries.\nAll write endpoints accept an Agent Key signature.\n"}],"servers":[{"url":"http://10.34.8.77:8481/v1","description":"Production"}],"paths":{"/trade/orders/chase":{"post":{"tags":["Trading"],"summary":"Chase Order","operationId":"chaseOrder","description":"Re-price a limit order to the current best bid (buy) or best ask (sell).\n\nMethod A signature (`tag = 13`).\n","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]}}}}}}
```

## Batch Place Orders

> Place up to \*\*20\*\* orders for the same \`symbol\_id\` in one signed request. Non-atomic — each order is validated and executed independently.\
> \
> Method A signature (\`tag = 17\`).<br>

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"tags":[{"name":"Trading","description":"Order management — place, modify, cancel, batch operations, and order/execution queries.\nAll write endpoints accept an Agent Key signature.\n"}],"servers":[{"url":"http://10.34.8.77:8481/v1","description":"Production"}],"paths":{"/trade/orders/batch":{"post":{"tags":["Trading"],"summary":"Batch Place Orders","operationId":"batchPlaceOrders","description":"Place up to **20** orders for the same `symbol_id` in one signed request. Non-atomic — each order is validated and executed independently.\n\nMethod A signature (`tag = 17`).\n","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 up to \*\*20\*\* orders for the same \`symbol\_id\`. Method A signature (\`tag = 18\`).<br>

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"tags":[{"name":"Trading","description":"Order management — place, modify, cancel, batch operations, and order/execution queries.\nAll write endpoints accept an Agent Key signature.\n"}],"servers":[{"url":"http://10.34.8.77:8481/v1","description":"Production"}],"paths":{"/trade/orders/batch/modify":{"post":{"tags":["Trading"],"summary":"Batch Modify Orders","operationId":"batchModifyOrders","description":"Modify up to **20** orders for the same `symbol_id`. Method A signature (`tag = 18`).\n","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 up to \*\*20\*\* orders in one request. Method A signature (\`tag = 16\`).

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"tags":[{"name":"Trading","description":"Order management — place, modify, cancel, batch operations, and order/execution queries.\nAll write endpoints accept an Agent Key signature.\n"}],"servers":[{"url":"http://10.34.8.77:8481/v1","description":"Production"}],"paths":{"/trade/orders/batch/cancel":{"post":{"tags":["Trading"],"summary":"Batch Cancel Orders","operationId":"batchCancelOrders","description":"Cancel up to **20** orders in one request. Method A signature (`tag = 16`).","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]}}}}}}
```

## Order History

> Terminal-state orders (\`filled\` / \`canceled\` / \`rejected\` / \`triggered\`). Up to 2000 records per page, last 10000 records queryable.

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"tags":[{"name":"Trading","description":"Order management — place, modify, cancel, batch operations, and order/execution queries.\nAll write endpoints accept an Agent Key signature.\n"}],"servers":[{"url":"http://10.34.8.77:8481/v1","description":"Production"}],"paths":{"/trade/orders/history":{"get":{"tags":["Trading"],"summary":"Order History","operationId":"orderHistory","description":"Terminal-state orders (`filled` / `canceled` / `rejected` / `triggered`). Up to 2000 records per page, last 10000 records queryable.","parameters":[{"$ref":"#/components/parameters/AddressQuery"},{"$ref":"#/components/parameters/SymbolIdQuery"},{"name":"order_type","in":"query","required":false,"schema":{"type":"string"},"description":"Filter by order type: `market` / `limit` / `conditional` / `tpsl`. Comma-join for multiple, e.g. `limit,tpsl`."},{"$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","nullable":true},"tpsl":{"$ref":"#/components/schemas/OrderTpslParams","nullable":true},"parent_order_id":{"type":"string","nullable":true},"slippage":{"type":"string","nullable":true},"tx_hash":{"type":"string","description":"Creation/last-update transaction hash."}}},"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","index_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","index_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","index_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

> Trade-fill records. Up to 2000 per page, last 10000 queryable.

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"tags":[{"name":"Trading","description":"Order management — place, modify, cancel, batch operations, and order/execution queries.\nAll write endpoints accept an Agent Key signature.\n"}],"servers":[{"url":"http://10.34.8.77:8481/v1","description":"Production"}],"paths":{"/trade/executions":{"get":{"tags":["Trading"],"summary":"Executions","operationId":"listExecutions","description":"Trade-fill records. Up to 2000 per page, last 10000 queryable.","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: 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.lynxtrade.world/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.
