Trading

Place complex order

Changed on

Places a complex conditional order (OCO, OTO, or OTOCO). Only supported on certain brokerages. Please refer to the brokerage trading support page for details on which brokerages support complex orders and which types they support.

  • OCO (One Cancels the Other): Two peer orders; when one fills the other is cancelled.
  • OTO (One Triggers the Other): A trigger order that, when filled, activates a conditional order.
  • OTOCO (One Triggers a One Cancels the Other): A trigger order that, when filled, activates an OCO pair of two peer orders.

Option OCO peers must trade the same OCC option symbol with the same closing action and positive whole-contract quantity.

On tastytrade, option OCO supports closing an existing long or short option position with one Limit order and one Stop or StopLimit order. Both PEER orders must use SELL_TO_CLOSE or both must use BUY_TO_CLOSE, with Day or GTC time in force. Opening option OCOs are not supported.

On enabled Webull US v3 accounts, option OCO supports closing an existing long option position with one Limit take-profit order and one Stop stop-loss order. Both PEER orders must use SELL_TO_CLOSE, Day, the same OCC option symbol, and the same positive whole-contract quantity. Webull receives these as STOP_PROFIT and STOP_LOSS orders sharing a combo ID, without a MASTER order. Opening option OCOs, BUY_TO_CLOSE, StopLimit, and other option order pairs are not supported on Webull. Equity complex-order behavior is unchanged.

post/accounts/{accountId}/trading/complex

Request

  • Base URL
    https://api.snaptrade.com
  • URL
    https://api.snaptrade.com/accounts/{accountId}/trading/complex
  • Auth
    API key in header Signature and API key in query parameter clientId and API key in query parameter timestamp

Path parameters

accountIdstring uuid required

Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.

Example:917c8734-8470-4a3e-a18f-57c3f2ee6631

The ID of the account to execute the trade on.

Query parameters

userIdstring required

SnapTrade User ID. This is chosen by the API partner and can be any string that is a) unique to the user, and b) immutable for the user. It is recommended to NOT use email addresses for this property because they are usually not immutable.

Example:snaptrade-user-123
userSecretstring required

SnapTrade User Secret. This is a randomly generated string and should be stored securely. If compromised, please rotate it via the rotate user secret endpoint.

Example:adf2aa34-8219-40f7-a6b3-60156985cc61

Request body

type'OCO' | 'OTO' | 'OTOCO' required

The complex order type.

  • OCO: One Cancels the Other — two peer orders.
  • OTO: One Triggers the Other — a trigger order and a conditional order.
  • OTOCO: One Triggers a One Cancels the Other — a trigger order and two peer orders.
client_order_idstring uuid nullable

Optional caller-supplied identifier passed through to the brokerage for idempotent order placement. Must be a canonical 36-character UUID. Idempotency enforcement is brokerage-specific - SnapTrade forwards this value to the broker but does not enforce uniqueness server-side. Refer to per-brokerage documentation for behavior on duplicate submission.

Example request

{
  "type": "OTO",
  "orders": [
    {
      "order_role": "TRIGGER",
      "instrument": {
        "symbol": "AAPL"
      },
      "order_type": "Market",
      "units": 1,
      "time_in_force": "Day",
      "price": 31.33,
      "stop": 29.5
    }
  ],
  "client_order_id": "550e8400-e29b-41d4-a716-446655440000"
}

Response

OK

type'OCO' | 'OTO' | 'OTOCO'

The complex order type that was placed.

brokerage_group_order_idstring nullable

The brokerage-assigned identifier that links all legs of this complex order together. Each leg will eventually appear as a separate AccountOrderRecord sharing this value. May be null if the brokerage does not return a group identifier.

Example response

{
  "type": "OTO",
  "brokerage_group_order_id": "1234567890"
}

Changes

    • breaking

      the response's property type changed from string to no type for status

    • breaking

      the response's property type changed from string to no type for status

    • breaking

      the response's property type changed from string to no type for status

    • breaking

      the response's property type changed from string to no type for status

    • breaking

      the response's property type changed from no type to string for status

    • breaking

      the response's property type changed from no type to string for status

    • breaking

      the response's property type changed from no type to string for status

    • breaking

      the response's property type changed from no type to string for status