Skip to content

Split a take-profit across several targets

A single take-profit is all-or-nothing. Swapping tpPrice for tpLegs on the same endpoint gives you up to three rungs — each a reduce-only limit at its own price and size — sharing one OCO group with the stop, so the stop still covers whatever is left.

  1. You compute the split; the server does not. Read the live size first and divide it — for 0.9 BTC in thirds, three rungs of 0.3.

    Terminal window
    curl -s https://api.troncharts.xyz/api/v1/accounts/$ACCOUNT_ID/positions \
    -H "authorization: Bearer $TOKEN" \
    -H "x-tenant-slug: $TC_TENANT_SLUG"
    # → { positions: [ { symbol: "BTC.HL", qty: "0.9", … } ] }

    The rung quantities are read as RATIOS, not absolute sizes. The server re-sizes the ladder against the live position, so a set that sums to more than the position is scaled down rather than over-closing, and a rung the position cannot fund is dropped instead of being sent as a zero. Send sizedAgainstQty when your ratios were computed against a different size — without it the ladder is read as covering the whole position.

  2. tpLegs takes one to three entries, each with a required positive price and qty. It is mutually exclusive with tpPrice. tag is optional (tp1 / tp2 / tp3) and is display metadata only — the OMS does not persist it, so the functional split is the price and qty you send.

    Terminal window
    curl -s https://api.troncharts.xyz/api/v1/oms/brackets/attach-to-position \
    -H "authorization: Bearer $TOKEN" \
    -H "x-tenant-slug: $TC_TENANT_SLUG" \
    -H 'content-type: application/json' \
    -H "idempotency-key: $(uuidgen)" \
    -d '{
    "symbol": "BTC.HL",
    "tpLegs": [
    { "price": 68000, "qty": 0.3, "tag": "tp1" },
    { "price": 72000, "qty": 0.3, "tag": "tp2" },
    { "price": 78000, "qty": 0.3, "tag": "tp3" }
    ],
    "slPrice": 58500
    }'
  3. tpIntentIds is the array you want — one id per rung, in the order you sent them. tpIntentId (singular) is back-compat and only ever carries the first rung. The response qty is the full protected position size, not a per-rung number.

    { "ok": true, "ocoGroupId": "9c41…",
    "tpIntentId": "1a2b…",
    "tpIntentIds": ["1a2b…", "4c5d…", "6e7f…"],
    "slIntentId": "7d8e…", "side": "sell", "qty": "0.9" }

Next: Attach a take-profit and stop-loss · Cancel an order or close a position · Orders & OMS