StrategyConfigMsg Schema
| Field | Type | Required | Description |
|---|---|---|---|
target_profit_pct | number | Yes | Take profit threshold as a percentage (e.g., 5 = 5%). |
stop_loss_pct | number | Yes | Stop loss threshold as a percentage (e.g., 1.5 = 1.5%). |
trailing_stop_pct | number | No | Trailing stop percentage from the peak. Activates only after the position is in profit. |
sell_on_graduation | boolean | No | If true, auto sells when a bonding curve token graduates to an AMM pool. |
take_profit_levels | TakeProfitLevelMsg[] | No | Exit ladder: sell partial amounts at multiple profit thresholds. Each level has profit_pct (trigger), sell_pct (portion to sell), and trailing_stop_pct (optional trailing stop for that level). |
liquidity_guard | boolean | No | When enabled, the stream checks available pool liquidity before generating an exit signal. Prevents exits into thin liquidity. Default: false. |
breakeven_trail_pct | number | No | A trailing stop that activates once the position breaks even, trailing from the breakeven point rather than the peak. |
target_profit_pct, stop_loss_pct, trailing_stop_pct, or deadline_timeout_sec (on the configure message) must be greater than zero.
TakeProfitLevelMsg Schema
| Field | Type | Required | Description |
|---|---|---|---|
profit_pct | number | Yes | Profit percentage at which this level triggers (e.g., 20 = 20%). |
sell_pct | number | Yes | Percentage of the position to sell at this level (e.g., 50 = sell 50%). |
trailing_stop_pct | number | No | Optional trailing stop for this level. If set, instead of selling immediately at profit_pct, a trailing stop activates at this level. Default: 0 (sell immediately). |
Setting Strategy at Connection Time
Strategy is provided in theconfigure message when you first connect:
Using StrategyConfigBuilder
All 4 SDKs provide a fluent builder for strategy configuration. The builder validates that at least one exit condition is set when you callbuild().
Exit Ladder (Take Profit Levels)
An exit ladder lets you take partial profits at multiple thresholds instead of exiting your entire position at a single price. Each level specifies a profit target and the percentage of the remaining position to sell.How it works
- When profit reaches a level’s
profit_pct, the stream sellssell_pctof the current position. - If a level has
trailing_stop_pct > 0, a trailing stop activates at that level instead of selling immediately. - Levels are evaluated in order from lowest to highest
profit_pct. - The global
target_profit_pctstill applies as a hard cap; if reached before all levels fire, the remaining position is sold.
Example
With this exit ladder and an entry of 1 SOL:- At 20% profit (position worth 1.2 SOL): sell 25% immediately.
- At 50% profit (position worth 1.5 SOL): activate a 3% trailing stop on 50% of the remaining position.
- At 100% profit (position worth 2 SOL): activate a 5% trailing stop on the remaining position.
Liquidity Guard
Whenliquidity_guard is enabled, the stream checks pool liquidity before generating an exit signal. If the pool cannot absorb the sell at a reasonable slippage, the signal is deferred until liquidity improves or a timeout forces the exit.
This is useful for large positions in thin pools where an immediate sell would result in excessive slippage.
Breakeven Trail
Thebreakeven_trail_pct field enables a trailing stop that activates once a position breaks even (profit >= 0), trailing from the breakeven point rather than the peak.
Unlike the standard trailing_stop_pct which trails from the highest observed profit, the breakeven trail protects you from giving back all gains on a position that briefly went profitable.
Example
Withbreakeven_trail_pct: 2 and an entry of 1 SOL:
| Time | Profit (%) | Breakeven Trail Active | Trigger |
|---|---|---|---|
| t=0 | -5 | No (not at breakeven) | — |
| t=1 | 0 | Yes (at breakeven) | — |
| t=2 | 3 | Yes | No trigger (profit > 0) |
| t=3 | -1 | Yes | No trigger (drop < 2% from breakeven) |
| t=4 | -2.5 | Yes | Triggered (drop >= 2% from breakeven) |
trailing_stop_pct to protect both the breakeven point and the profit peak.
Trailing Stop Explained
The trailing stop tracks the highest profit observed since the position opened. When profit drops from that peak bytrailing_stop_pct, an exit signal fires.
Numerical Example
| Time | Profit (%) | Peak (%) | Drop from Peak (%) | Trailing Stop (5%) |
|---|---|---|---|---|
| t=0 | 0 | 0 | 0 | Not active |
| t=1 | 3 | 3 | 0 | Not active |
| t=2 | 8 | 8 | 0 | Active, no trigger |
| t=3 | 6 | 8 | 2 | Active, no trigger |
| t=4 | 4 | 8 | 4 | Active, no trigger |
| t=5 | 2.5 | 8 | 5.5 | Triggered (drop >= 5%) |
Updating Strategy Mid Session
You can change the strategy at any time without reconnecting by sending anupdate_strategy message:
Deadline Timeout
Thedeadline_timeout_sec is set on the configure message (not on the strategy object itself). It defines the maximum time in seconds to hold a position before requesting an exit signal, regardless of profit or loss.
Setting deadline_timeout_sec: 60 means the Exit Intelligence Stream will attempt to exit any position held for more than 60 seconds.
When using StreamSession, the deadline timer runs client side and automatically calls requestExitSignal when it fires. If you are using StreamClient directly, you must implement deadline logic yourself.
Validation Rules
target_profit_pctmust be >= 0.stop_loss_pctmust be >= 0.trailing_stop_pct(if provided) must be >= 0.deadline_timeout_secmust be >= 0.- At least one of these values must be > 0.
StreamClientError with kind "protocol".
Per-Position Strategy Override
You can override the global strategy for individual positions without affecting other tracked positions. This is useful when you want different exit rules for specific tokens.update_position_strategy with the current global strategy values.
Per-position overrides are ephemeral and are not persisted across reconnections.
