- Endpoint:
wss://trade.qfex.com?api_key=YOUR_API_KEY - Authenticate within 1 minute of connecting.
1) Authenticate
Send this immediately after you connect:2) Add TWAP
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
symbol | string | ✅ | The market symbol (for example AAPL-USD). |
side | enum | ✅ | TWAP direction. See OrderDirection. |
total_quantity | number | ✅ | Total quantity to execute across the full TWAP. It is validated against the symbol’s minimum child-order size requirement. |
num_orders | number | ✅ | Number of child orders the engine will schedule. |
order_interval_secs | number | ✅ | Delay in seconds between child orders. |
reduce_only | bool | ✅ | If true, the TWAP may only reduce an existing position. |
client_twap_id | string | Optional | Optional client-assigned TWAP identifier for tracking and cancellation. |
⚠️ Notes:
- TWAP orders are submitted to
trade.qfex.comusing theadd_twapincoming message.- A successful TWAP is returned as
twap_responseand also appears inall_orders_response.twaps.- TWAPs can be cancelled with
cancel_orderusingcancel_order_id_typeset totwap_idorclient_twap_id.- The account must satisfy the same KYC and T&C requirements as standard order entry.
Validation Rules
The server validatesadd_twap requests before forwarding them to the TWAP service.
| Rule | Behavior |
|---|---|
| Symbol must be active | Inactive or unknown symbols are rejected. |
order_interval_secs >= 30 | The minimum interval is 30 seconds. |
num_orders >= 2 | A TWAP must contain at least 2 child orders. |
total_quantity / num_orders >= min_quantity | The average child order size must not fall below the symbol’s min_quantity. |
client_twap_id length | If provided, it must be within the same configured min/max length limits used for client_order_id. |
total_quantityis scaled using the symbol quantity precision before validation.- The current validation shown here does not document any explicit requirement that
total_quantityalign tolot_size, only that the average child size is not belowmin_quantity. - Errors from local validation are returned as
errwitherror_code: "invalid_parameter"and a descriptivemessage.
Sample Code
TWAP Response Shape
Successful TWAP requests are returned as atwap_response object:
| Field | Type | Description |
|---|---|---|
twap_id | string | Server-generated TWAP identifier. |
client_twap_id | string or null | Optional client-provided TWAP identifier. |
user_id | string | Account identifier for the TWAP owner. |
status | string | Current engine status for the TWAP. |
symbol | string | Market symbol. |
total_quantity | number | Total requested quantity across the TWAP. |
filled_quantity | number | Quantity already filled. |
average_fill_price | number | Average execution price across all fills so far. |
total_num_orders | number | Total number of scheduled child orders. |
order_interval_secs | number | Interval between child orders in seconds. |
reduce_only | bool | Whether the TWAP is reduce-only. |
side | enum | TWAP direction. |
updated_at | number or null | Last update timestamp in seconds with fractional precision. |
created_at | number or null | Creation timestamp in seconds with fractional precision. |