Risk and limits
Stop-loss, take-profit and trailing
How exits work: stop-loss, take-profit and trailing stops, how the keeper watches prices all day, how it avoids being fooled by a single wick, and what happens with gaps, weekends and closed markets.
An exit is a rule that closes (part of) a position when the price reaches a level. Agents set exits when they open a position or later. A separate always-on process, the keeper, watches the prices and fires the exits. It does not depend on the agent's decision schedule, so a stop is checked about every two seconds even if the agent only decides once an hour.
The three exit types#
| Exit | What it does | Example |
|---|---|---|
| Stop-loss | Closes the position if price moves against you by a set distance | Long NVDA at $100 with a 5% stop: closes at about $95 |
| Take-profit | Closes a share of the position when price reaches a profit target. Up to three levels, each with a fraction | Take 50% off at +6%, the other 50% at +12% |
| Trailing stop | A stop that follows the price in your favour and never moves back | A 4% trail on a long: the stop sits 4% under the highest price seen since it was set |
Exits are always reduce-only: they can only shrink a position, never open or flip one. When a stop fires, the remaining take-profits for that position are cancelled (one cancels the other), and exits left behind by a position that is already closed are cleaned up.
Who sets them, and who wins#
- The agent can set exits with an order or later with a
set_exitsaction, within your limits: the stop may be no wider than your widest stop, and a stop can be required (risk limits). - Exits you set are marked as owner exits. The agent may only tighten them (move a stop closer, a trail narrower), never loosen them. If you turn off "let the agent move its exits", it cannot change them at all.
- A trailing stop's distance counts against the widest stop too.
Why exits are not a single price tick#
Thin books produce wicks: a price spikes for a moment and returns. A stop that fires on one print would sell the bottom of a wick. The keeper therefore needs confirmation before it fires.
The confirmation rule#
- Reads. The keeper reads each trigger's price about every 2 seconds, with a random jitter of up to half a second, so no one can time a wick to a fixed schedule.
- Consecutive reads. The price must be beyond the level on at least 3 consecutive reads spanning at least 4 seconds.
- Median of five. The median of the last 5 reads must also be beyond the level. One extreme print cannot satisfy it.
- Thin or unmeasured prices. When the price source reports a wide uncertainty (wider than 50 basis points) or none, the rule is stricter: 6 consecutive reads over at least 30 seconds.
- Fresh re-check. After the keeper claims a trigger, it checks the newest price once more. If the price has recovered, the trigger goes back to waiting and its reads start over.
Take-profits use the same rule, with reads at or beyond the target. Emulated limit orders are the exception: they fire on a touch, because the order sent is a limit order that can only fill at the limit or better.
How trailing stops move#
A trailing stop remembers the best price since it was set (the high for a long, the low for a short). That best price only moves with the median of the last five reads, so a single pumped print cannot drag the stop upward and then trigger on the pullback.
What a fire looks like#
- The keeper places a reduce-only market order with a slippage bound of 100 basis points (1%).
- The order is recorded before it is sent and goes through the normal executor. The fill appears on the chart as an exit marker linked to the trigger.
- If an attempt fails (a venue error, a rejection), the trigger goes back to waiting and retries with exponential backoff, from 1 second up to 60 seconds. A stop-loss is never silently dropped. The attempt count and the last error are stored so you can see why an exit has not executed yet.
- A trigger stuck mid-fire for more than 2 minutes (for example because the keeper restarted) is recovered.
Gaps#
Prices can jump past your stop: an overnight gap, a reopening after a closed session, a fast candle. A stop is a trigger, not a guarantee of the price.
- If the confirmed price is through the stop by 100 basis points (1%) or more, the keeper fires a market order at the current price. It does not place a limit order at the stop level (which would never fill) and does not wait for the price to come back. The fill is worse than your level by the gap.
- For a gap-through, the slippage bound is wider, 500 basis points (5%), and is measured from the current price, not from the level. The decision log marks it as a gap-through.
- A crash guard flags a move of more than 20% against a position within 5 minutes so that it is paged and visible.
Weekends, after hours and stale prices#
- Stock perps trade around the clock on Phoenix, but liquidity is thinner outside US market hours, and from Friday evening to Sunday evening (US Eastern) the price comes from the exchange's own book rather than from the external stock price. The engine limits new risk then (markets).
- Closed or paused markets. The keeper skips the market, resets its reads, and looks again every 15 seconds. Corporate-action pauses (tokenized stocks) work the same way and rescale levels when the price basis changes.
- Stale prices. A price older than 10 seconds, or flagged stale by its source, is never used to fire an exit. This is also treated as a health problem of the price feed.
Exits on real money#
For real-money agents, exits are enforced by the keeper and not by native stop orders on the exchange. This is deliberate: it lets the confirmation rules above apply, and it lets the signing policy refuse any conditional-order flags. The consequence is that exits depend on the keeper and the price feed being up. If you must be sure of flat exposure, close the position or stop the agent.
Exits are never blocked by the platform kill switch, the pilot caps or the AI allowance. A downgrade or an exhausted allowance makes an agent slower, never unable to get out.
Practical tips#
- Put stops where the trade idea is wrong, not at an arbitrary percentage.
- On leveraged positions, keep the stop well inside the distance at which you would be liquidated (glossary: liquidation).
- Use more than one take-profit level to bank gains while keeping a trailing runner.
- Read the exit markers: the reason on a fired trigger tells you whether it was a normal fire or a gap-through.