A professional-grade, web-based simulation tool that allows users to backtest algorithmic trading strategies using historical market data. Built with Python and Streamlit, this application bridges the gap between complex financial concepts and accessible user experimentation without financial risk.
This project was developed to demonstrate how algorithmic trading strategies can be visualized and tested against historical data. It focuses on the Golden Cross strategy combined with RSI (Relative Strength Index) indicators and robust risk management controls (Stop Loss and Take Profit).
The simulator allows users—even those with no prior trading experience—to understand how technical indicators interact to generate buy and sell signals.
The Problem: Algorithmic trading often feels like a "black box" to beginners. Understanding how moving averages, momentum indicators, and risk management settings affect long-term profitability is difficult without writing complex code or risking real capital.
The Solution: A beautifully designed, interactive web application that:
- Democratizes Access: Provides an easy-to-use interface for complex calculations.
- Visualizes Logic: Shows exactly where buy and sell signals occur on the price chart.
- Enforces Risk Management: Simulates real-world constraints like Position Sizing, Stop Losses, and Take Profits.
- Dynamic Strategy Customization: Adjust Short/Long SMA windows and RSI thresholds in real-time.
- Risk Management Simulation: Configure Position Sizing, Stop Loss %, and Take Profit % to test risk-adjusted returns.
- Interactive Visualization: Plot buy/sell signals directly on price charts using Matplotlib.
- Detailed Performance Metrics: Instant calculation of Strategy Return vs. Buy & Hold Return.
- Trade Log Transparency: Full table view of every simulated trade execution.
- Frontend: Streamlit (Python-based reactive UI)
- Data Source:
yfinance(Yahoo Finance API) - Data Processing: Pandas (Time-series analysis)
- Visualization: Matplotlib
- Language: Python 3.9+
| Strategy Inputs | Result Visualization |
|---|---|
![]() |
![]() |
No sensitive environment variables are required for this project as it uses the public Yahoo Finance API.
To run this project locally, follow these steps:
-
Clone the repository
git clone https://github.com/kritgarg/Stock-Strategy-Simulator.git cd Stock-Strategy-Simulator -
Create a virtual environment (optional but recommended)
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Run the application
streamlit run app.py
Stock-Strategy-Simulator/
├── app.py # Main application entry point
├── requirements.txt # Python dependencies
├── README.md # Project documentation
├── .gitignore # Git ignore rules
└── docs/ # Documentation assets (images, guides)
This application is for educational purposes only. The results generated are simulations based on historical data and do not guarantee future performance. This tool does not provide financial advice.
- SMA (Simple Moving Average): Calculates the average price over a specific window to smooth out price data.
- RSI (Relative Strength Index): Measures the speed and change of price movements.
- Signal Generation:
- Buy: Short-term trend crosses above Long-term trend AND RSI indicates asset is not overbought.
- Sell: Short-term trend crosses below Long-term trend OR RSI indicates asset is overbought.
- Add support for multiple stock tickers comparison.
- Implement Exponential Moving Averages (EMA).
- Add "Sharpe Ratio" and "Max Drawdown" to metrics.
- Export trade logs to CSV.
Krit Garg
Built with ❤️ using Streamlit and Python.

