Projet n°7: DA-Python OpenClassrooms (Develop a user interface for a Python web application).
The program calculates the best combination of stocks based on their profits using two approaches: bruteforce and dynamic programming (knapsack algorithm).
- Python 3.11 or higher
- Git
- Clone the repository:
git clone https://github.com/Majestic-MJ12/OC_P7_DA-Python.git
- Navigate to the project directory:
cd OC_P7_DA-Python
- Set up a virtual environment:
python -m venv env
- Activate the virtual environment:
- On Windows:
env\scripts\activate
- On MacOS and Linux:
source env/bin/activate
- On Windows:
- Install the required packages:
pip install -r requirements.txt
To run the bruteforce approach, use the following command:
python bruteforce.py
By default, the investment amount is set to 500€. However, it is possible to enter a custom amount as follows:
python bruteforce.py 400
Note: The bruteforce approach only processes data from the "shares.csv" file, which contains 20 stocks. Datasets 1 and 2 would result in an extremely long execution time (What is solved with the optimized.py).
To run the dynamic programming approach, use the following command:
python optimized.py dataset1
Replace "dataset1" with the name of the file you want to process, without the file path or extension. By default, the investment amount is set to 500€. However, it is possible to enter a custom amount as follows:
python optimized.py dataset2 600
It is also possible to process the test file (20 stocks), with or without a custom amount:
python optimized.py shares
python optimized.py shares 400
Note: During data processing, the program displays a progress bar (thanks to "tqdm").
Here you'll find the slides that explain the optimised solution (including the bruteforce):
- Python
- Git
GNU AFFERO GENERAL PUBLIC LICENSE