Skip to main content

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 the configure 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 call build().

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

  1. When profit reaches a level’s profit_pct, the stream sells sell_pct of the current position.
  2. If a level has trailing_stop_pct > 0, a trailing stop activates at that level instead of selling immediately.
  3. Levels are evaluated in order from lowest to highest profit_pct.
  4. The global target_profit_pct still 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

When liquidity_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

The breakeven_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

With breakeven_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 by trailing_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 an update_strategy message:
Using the SDK:
The new strategy takes effect immediately for all tracked positions. No positions are closed or reopened; the server simply re evaluates existing positions against the new thresholds.

Deadline Timeout

The deadline_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_pct must be >= 0.
  • stop_loss_pct must be >= 0.
  • trailing_stop_pct (if provided) must be >= 0.
  • deadline_timeout_sec must be >= 0.
  • At least one of these values must be > 0.
Violating these rules raises a 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.
Using the SDK:
The override applies only to the specified position. All other positions continue using the global strategy. To revert a position back to the global strategy, send another update_position_strategy with the current global strategy values. Per-position overrides are ephemeral and are not persisted across reconnections.