Place algo order
The algo order includes trigger order, oco order, chase order, conditional order, twap order and trailing order.
Authentication
Base64-encoded HMAC-SHA256 signature of the prehash string.
ISO 8601 UTC timestamp, e.g. 2020-12-08T09:08:57.715Z.
Request
Instrument ID, e.g. BTC-USDT
Trade mode Margin mode cross isolated Non-Margin mode cash spot_isolated (only applicable to SPOT lead trading) Note: isolated is not available in multi-currency margin mode and portfolio margin mode.
Order side, buy sell
Order type conditional: One-way stop order oco: One-cancels-the-other order chase: chase order, only applicable to FUTURES and SWAP trigger: Trigger order move_order_stop: Trailing order twap: TWAP order smart_iceberg: Iceberg order
Quantity to buy or sell Either sz or closeFraction is required.
Margin currency Applicable to all isolated MARGIN orders and cross MARGIN orders in Futures mode.
Position side Required in long/short mode and only be long or short
Client-supplied Algo ID A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
Order tag A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters.
Whether the order can only reduce the position size. Valid options: true or false. The default value is false. This parameter is only valid in the FUTRUES/SWAP net mode, and is ignored in the long/short mode.
Order quantity unit setting for sz base_ccy: Base currency ,quote_ccy: Quote currency Only applicable to SPOT traded with Market buy conditional order Default is quote_ccy for buy, base_ccy for sell
Take-profit trigger price If you fill in this parameter, you should fill in the take-profit order price as well.
Take-profit trigger price type last: last price index: index price mark: mark price The default is last
Take-profit order price For condition TP order, if you fill in this parameter, you should fill in the take-profit trigger price as well. For limit TP order, you need to fill in this parameter, but the take-profit trigger price doesn’t need to be filled. If the price is -1, take-profit will be executed at the market price.
Stop-loss trigger price If you fill in this parameter, you should fill in the stop-loss order price.
Stop-loss trigger price type last: last price index: index price mark: mark price The default is last
Stop-loss order price If you fill in this parameter, you should fill in the stop-loss trigger price. If the price is -1, stop-loss will be executed at the market price.
The price level that activates this algo order. Unit: same as px for the instrument. Which price feed is compared depends on triggerPxType (default: last trade price). Direction: for a sell stop-loss, trigger must be below orderPx; for a buy stop, above orderPx. Error codes 51046–51049 are returned for direction violations.
Trigger price type: last: triggers when any trade occurs at or beyond triggerPx — most responsive but vulnerable to brief price wicks in thin markets. index: triggers on the underlying multi-exchange composite index — stable, not affected by OKX-specific wicks. mark: triggers on OKX mark price — smoothed and wick-resistant; recommended for derivatives. last is the only option available for SPOT instruments. The default is last.
Price of the order submitted when triggerPx is reached. This is separate from triggerPx (which determines when the algo activates). Set to -1 to submit a market order when triggered; set to a specific price to submit a limit order. Not applicable when advanceOrdType is chase (a chase has no fixed price).
Callback price ratio, e.g. 0.01 represents 1% Either callbackRatio or callbackSpread is allowed to be passed.
Active price The system will only start tracking the market and calculating your trigger price after the activation price is reached. If you don’t set a price, your order will be activated as soon as it’s placed.
Price variance by percentage, range between [0.0001 ~ 0.01], e.g. 0.01 represents 1% Take buy orders as an example. When the market price is lower than the limit price, small buy orders will be placed above the best bid price within a certain range. This parameter determines the range by percentage. Either pxVar or pxSpread is allowed to be passed.
Price variance by constant, should be no less then 0 (no upper limit) Take buy orders as an example. When the market price is lower than the limit price, small buy orders will be placed above the best bid price within a certain range. This parameter determines the range by constant.
Minimum order size per execution. Only applicable to smart_iceberg
Price limit. Only applicable to smart_iceberg
Time interval in unit of second ake buy orders as an example. When the market price is lower than the limit price, small buy orders will be placed above the best bid price within a certain range based on the time cycle. This parameter represents the time cycle.
Response
Result code. 0 means success; any other value is an error code.

