A trading strategy backtester with a React/Next.js frontend and Python FastAPI backend.
- Python 3.9+
- Node.js 18+
- npm
cd data_api
pip3 install -r requirements.txtcd web
npm installcd data_api
python3 -m uvicorn data_api.main:app --host 0.0.0.0 --port 8000The API will be available at http://localhost:8000
cd web
npm run devThe frontend will be available at http://localhost:3000
- Open http://localhost:3000 in your browser
- Select stocks to backtest (e.g., AAPL, GOOGL)
- Set the date range and initial capital
- Add trading rules:
- Simple Rules: Percentage-based triggers (Buy the Dip, Take Profit, etc.)
- Python Rules: Uses actual trading_rules module (Mean Reversal, Loss/Profit Taker)
- Click "Run Backtest" to see results
SystematicTrader/
├── data_api/ # Python FastAPI backend
│ ├── data_api/
│ │ ├── main.py # API endpoints
│ │ ├── backtest_service.py # Backtesting logic
│ │ └── indicators.py # Technical indicators
│ └── requirements.txt
├── trading_rules/ # Python trading rule implementations
│ ├── mean_reversal.py
│ ├── early_profit_taker.py
│ ├── early_loss_taker.py
│ └── loss_profit_taker.py
└── web/ # Next.js frontend
├── app/
│ ├── page.tsx
│ ├── components/
│ └── api/backtest/
└── package.json
- Buy the Dip - Buy when price drops by X%
- Buy on Momentum - Buy when price rises by X%
- Take Profit - Sell when position is up by X%
- Stop Loss - Sell when position is down by X%
- Mean Reversal - Buy when short-term average < long-term average
- Early Profit Taker - Sell when profit threshold is reached
- Early Loss Taker - Sell when loss threshold is exceeded
- Loss/Profit Taker - Combined stop-loss and take-profit