Create Algo Order Sample

STOP

STOP order will be triggered once the given trigger_price is reached and new order of trigger_price_type will be created.

{
    "symbol": "PERP_NEAR_USDC", 
    "algo_type": "STOP", 
    "quantity": "5.5", 
    "side": "BUY", 
    "type": "LIMIT", 
    "trigger_price_type": "MARK_PRICE", 
    "trigger_price": "4.203", 
    "price": "3.5"
}

TP_SL

  • For each TP_SL order placed, three algo orders will be created in Orderly system.

  • To edit a TP_SL order, user must send the edit order request on the root_algo_order and must pass both root_algo_order and child_orders as parameters. User may pass only one child_order for editing. If the goal is to edit quantity, both child_order must be passed and the quantity need to be identical.

  • For each user, there can be at most 10 untriggered TP_SL orders.

  • For each user, there can be at most 1 untriggered POSITIONAL_TP_SL order.

{
    "symbol": "PERP_NEAR_USDC",
    "algo_type": "TP_SL",
    "quantity": "5.5",
    "trigger_price_type": "MARK_PRICE",
    "order_tag": "test_tag",
    "child_orders": [
        {
            "symbol": "PERP_NEAR_USDC",
            "algo_type": "TAKE_PROFIT",
            "side": "SELL",
            "type": "MARKET",
            "trigger_price": 3.365,
            "reduce_only": true
        },
        {
            "symbol": "PERP_NEAR_USDC",
            "algo_type": "STOP_LOSS",
            "side": "SELL",
            "type": "MARKET",
            "trigger_price": 3.36,
            "reduce_only": true
        }
    ]
}

POSITIONAL_TP_SL

{
    "symbol": "PERP_NEAR_USDC", 
    "algo_type": "POSITIONAL_TP_SL", 
    "trigger_price_type": "MARK_PRICE", 
    "child_orders": [
        {
            "symbol": "PERP_NEAR_USDC", 
            "algo_type": "TAKE_PROFIT", 
            "side": "SELL", 
            "type": "CLOSE_POSITION", 
            "trigger_price_type": "MARK_PRICE", 
            "trigger_price": 4.05, 
            "reduce_only": true
        }, 
        {
            "symbol": "PERP_NEAR_USDC", 
            "algo_type": "STOP_LOSS", 
            "side": "SELL", 
            "type": "CLOSE_POSITION", 
            "trigger_price_type": "MARK_PRICE", 
            "trigger_price": 3.95, 
            "reduce_only": true
        }
    ]
}

BRACKET

The nature of BRACKET order is to use track a regular order and close its position with TP_SL \ POSITIONAL_TP_SL order. In this example, assume the regular order under BRACKET order as leg_1 and the TP_SL \ POSITIONAL_TP_SL child order under BRACKET order as leg_2.

leg_1 = BRACKET and the triggered regular order

leg_2 = POSITIONAL_TP_SL \ TP_SL and their triggered child orders

BRACKET + TP_SL : The quantity of TP_SL order is determined by the executed_quantity of leg_1.

BRACKET + POSITIONAL_TP_SL : The quantity of POSITIONAL_TP_SL order is determined by the user’s position at the time of triggering.

Note: For BRACKET + POSITIONAL_TP_SL, when leg_2’s POSITIONAL_TP_SL order is triggered, the previously active POSITIONAL_TP_SL orders will be canceled. If there were existing triggered POSITIONAL_TP_SL order, leg_2 will be canceled.

Makes sure there’s only one active POSITIONAL_TP_SL order. For any of the regular order under leg_1 being executed, leg_1 and leg_2 will be cutoff such that leg_2 becomes an independent POSITIONAL_TP_SL order.

{
  "symbol": "PERP_ETH_USDC",
  "algo_type": "BRACKET",
  "quantity": "0.0032",
  "side": "BUY",
  "type": "LIMIT",
  "price": "3415.9",
  "child_orders": [
    {
      "symbol": "PERP_ETH_USDC",
      "algo_type": "POSITIONAL_TP_SL",
      "child_orders": [
        {
          "symbol": "PERP_ETH_USDC",
          "algo_type": "TAKE_PROFIT",
          "side": "SELL",
          "type": "CLOSE_POSITION",
          "trigger_price": "3518.4",
          "reduce_only": true
        },
        {
          "symbol": "PERP_ETH_USDC",
          "algo_type": "STOP_LOSS",
          "side": "SELL",
          "type": "CLOSE_POSITION",
          "trigger_price": "3313.4",
          "reduce_only": true
        }
      ]
    }
  ]
}