This code provides a Flask API for simulating and plotting investment scenarios over time.
-
Simulation Endpoint:
/simulate
(POST)- Use this endpoint to simulate investments.
- Input JSON format:
{ "duration": 10, "initial_salary": 50000, "savings_rate": 20, "investments": [ { "name": "Investment 1", "rate": 5, "initial_amount": 10000, "allocation_percentage": 50 }, { "name": "Investment 2", "rate": 8, "initial_amount": 20000, "allocation_percentage": 50, "fees": 1.5 } ], "salary_changes": [ { "year": 5, "new_salary": 60000 } ] }
- Output JSON format:
[ ["Investment 1", 123456.78], ["Investment 2", 98765.43] ]
-
Plotting Endpoint:
/plot
(POST)- Use this endpoint to plot investment data.
- Input and output formats are similar to the simulation endpoint.
-
Clone the repository:
git clone https://github.com/ucclngit/InvestmentSimulator_web.git
-
Install dependencies (no requirement.txt yet):
pip install -r requirements.txt
-
Run the Flask server:
python app.py
__init__(duration, initial_salary, savings_rate, currency="โฌ")
: Initializes the simulator.change_salary(year, new_salary)
: Changes the salary at a given year.add_investment(name, rate, initial_amount, allocation_percentage, fees=0)
: Adds an investment.simulate()
: Simulates the evolution of all investments over time.data_investments()
: Saves the evolution of all investments over time.
Contributions are welcome! Please feel free to submit pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.