Vibe Coding #1 - Backtest Trading Strategies with Claude Code | Build Python CLI Tools for AI
Built an AI agent with Claude Code that runs backtesting experiments autonomously. Created CLI tools, YAML configs, and a Streamlit dashboard to visualize strategy performance across multiple stocks.
Featured clips
Result
Ran 100+ backtests across 7 stocks in minutes - would have taken hours manually.
The problem
- Testing trading strategies manually is tedious: run, record, change parameters, repeat
- Parameter combinations explode quickly (3 stocks × 5 strategies × multiple params = 100+ runs)
- Results end up scattered, hard to compare
The solution
Started from my LinkedIn Learning course materials as reference. The course covers backtesting strategies and optimizing parameters - the heatmap below shows how different parameter combinations affect returns.

The backtesting.py library provides an interactive dashboard showing equity curves, drawdowns, and trade markers for each strategy run.

Project setup
Claude Code scaffolded the entire project - CLI with Typer, modular strategy implementations, project-based execution. Each strategy lives in its own module, and a project manager coordinates running experiments across all combinations.

The key insight
YAML configs define the experiment matrix. You specify symbols, strategies, and parameter ranges - the system expands all combinations and runs them automatically:
# config.yaml
symbols: [AAPL, MSFT, GOOGL]
strategies:
sma:
fast_period: [10, 20]
slow_period: [50, 100]
rsi:
oversold: [30]
overbought: [70] This config generates 3 stocks × (4 SMA combos + 1 RSI combo) = 15 backtests.
Running experiments
Create a new project with target stocks:
uv run backtest project create portfolio --symbols AAPL,MSFT,GOOGL Run all strategy combinations across all stocks:
uv run backtest project run portfolio 
Launch the dashboard to visualize results:
uv run streamlit run frontend/app.py We tested this on the Magnificent 7 stocks. The Streamlit dashboard displays results as a matrix - which strategy performs best on which stock, with Sharpe ratio, max drawdown, and win rate.

Reference
Strategies
| Strategy | Parameters | Logic |
|---|---|---|
| SMA | fast_period, slow_period | Buy when fast crosses above slow |
| RSI | rsi_period, oversold, overbought | Buy when RSI < oversold |
| MACD | fast, slow, signal | Buy when MACD > signal |
| Bollinger | bb_period, bb_std | Buy at lower band |
| Breakout | entry_period, exit_period | Buy on N-day high |
Project structure
Resources
- LinkedIn Learning Course - reference materials we built upon
- backtesting.py - backtesting engine for running strategies
- yfinance - fetching historical stock data
- uv - Python package manager (fast, handles virtual envs)
- Typer - CLI framework for the
backtestcommand - Streamlit - dashboard for visualizing results