This project provides tools for simulating stock investments using historical data. It features a Python-based environment for fetching stock data, simulating investments, and visualizing investment outcomes.
- Data extraction from Yahoo Finance API.
- Simulation of stock investments based on historical data.
- Graphical representation of investment performance.
- Ability to process a list of stock tickers from a JSON file.
- Python 3.8 or higher
- Pip (Python package manager)
It's recommended to use a virtual environment to avoid conflicts with other Python projects or system-wide packages. To set up a virtual environment, navigate to the project's root directory and run:
python -m venv venvTo activate the virtual environment:
- On Windows:
.\venv\Scripts\activate- On macOS and Linux:
source venv/bin/activateWith the virtual environment activated, install the required packages using:
pip install -r requirements.txtBefore starting to use the project, make sure that the paths within src/settings/config.py are created
The data_processor.py script is used to fetch and save historical stock data. The stock tickers are read from a JSON file named stocks.json.
Create a stocks.json file in the project root with the following format:
{
"data": [
"AAPL",
"MSFT",
"GOOGL",
...
]
}Run the data_processor.py script:
python data_processor.pyUse main.py to simulate investments based on the fetched data.
-
Edit
main.pyto specify the stock ticker, purchase date, and sale date. -
Run the script:
python main.pyThis project is open-sourced and available to everyone under the MIT License.