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.

January 21, 2026 16:00 CET
pythonai-agentsalgorithmic-tradingbacktestingllm

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.

Strategy optimization heatmap from the course

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

backtesting.py interactive dashboard

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.

Building the Streamlit dashboard with Claude Code

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

Simulation results after running backtests

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.

Streamlit dashboard showing strategy performance

Reference

Strategies

StrategyParametersLogic
SMAfast_period, slow_periodBuy when fast crosses above slow
RSIrsi_period, oversold, overboughtBuy when RSI < oversold
MACDfast, slow, signalBuy when MACD > signal
Bollingerbb_period, bb_stdBuy at lower band
Breakoutentry_period, exit_periodBuy on N-day high

Project structure

backend
cli.pyTyper CLI
strategiesSMA, RSI, MACD, Bollinger, Breakout
runnerBacktest execution
projectProject management
frontend
app.pyStreamlit dashboard
data/projects/{name}
config.yamlExperiment definition
summary.yamlAggregated results
results/{run_id}Per-run outputs

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 backtest command
  • Streamlit - dashboard for visualizing results

Subscribe to our newsletter

Get weekly insights on data, automation, and AI.

© 2026 Datons. All rights reserved.