This project fetches Consumer Price Index (CPI) data from the FRED API, processes it, and compares it to stock market data obtained from Yahoo Finance. The script then utilizes feature engineering to output a Statistical Summary and Perform Regression Analysis on your downloaded csv stock data. Then plots key metrics for better analysis comprehension.
Install the required Python packages:
pip install -r requirements.txt
Set up your API key in a config.ini
file:
[API]
FRED_API_KEY = your_fred_api_key_here
Or set it as an environment variable:
export FRED_API_KEY=your_fred_api_key_here
Run the script with:
python ok.py
The script generates multiple plots:
- CPI Data with Different Fill Methods (Original, Backward Fill, Forward Fill, Linear Interpolation)
- Realized Volatility of Inflation & Stock Data
- Stock Returns Distribution
- Stock vs. Market Regression Analysis
If you encounter errors:
- Ensure your
FRED_API_KEY
is correct and active. - Check if the FRED API is online.
- Verify that Yahoo Finance (
yfinance
) is returning data correctly. - Inspect missing values and ensure correct data preprocessing.
This project is open-source and free to use.
📩 Need Help? Feel free to reach out or open an issue!