StrategyConfigMsg Schema
At least one of
target_profit_pct, stop_loss_pct, trailing_stop_pct, or deadline_timeout_sec (on the configure message) must be greater than zero.
TakeProfitLevelMsg Schema
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:
Combine with a standard
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
The trailing stop only activates once the position is in profit. If the position goes negative before ever being in profit, the stop loss triggers instead.
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.
