Autonomous agents never sleep โ but they also can't watch every tick. Without a stop-loss, a single market event can erase weeks of compounded gains in minutes. Purple Flea's stop-loss API gives your agent the discipline to exit before disaster strikes, automatically, across 275 perpetual markets.
Markets move fast. Agents move faster. But without guardrails, speed becomes a liability.
Traditional traders monitor their screens. They feel the anxiety of a falling price and hit the exit button. AI trading agents have no such instinct. Once a position is open, they continue executing their strategy loop โ often waiting for a signal that may never come while the position bleeds out.
Markets crash in seconds. A BTC flash crash of 15% can occur in under 90 seconds. An agent running on a 5-minute candle cycle will miss the entire event and wake up to a margin call. This is not a hypothetical โ it has happened to dozens of live agent deployments.
Leverage amplifies everything. At 10x leverage, a 5% adverse move equals a 50% loss on margin. At 20x, you are liquidated. Stop-losses are not optional safety features โ they are the fundamental architecture of any serious agent trading system.
Unattended operation demands automation. If your agent runs overnight, over weekends, or in a headless cloud environment, you cannot intervene manually. The stop-loss must fire automatically, without human oversight, and must execute reliably even during high-volatility periods.
Purple Flea's stop-loss engine runs server-side, independent of your agent process. Even if your agent crashes, the stop order remains active and will execute when triggered. This is the only architecture that provides real protection for unattended autonomous traders.
Three mechanisms designed for different agent strategies and risk profiles.
Set a hard price floor. If the market trades at or below your stop price, the position exits immediately at market. Simple, predictable, and the most common choice for mean-reversion agents.
stop_type: "fixed"
stop_price: 42000.00
The stop price follows the position's peak value upward but never moves down. When price reverses by your specified percentage from peak, the position exits. Lets your agent ride winners while locking in gains.
stop_type: "trailing"
trail_percent: 5.0
Stop distance automatically widens in high-volatility markets and tightens in calm conditions using Average True Range (ATR). Prevents premature stop-outs during normal market noise while remaining protective during genuine moves.
stop_type: "atr"
atr_multiplier: 2.5
Add a trailing stop-loss to any position in three API calls.
Infrastructure built for the speed and scale that autonomous agents demand.
Four steps from zero to a protected position running 24/7.
Create an account at purpleflea.com. No KYC required for agents using testnet. API key is issued instantly. The SDK supports Python, JavaScript, and raw REST.
Deposit USDC to your agent's on-chain wallet address. Minimum deposit is $10. New agents can claim free funds via the Faucet to test without risk.
Use set_stop_loss() immediately after opening a position. The stop order is registered server-side and remains active regardless of your agent's uptime.
Purple Flea's execution engine monitors trigger conditions every 100ms. When your stop is triggered, the position exits at best available price and your agent receives a webhook notification with the outcome.
Beyond basic stops โ tools for sophisticated agent risk architectures.
Every position your agent opens should have a stop-loss. It takes three lines of code. Start now.