Skip to main content

private/advanced/create-otoco

REQUEST 

wss://stream.crypto.com/exchange/v1/user

private/advanced/create-otocoPrivate
Creates a One-Triggers-a-One-Cancels-the-Other (OTOCO) execution strategy on the Exchange.

OTOCO execution strategy allows users to place a three-order strategy where one order automatically triggers the other two when the first order is fully executed. Users are able to place a limit or market order with two trigger orders, and only when the primary order is fully executed, the two trigger orders will take effect. The two trigger orders must be one stop loss and one take profit orders.

SpotAttach / DerivAttach: This API creates SpotAttach (for spot instruments) or DerivAttach (for derivative instruments) order types. The contingency type is automatically resolved from the instrument type. With 3 legs (1 limit/market + 2 triggers), it follows OTOCO behavior.

  • SpotAttach: When either one of the two trigger orders is executed, the other is automatically canceled (OCO behavior). SpotAttach orders are flexible - you can cancel one of the TP/SL legs using private/advanced/cancel-order, effectively converting it to OTO behavior. You can also reattach new TP/SL using private/advanced/create-order with attach_order_id.
  • DerivAttach: For derivatives, the two trigger legs are independent - one firing does NOT cancel the other (unlike SpotAttach). The primary leg may specify isolation_id, leverage, isolated_margin_amount, and exec_inst may include ISOLATED_MARGIN. Trigger legs inherit the isolation mode from the parent leg.

This call is asynchronous, so the response is simply a confirmation of the request. The user.advanced.order subscription can be used to check if the orders are successfully created.

For the content of each order in order_list, please refer to private/create-order for details. One order must be LIMIT or MARKET, and for the two trigger orders, one must be STOP_LOSS or STOP_LIMIT, and the other one must be TAKE_PROFIT or TAKE_PROFIT_LIMIT. The ref_price_type for the trigger orders supports MARK_PRICE (default), INDEX_PRICE, and LAST_PRICE.

Request

Body

required
    id int64required

    Request id (echoed in response)

    method stringrequired

    Must be "private/advanced/create-otoco"

    nonce int64required

    Current timestamp in milliseconds, e.g. "1771761038000".

    params objectrequired
    order_list object[]required
    Possible values: >= 3, <= 3
    Exactly 3 orders. One must be LIMIT or MARKET; one trigger must be STOP_LOSS or STOP_LIMIT, the other TAKE_PROFIT or TAKE_PROFIT_LIMIT. ref_price_type supports MARK_PRICE (default), INDEX_PRICE, LAST_PRICE.
  • Array [
  • instrument_name stringrequired

    Instrument symbol, e.g. BTCUSD-PERP

    side WsOrderSide (string)required

    Possible values: [BUY, SELL]

    BUY or SELL

    quantity decimalrequired

    Order quantity. For MARKET BUY can use notional instead.

    client_oid string

    Client order ID (max 36 chars). Recommended for correlation.

    time_in_force WsTimeInForce (string)

    Possible values: [GOOD_TILL_CANCEL, IMMEDIATE_OR_CANCEL, FILL_OR_KILL]

    Time in force

    exec_inst WsExecInstCreateOrder (string)[]

    Possible values: [POST_ONLY, REDUCE_ONLY, SMART_POST_ONLY, ISOLATED_MARGIN, MARGIN_ORDER]

    Optional array of execution instructions. POST_ONLY and SMART_POST_ONLY mutually exclusive.

    fee_instrument_name string

    Fee instrument (e.g. CRO) for fee deduction

    stp_id string

    Self-trade prevention ID (0 to 32767)

    stp_inst WsStpInst (string)

    Possible values: [M, T, B]

    Self-trade prevention instruction. Used in private/change-account-settings (params) and private/get-account-settings (result). Mandatory if stp_scope is set.

    • ➖ M: Cancel Maker
    • ➖ T: Cancel Taker
    • ➖ B: Cancel Both Maker and Taker
    stp_scope WsStpScope (string)

    Possible values: [M, S, D]

    Self-trade prevention scope. Used in private/change-account-settings (params) and private/get-account-settings (result).

    • ➖ M: Matches Master or Sub a/c
    • ➖ S: Matches Sub a/c only
    • ➖ D: reset all STP fields to default (stp_inst and stp_id in same request are ignored).
    type WsOrderType (string)required

    Possible values: [LIMIT, MARKET, STOP_LOSS, STOP_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT]

    Order type:

    • ➖ LIMIT, MARKET
    • ➖ STOP_LOSS, STOP_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT: Trigger orders
    price decimal

    Limit price (required for LIMIT, STOP_LIMIT, TAKE_PROFIT_LIMIT)

    notional decimal

    Amount to spend; for MARKET/STOP_LOSS/TAKE_PROFIT BUY only

    ref_price decimal

    Trigger price for STOP_LOSS, STOP_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT

    ref_price_type WsRefPriceType (string)

    Possible values: [MARK_PRICE, INDEX_PRICE, LAST_PRICE]

    Reference price type for trigger orders

    spot_margin WsSpotMargin (string)

    Possible values: [SPOT, MARGIN]

    SPOT or MARGIN (spot/margin mode).

    isolated_margin_amount decimal

    Isolated margin amount

    isolation_id string

    Isolation ID for isolated margin

    leverage decimal

    Leverage for margin/derivatives

    attach_order_id int64

    Order ID to attach this trigger order to. Used for SpotAttach / DerivAttach.

  • ]
WebSocket response
Schema
    id int64

    Echoed request id

    method string

    Method invoked

    code int32

    0 = success; non-zero indicates error (reason code).

    result object
    Present when code === 0. list_id.
    list_id int64

    List ID.

    message string

    Present when code !== 0.

    original string

    Present when code !== 0.