A full-stack web application for backtesting cryptocurrency trading strategies with real-time visualization and performance metrics.
- 🚀 Quick Start Presets: Pre-configured backtest scenarios for instant testing
- 📊 Real-time Visualization: Interactive equity curves and performance charts
- 📈 Multiple Strategies: Compare up to 3 strategies simultaneously
- 🎯 Comprehensive Metrics: Sharpe ratio, max drawdown, win rate, and more
- 💾 History Tracking: View and manage all your backtest runs
- ⚡ Async Execution: Non-blocking background processing for long-running backtests
- FastAPI: Modern Python web framework
- SQLAlchemy: SQL toolkit and ORM
- SQLite: Lightweight database for development
- AsyncIO: Asynchronous background workers
- React 18: UI library
- TypeScript: Type-safe JavaScript
- Vite: Fast build tool
- TailwindCSS: Utility-first CSS framework
- React Query: Data fetching and caching
- Recharts: Charting library
- React Router: Client-side routing
crypto/
├── backend/ # FastAPI backend
│ ├── app/
│ │ ├── main.py # FastAPI app entry
│ │ ├── api.py # API endpoints
│ │ ├── database.py # SQLAlchemy setup
│ │ ├── models.py # Database models
│ │ ├── services/ # Business logic
│ │ └── workers/ # Background jobs
│ ├── requirements.txt
│ └── backtest.db # SQLite database
│
├── frontend/ # React frontend
│ ├── src/
│ │ ├── lib/ # API client
│ │ ├── pages/ # Page components
│ │ ├── App.tsx # Main app
│ │ └── main.tsx # Entry point
│ └── package.json
│
└── [existing backtester modules]
- Python 3.10+
- Node.js 18+
- npm or yarn
-
Create virtual environment (if not already created):
python -m venv venv venv\Scripts\activate # Windows # or source venv/bin/activate # Linux/Mac
-
Install dependencies:
cd backend pip install -r requirements.txt -
Initialize database:
python init_db.py
-
Start backend server:
python -m uvicorn app.main:app --host 127.0.0.1 --port 8003 --reload
Backend will be available at: http://localhost:8003 API docs: http://localhost:8003/docs
-
Install dependencies:
cd frontend npm install -
Start development server:
npm run dev
Frontend will be available at: http://localhost:5173
From the repo root:
./stop.sh
./start.shstart.sh checks backend/.venv, runs backend/init_db.py, starts backend and frontend with systemd services (crypto-backend.service, crypto-frontend.service) when available, falls back to nohup (uvicorn/vite) when services are not present, and runs a quick health check on http://127.0.0.1:8000/api/health.
stop.sh stops those systemd services when available and falls back to stopping uvicorn/vite processes.
start.ps1 and stop.ps1 are kept only for legacy Windows workflows and are deprecated.
- Navigate to the Playground tab
- Choose from 3 pre-configured presets:
- BTC Swing (2 years, 4h): Compare 3 strategies with stop/take
- ETH Swing (2 years, 1d): Daily timeframe comparison
- BTC Trend (1 year, 1d): Single SMA Cross strategy
- Click "Run Backtest" to start execution
- Monitor progress in the History tab
- View results when status changes to "DONE"
- Go to History tab
- Find completed backtests (green "DONE" status)
- Click "View Results" to see:
- Equity curve comparison chart
- Performance metrics for each strategy
- Total return, max drawdown, Sharpe ratio
- Win rate and trade statistics
| Endpoint | Method | Description |
|---|---|---|
/api/health |
GET | Health check |
/api/presets |
GET | List preset configurations |
/api/backtest/run |
POST | Start single strategy backtest |
/api/backtest/compare |
POST | Start multi-strategy comparison |
/api/backtest/status/{run_id} |
GET | Get backtest status |
/api/backtest/result/{run_id} |
GET | Get backtest results |
/api/backtest/runs |
GET | List backtest history |
/api/backtest/runs/{run_id} |
DELETE | Delete backtest run |
cd backend
python -m uvicorn app.main:app --reloadcd frontend
npm run dev./backend/.venv/bin/python -m pytest -q backend/tests/integration
npm --prefix frontend run test:e2eBranch protection checklist for main:
docs/branch-protection.md
cd frontend
npm run build# Not needed for SQLite, but can be configured for Postgres
# SUPABASE_DB_URL=postgresql://user:pass@host:5432/dbVITE_API_URL=http://localhost:8003/apiPort already in use:
# Use a different port
python -m uvicorn app.main:app --port 8004Database locked:
# Delete and recreate database
rm backtest.db
python init_db.pyModule not found:
# Reinstall dependencies
rm -rf node_modules package-lock.json
npm installCORS errors:
- Ensure backend is running on port 8003
- Check
VITE_API_URLin frontend/.env
- Custom backtest form with parameter inputs
- Trade-by-trade analysis table
- Candlestick chart with trade markers
- Portfolio optimization
- Walk-forward analysis
- Export results to PDF/CSV
- User authentication
- Cloud deployment (Supabase/Vercel)
MIT
Alan Silva