spin docs
Strategies

Exits

Sell rules, how much each one sells, the order the bot checks them in, and AI sell checks.

Exits are the rules that sell an open position. Each exit is a Sell block beside the Buy block. A strategy can have up to 10 exits.

Add a sell rule

Open the menu

Select the "+" under the sell blocks (Add an exit).

Choose the kind

Choose Sell rule for a rule on the market, or AI sell check to ask your AI model.

Set the rule

The new block opens. Set its fields, then select Done.

Each exit has these fields:

FieldJSONWhat it is
Exit namereasonA short name, 1 to 40 characters. It shows in the activity and in backtests as the reason a position sold.
Sellsell_pctThe percent of what is still held, from 1 to 100. The default is 100.
Sell whenifThe condition. Read conditions.

A sell rule can read the token's values, the position's values and the bot's values. It cannot read the values of the trade that started the entry. The position values are:

The position (exits only)Meaning
position.multiplePrice now divided by the price at entry (before costs).
position.peak_multipleHighest price since entry divided by the price at entry.
position.drawdown_pctPercent below the highest price since entry (for trailing stops).
position.pnl_pctEstimated return if sold now, after the venue fee and tax, ignoring price impact.
position.age_sSeconds since the position opened.

Sell percent

Sell is a percent of what the position still holds, not of what it bought. Example: the launch momentum preset sells 50% at 2 times the entry price. A later exit at 100% then sells the rest.

The order of the exits

The bot checks the exits in order, on every price change of the token and every second. Each exit sells at most once for each position. A position has one sell at a time. When one exit sells, the next exits wait for the next check.

If a sell fails, the exit can sell again. The bot tries it again after 30 seconds.

A Pons curve that has sold out cannot take a sell. The bot then waits until the token trades in its pool, as any holder would.

Example: the exits of the launch momentum preset, in order.

{
  "schema": 1,
  "name": "Launch momentum",
  "entry": {
    "trigger": { "on": "launch" },
    "wait_s": 60,
    "confirm": { ">=": [{ "f": "token.buyers", "args": [60] }, 30] },
    "buy_eth": 0.02
  },
  "exits": [
    { "if": { ">=": [{ "f": "position.multiple" }, 2] }, "sell_pct": 50, "reason": "half_at_2x" },
    {
      "if": {
        "and": [
          { ">=": [{ "f": "position.peak_multiple" }, 1.5] },
          { ">=": [{ "f": "position.drawdown_pct" }, 30] }
        ]
      },
      "reason": "trailing_stop"
    },
    { "if": { "<=": [{ "f": "position.pnl_pct" }, -50] }, "reason": "stop_loss" },
    { "if": { ">=": [{ "f": "position.age_s" }, 1800] }, "reason": "time" }
  ]
}
  1. half_at_2x sells half when the price is 2 times the entry price.
  2. trailing_stop sells what is still held when the price has been at least 1.5 times the entry, then falls 30% from its highest point.
  3. stop_loss sells when the position's estimated return is -50% or less.
  4. time sells after 30 minutes.

This example leaves out two checks of the preset, to keep it short. Read presets for the full preset.

Slippage on sells

A sell reverts if it would get much less ETH than the market state suggests. Set this in Exit slippage in the Limits block (limits.exit_slippage_pct, 25% by default). Read limits.

AI sell checks

An AI sell check asks your own AI model whether to sell each position. Choose AI sell check in the "+" menu, or turn on Ask the AI before selling in a sell rule. It needs an Epic Spinner.

An AI sell check has:

  • Ask the AI when: a condition. The bot asks only while it holds. No condition: the bot asks all the time, within the limits below.
  • The AI steps: up to 3, with their prompts and answer fields. Prompts can also use position values, such as {{position.multiple}}.
  • Answer within: how long the steps have to answer, in seconds (5 to 120; 60 by default).
  • Ask at most every: how often the bot asks for each position, in minutes. In JSON, ai.every_s is in seconds, from 60 to 86400, and 900 (15 minutes) by default.
  • Then sell if: the condition on the answers. The bot sells only when it holds.

A new AI sell check starts with one step, review, whose answer is sell or hold, and sells when the answer is sell:

{
  "ai": {
    "every_s": 900,
    "steps": [
      {
        "id": "review",
        "prompt": "Should a small trading bot sell its position in {{token.address}} now? It is at {{position.multiple}} times its entry price.",
        "output": { "action": ["sell", "hold"] }
      }
    ]
  },
  "confirm": { "==": [{ "f": "ai.review.action" }, "sell"] },
  "reason": "ai_exit"
}

The editor starts the prompt empty. Write your own prompt. Each run is calls on your own AI key, and counts toward AI runs an hour at most. No answer, or a late answer, never sells. Read AI steps.

Never sells

A strategy with no exits shows one block: Never sells. "No exits: it buys and holds. Add an exit to sell." The bot then only buys and holds. This is how the DCA presets work: each buy adds to one position, and the bot never sells it.

The tokens stay in the Spinner's wallet. Read the Spinner wallet.

Open positions keep their rules

A position keeps the exits and the exit slippage it was opened with. When you save a new version, open positions still sell by their old exits. Only new positions use the new exits. Read versions.

On this page