Overview
Strategy testing provides:- Backtesting: Simulate historical strategy performance
- Paper Trading: Execute intents without on-chain submission
- Pass/Fail Metrics: Automated strategy validation
- PnL Tracking: Profit and loss calculation per step
- Autonomous Decision Validation: Test rule-based agent logic
Backtesting is required for agents when
AGENT_REQUIRE_BACKTEST_PASS=true is set in production.Backtesting Workflow
Backtests evaluate a sequence of strategy steps and calculate success rates.Define Strategy Steps
1
Create step sequence
Each step represents an intent with a timestamp and optional PnL:
2
Run backtest
3
Evaluate results
Response:
Using the CLI
Using the SDK
PnL Calculation
Steps withsimulatedPnlLamports >= 0 are counted as passed:
Example Scenarios
Example Scenarios
Scenario 1: All ProfitableScenario 2: Mixed ResultsScenario 3: Below Threshold
Paper Trading Mode
Paper trading executes real intent logic without on-chain submission.Execute Paper Trade
List Paper Trades
Paper trades are stored in-memory with a 500-record cap per agent.
Autonomous Decision Engine
Agents can use backtesting to validate autonomous strategies before enabling them.Strategy Steps
Define repeatable actions with cooldowns and caps:Strategy Conditions
Use rules to trigger actions based on metrics:Available Metrics
Available Metrics
tick: Autonomous loop iteration countbalance_lamports: Current wallet SOL balanceknown_wallets_count: Number of registered wallets
Comparison Operators
Comparison Operators
gt: Greater thangte: Greater than or equallt: Less thanlte: Less than or equaleq: Equal
Template Variables
Use dynamic values in intents:{{tick}}{{walletId}}{{balanceLamports}}{{knownWallet0}},{{knownWallet1}}
Enforcing Backtest Requirements
Production Governance
Require passing backtests before agent activation:- Agents must have a passing backtest in their wallet history
- Autonomous agents cannot start without a passing backtest
- Failed backtests block agent execution
Checking Latest Backtest
Paper Trading for Agents
Set autonomous agents to paper trading mode:Per-Step Paper Mode
CLI Strategy Wizard
Interactive strategy builder:- Choose wallet
- Define strategy name
- Add steps (type, protocol, intent, PnL)
- Set minimum pass rate
- Run backtest
- Review results
Advanced Patterns
Monte Carlo Backtesting
Run multiple backtest iterations with randomized PnL:Walk-Forward Analysis
Backtest on rolling time windows:Next Steps
Multi-Agent Orchestration
Apply validated strategies to agent fleets
Escrow Program
Backtest escrow-based payment strategies