Click the badge above to run the simulator in your browser!
A comprehensive Python application featuring two distinct trading simulation engines: Exponential Growth and Baseline Harvest Engine. Perfect for analyzing different investment strategies and risk management approaches.
- Two Simulation Types: Choose between compound growth or harvest-based strategies
- Dynamic Start Date: Simulations automatically start from the current week's Monday
- Interactive CLI: Colorful, user-friendly command-line interface
- Parameter Persistence: Save and re-run previous simulations instantly
- Comprehensive Reporting: Weekly breakdowns, monthly summaries, and charts
- Professional Output: Text reports and matplotlib visualizations
- Extensible Architecture: Clean, modular design for easy enhancement
- Strategy: Pure compound interest growth
- Formula:
A = P(1 + r)^n - Use Case: Traditional investment growth modeling
- Risk Profile: High growth potential with compounding
- Strategy: Accumulation phase โ Distribution phase
- Phases: Build to cap โ Harvest excess profits
- Use Case: Risk-managed trading with profit extraction
- Risk Profile: Controlled growth with systematic withdrawals
For a detailed view of the application architecture, see architecture/architecture.md.
To regenerate the architecture diagram:
python architecture/generate_architecture.py- Prerequisites: Python 3.8+
- Virtual Environment (recommended):
python -m venv .venv # Windows: .venv\Scripts\Activate.ps1 # macOS/Linux: source .venv/bin/activate
- Install Package:
pip install -e .
start-simulatorpython -m simulator.mainclear-outputChoose option 3 from the main menu to instantly re-run your previous simulation with saved parameters.
The simulation automatically determines its start date based on the current day:
- Weekdays (Mon-Fri): Starts from the most recent Monday
- Weekends (Sat-Sun): Starts from the upcoming Monday
Example: If today is Sunday 1/11, simulation starts Monday 1/12. If today is Wednesday 1/08, simulation starts Monday 1/05.
initial_pot: Starting investment amount (default: $1,000)total_weeks: Simulation duration in weeks (default: 52)
weekly_return_rate: Annual return rate as decimal (default: 0.25 = 25%)
weekly_return_rate: Weekly return rate (default: 0.25 = 25%)engine_cap: Maximum pot size before distribution (default: $10,000)growth_vault_pct: Vault allocation during growth phase (default: 50%)harvest_vault_pct: Vault allocation during harvest phase (default: 25%)
Strategy Overview:
- Continuous compound growth
- No profit extraction during simulation
- Focus on long-term capital appreciation
Example Parameters:
- Initial Amount: $1,000
- Weekly Return: 25%
- Duration: 52 weeks
Expected Outcome:
- Final Amount: ~$1,000 ร (1.25)^52
- Growth Focus: Pure capital accumulation
Strategy Overview:
- Phase 1 (Accumulation): Reinvest all profits until reaching engine cap
- Phase 2 (Distribution): Lock pot at cap, systematically withdraw excess profits
- Risk Management: No withdrawals during deficit periods
Key Rules:
- Starting Point: Begin with initial investment
- Growth Phase: 100% reinvestment until engine cap reached
- Harvest Phase: Excess profits split between vault and spending
- Deficit Protection: No distributions if pot falls below cap
- 50/50 Split: Withdrawals divided equally between savings and spending
Example Parameters:
- Initial Amount: $220
- Weekly Return: 25%
- Engine Cap: $10,000
- Duration: 52 weeks
Typical Results:
- Engine Hit: Week 18 (when pot reaches $10,000)
- Final Pot: $10,000 (locked)
- Total Vault: $43,606.23 (accumulated savings)
- Total Spend: $43,606.23 (available for spending)
Each simulation generates:
- Weekly breakdown with dates
- Monthly summary tables
- Final statistics
- Parameter summary
- Time series visualization
- Multiple data streams (pot, vault, spend)
- Professional matplotlib styling
output/
โโโ run_exponential_2026-01-10_14-30-45/
โโโ simulation.txt
โโโ plot.png
numpy: Numerical computationsmatplotlib: Chart generationcolorama: Cross-platform terminal colorspytest: Testing framework
- CLI Layer: User interface and input handling
- Simulation Engine: Core algorithms for both strategies
- Data Processing: Report generation and time series analysis
- File Management: Output organization and parameter persistence
trading_simulator/
โโโ src/simulator/
โ โโโ main.py # CLI interface and orchestration
โ โโโ simulation.py # Core simulation algorithms
โโโ tests/
โ โโโ test_simulation.py # Comprehensive test suite
โโโ architecture/
โ โโโ generate_architecture.py
โ โโโ architecture.md
โโโ output/ # Generated reports and charts
โโโ demo/ # Demo files and media
โโโ pyproject.toml # Project configuration
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is open source. See LICENSE file for details.
Built with โค๏ธ for educational and analytical purposes
