A Python project for updating stock data using Yahoo Finance API and storing it in an SQLite database.
This project is designed to fetch stock data from Yahoo Finance using stock tickers and intervals specified in a JSON file. The retrieved data is then stored in an SQLite database for further analysis and processing.
The project consists of the following files:
- main.py: The main script that orchestrates the entire processing flow.
- db_funcs.py: Module containing functions for database operations.
Make sure you have the following installed:
- Python 3.x
- Required Python packages (install using
pip install -r requirements.txt
)
-
Clone the repository to your local machine:
git clone https://github.com/roruizf/yahoo_finance-stock-db.git
-
Navigate to the project directory:
cd yahoo_finance_stock_db
-
Modify the
stocks_intervals.json
file to include the desired stock tickers and intervals. -
Run the project using the following command:
python3 main.py
stocks_intervals.json
: JSON file containing stock data configurations.yahoo_finance_stocks.db
: SQLite database file where stock data is stored.
The project uses logging to capture information and errors during execution. Log messages are configured to be displayed at the INFO level.
The main processing flow includes a retry mechanism to handle temporary failures, such as network issues or API restrictions. The script will attempt to fetch and update stock data with a specified number of retries and intervals between attempts.
- Ensure that the requirements.txt file is used to install the required Python packages.
- Feel free to customize the project to suit your specific needs or integrate it into a larger financial data processing pipeline.