# easy backtest

> One self-contained Python script for simple, honest stock backtests. Your agent runs buy and hold, an SMA crossover, or a sweep of SMA pairs, then reports the measured results next to buy and hold with trading costs and the method's limits stated.

easy backtest is a free AI agent skill on Agensi by Kavin Ravi, in Trading & Investing. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Kavin Ravi](https://www.agensi.io/creators/kavin-ravi)
- Category: [Trading & Investing](https://www.agensi.io/skills/trading-investing)
- Version: 1.0
- Last updated: 2026-11-25
- Security: scan passed (2026-11-25); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/easy-backtest
- Tags: backtesting, trading, finance, python, moving-average

## 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
1. **Configure inputs** Define the ticker, date range, strategy type, and SMA windows.
2. **Set costs** Specify the trading cost in basis points to ensure the results aren't artificially inflated.
3. **Execute script** The agent runs the `easy_backtest.py` script with your parameters.
4. **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.

## Requires

- Python

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the easy backtest skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### How does this skill provide more accurate results than just asking an AI to backtest a strategy?

The skill provides a specialized Python environment that executes a fixed, auditable backtesting script, preventing the mathematical hallucinations and cost-modeling errors common when asking LLMs to calculate returns manually.

### Can I use my own custom price data instead of relying on Yahoo Finance?

Yes, while the skill defaults to fetching data via yfinance, you can provide your own local CSV files to test proprietary data or assets not listed on major exchanges.

### Does 'easy backtest' support shorting or leveraged trading strategies?

This skill is designed for single-asset, long-only SMA strategies; it currently does not support short selling, margin trading, or multi-asset portfolio rebalancing.

### How does the skill account for trading fees and slippage?

The skill applies a configurable basis-point fee to every trade, ensuring that the performance metrics reflect the real-world impact of commissions and exchange fees rather than 'perfect' theoretical returns.

### What is included in the 'easy backtest' skill package?

You receive the production-ready Python backtesting environment, the core execution script, and pre-configured templates for SMA crossovers and buy-and-hold benchmarking.

### Which AI agents or platforms are compatible with this skill?

The skill is compatible with any AI agent platform that supports Python 3.10 execution environments and has access to standard libraries like pandas and matplotlib.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
