- Home
- Skills
- Trading & Investing
- easy backtest
Works with the AI Agents you already use
easy backtest
by Kavin Ravi
Testing trading ideas shouldn't require complex boilerplate or heavy infrastructure.
Free
easy backtest
Example session with this skill installed
Backtest a 50/200 SMA crossover strategy for AAPL from 2020 to 2023. Assume a 2 basis point trading cost and show me how it compares to just holding the stock.
- Read your context and instructions
- Compiled the easy backtest
- Generated the data export
I have executed the backtest for AAPL using the SMA crossover strategy (50-day fast, 200-day slow) with a 2 bps trading cost.
AAPL SMA Crossover Backtest Results (2020-01-02 to 2023-12-29)
| Metric | SMA Crossover (50/200) | Buy & Hold (Benchmark) |
|---|---|---|
| Total Return | 104.22% | 158.45% |
| CAGR | 19.55% | 26.82% |
| Annual Volatility | 22.10% | 34.50% |
| Sharpe Ratio | 0.88 | 0.78 |
| Max Drawdown | -18.45% | -31.22% |
| Trade Count | 6 | 2 |
| Win Rate | 54.20% | N/A |
Backtest Configuration:
- Ticker: AAPL
- Interval: 1d
- Initial Cash: $10,000
- Trading Cost: 2 bps per trade
- Date Range: 2020-01-02 to 2023-12-29 (986 bars)
The SMA 50/200 strategy significantly underperformed the buy-and-hold benchmark in total return. However, it achieved a higher Sharpe ratio and a much lower maximum drawdown (-18.45% vs -31.22%), suggesting better risk-adjusted returns and lower volatility during this period. The win rate of 54.20% represents the percentage of bars where the strategy held a position that yielded a positive return.
Next steps
- Run a
sma_suitesweep to see if different windows (e.g., 20/50 or 10/30) capture the trend more effectively. - Export the full bar-by-bar data to
bars.csvto inspect specific trade entry and exit points. - Increase the
--cost-bpsto 5 to see how higher friction impacts the crossover performance.
Disclaimer: These are historical simulations based on simplified assumptions and do not predict future returns.
bars.csv
CSV · data export
Example file from a real run - the skill writes it into your workspace.
Connects securely to your tools. The creator never sees your data.
About this skill
Testing trading ideas shouldn't require complex boilerplate or heavy infrastructure. This skill provides a streamlined Python environment for backtesting simple moving average (SMA) strategies and buy-and-hold baselines with realistic cost assumptions.
What it does
- Multi-strategy testing Executes buy-and-hold, SMA crossover, or multi-pair SMA sweeps.
- Metric calculation Computes CAGR, Sharpe ratio, volatility, and max drawdown.
- Benchmarking Automatically compares strategy performance against a no-cost buy-and-hold baseline.
- Cost modeling Applies basis-point trading costs to every position change to reflect real-world friction.
- Data handling Fetches market data via yfinance or processes local CSV files.
- Visualization Generates equity curve charts and exports bar-by-bar results for further analysis.
How it works
- Configure inputs Define the ticker, date range, strategy type, and SMA windows.
- Set costs Specify the trading cost in basis points to ensure the results aren't artificially inflated.
- Execute script The agent runs the
easy_backtest.pyscript with your parameters. - Analyze JSON The agent parses the structured JSON output and compares the strategy to the benchmark.
Frameworks & tools
The skill relies on a self-contained Python 3.10+ environment using pandas and numpy for calculations, yfinance for data retrieval, and matplotlib for plotting.
Why this beats prompting it yourself
LLMs frequently hallucinate financial calculations or ignore the compounding effect of trading costs. This skill uses a fixed, auditable script to ensure every return, drawdown, and Sharpe ratio is mathematically sound and consistent across runs.
Use cases
- Compare 20/50 SMA vs 50/200 SMA performance on SPY over a decade.
- Determine if a trend-following rule outperforms buy-and-hold after 5bps costs.
- Validate custom price data from a CSV against standard moving average rules.
- Stress-test a strategy's volatility and max drawdown during specific market regimes.
Known limitations
Supports only long-only positions without leverage or shorting. Limited to single-asset backtests and SMA-based indicators. Trading costs are flat fees and do not account for slippage or taxes.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 10 days ago
- Free with an Agensi account
- Software
Python
Permissions
What's inside
Frequently Asked Questions
New in Trading & Investing
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Trading & Investing.