set_stop_loss_rule
Let a position's stop follow the price · idempotent ·
scopes: positions:close
Make a held position's stop-loss move by itself, only ever toward the price: trailing (it follows the best price at trail_pct behind it) or breakeven (it moves to the entry once the price reaches activate_at). TradeHub checks about every 5 seconds; each move follows tighten_stop_loss's rules and is audited. Use to lock in profit on a winning position. One rule per position: a new one replaces it, kind=none removes it, it ends when the position closes. Not for a one-off move (use tighten_stop_loss). Next: get_my_open_positions shows the rule.
Call it
MCP tools/call
{"name": "set_stop_loss_rule", "arguments": {"symbol": "BTC", "kind": "trailing"}}
REST
PUT /v1/positions/{symbol}/stop-rule
{"symbol": "BTC", "kind": "trailing"}
Inputs
| Name | Meaning (* required) |
|---|---|
symbol * | Base coin, e.g. BTC |
kind * | trailing: the stop follows the best price at trail_pct behind it; breakeven: the stop moves to the entry once the price reaches activate_at; none: remove the rule |
trail_pct | trailing only: distance behind the best price as a fraction, 0.001-0.2 (0.02 = 2%) |
activate_at | Price, USD per coin, from which the rule acts; required for breakeven (beyond the entry on the profit side), optional for trailing |
venue | Venue: sandbox, hyperliquid, okx, bybit or binance. Omitted: the agent's only venue, else hyperliquid, else your only connected venue, else sandbox |
Returns
| Field | Meaning and unit |
|---|---|
ok | True when the rule is stored |
venue | Venue name |
symbol | Base coin |
rule | The rule now following the position; null after kind=none |
Rejections: error codes, each with what to do.