A high-performance quantitative research tool for simulating mean reversion trading strategies on historical equity data.
Built with Streamlit for an interactive UI and powered by vectorized backtesting logic for fast, efficient performance evaluation.
Adjust strategy inputs in real time:
- Buy Threshold (% below previous close)
- Take Profit (% target)
- Stop Loss (% risk control)
- Transaction Costs
All updates instantly reflect in performance metrics and charts.
Automatically calculates:
- Sharpe Ratio – Risk-adjusted return measurement
- Max Drawdown – Peak-to-trough capital decline
- Profit Factor – Gross profits ÷ Gross losses
- Total Return
- Win Rate
- Trade Count
- Equity Curve – Portfolio growth over time
- Underwater Chart – Visual drawdown analysis
- Trade signal overlays on price charts
All charts are powered by Plotly for smooth interactivity.
This application implements a simple daily mean reversion strategy:
- Monitors the previous day’s closing price.
- Buy when the current price drops a defined percentage below the previous close (oversold condition)
- Take Profit: Price rises by a defined percentage
- Stop Loss: Price drops to risk threshold
- Optional transaction cost adjustment
git clone https://github.com/pinxinfang/MeanReversionTester.git
cd MeanReversionTesterpip install streamlit pandas yfinance plotly numpyOr use a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
pip install -r requirements.txtstreamlit run backtester.pyThe application will open automatically in your browser.
- Fully vectorized performance calculations (no slow loops)
- Efficient pandas-based signal generation
- Real-time portfolio equity tracking
- Clean modular architecture for easy strategy expansion
MeanReversionTester/
│
├── backtester.py # Main Streamlit application
├── requirements.txt # Dependencies
└── README.md
- Multi-asset portfolio testing
- Walk-forward optimization
- Position sizing models
- Monte Carlo simulation
- Strategy comparison dashboard
This project is for educational and research purposes only. It does not constitute financial advice, investment recommendation, or trading guidance.
Trading involves risk. Past performance does not guarantee future results.