Trading Simulator
What Is This Project?
This is a demo project built to showcase a realistic, testable, and modular trading simulator written in Python. It's designed to help users practice trading strategies in a controlled environment with real historical stock data.
Try out the simulator
Click here (opens in new tab) to open the simulator and test your trading strategies on real (historical) data.
Tech Stack & Design
- Python: Used for both the frontend and backend.
- Streamlit: Provides the interactive user interface for simulating trades and displaying indicators.
- PyTest: Used to test core application logic in isolation with mock data, ensuring functionality and maintainability.
- Poetry: Handles package management and virtual environments for reproducible builds.
- Pre-commit: Ensuring all packages used in the local poetry environment are synced with the packages in the docker build requirements.txt file.
- Docker: Containers the application for consistent local development and deployment.
- Heroku: Hosts the deployed application for public access without requiring local setup.
- HTML/CSS: Used for creating static pages (like this one) outside the Streamlit UI.
- Domain Management: Custom domain and subdomains (e.g.,
simulator.simulatetrading.com
) were registered and configured for live hosting. - Git/GitHub: Used for version control and hosting the website via GitHub Pages/GitHub pages.
- GitHub Actions: Used as part of the CI/CD pipeline for automated testing and deployment, ensuring code quality and smooth integration before merging changes.
Debugging & Improvements
-
Memory leak: During development, I encountered a memory leak issue caused by an interaction between Streamlit and the
lightweight_charts
package. Therefore, thelightweight_charts
package has been removed from the app. - Docker build time: I also faced issues with build times for the Docker application. To optimize this, I ensured that frequently changing pieces of code were placed later in the Dockerfile, while static dependencies were placed earlier. This significantly improved build speed by leveraging Docker's layer caching.
What's Next?
While the core functionality is stable, Iām actively planning new features and improvements. For a full list, see the project roadmap.