This application is a comprehensive stock analysis and forecasting tool. It allows users to visualize historical data, forecast future stock prices using multiple advanced models, and interact with data through a sleek graphical user interface (GUI).
- Real-Time Stock Price Fetching: Fetches the latest stock prices using Yahoo Finance.
- Historical Data Visualization: Displays historical stock data for the last 10 years.
- Forecasting Models:
- ARIMA (Auto-Regressive Integrated Moving Average)
- ETS (Exponential Smoothing)
- Random Forest
- LSTM (Long Short-Term Memory)
- Interactive Graphs:
- Displays model forecasts for the next 12 months.
- Hover functionality to show predicted price and date.
- Modern GUI:
- User-friendly interface..
- Interactive graphs with zoom and pan capabilities.
- Multi-Model Comparison:
- Compare forecasts from different models on the same graph.
- Data Fetching:
- Fetches historical stock data from Yahoo Finance for analysis.
- Updates real-time prices using intraday data.
- Data Preprocessing:
- Cleans and prepares data for models.
- Handles missing data, converts formats, and ensures compatibility.
- Forecast Generation:
- Each model generates predictions for the next 12 months.
- Predictions start from the current date.
- Visualization:
- Forecasts are displayed on a graph.
- Users can view specific predictions by hovering over points on the graph.
Function: fetch_stock_data(stock_symbol, start_date, end_date)
- Fetches historical stock data from Yahoo Finance.
- Returns a time-series dataset for analysis.
Function: fetch_intraday_price(stock_symbol)
- Fetches the latest stock price using intraday data.
- ARIMA (AutoRegressive Integrated Moving Average):
- Provides statistical-based predictions.
- Suitable for time-series data with trends.
- ETS (Exponential Smoothing):
- Uses exponential smoothing for seasonal data.
- Random Forest:
- A machine learning model that incorporates lag features and technical indicators.
- LSTM (Long Short-Term Memory):
- A neural network-based model for sequential data.
Function:
- Launches the main GUI window.
- Displays historical data and model forecasts.
- Features:
- Interactive graph with hover functionality.
- Buttons to show historical data and exit.
Function:
- Opens a new window displaying historical data for the last 10 years.
yfinance
: Fetches stock data.pandas
: Data manipulation.matplotlib
: Visualization.tensorflow
: Neural network models (LSTM).statsmodels
: ARIMA and ETS models.sklearn
: Random Forest and preprocessing tools.mplcursors
: Adds hover functionality.tkinter
: GUI framework.
pip install yfinance pandas matplotlib tensorflow statsmodels scikit-learn mplcursors tk
-
Launch the Application:
- Run the script using
python stocks_forecast.py
.
- Run the script using
-
Select Stock:
- The application fetches data for IBM stocks by default.
- Modify the
stock_symbol
variable to analyze other stocks.
-
View Forecasts:
- Observe forecasts from ARIMA, ETS, Random Forest, and LSTM models.
- Hover over points on the graph to view predictions.
-
Exit:
- Click the "Exit" button to close the application.
Change the stock_symbol
variable in the __main__
section:
stock_symbol = "AAPL" # For Apple stock
Modify the steps
parameter in model functions to increase/decrease the forecast period.
Additional models can be implemented e.g., XGBoost, Prophet.
- Additional Models: Add models like Prophet, XGBoost, and SARIMA.
- User Preferences: Allow users to select models and forecast durations dynamically.
- Data Export: Functionality to save forecasts as CSV or Excel files.
- LSTM Predictions:
- Requires sufficient data for accurate predictions.
- Training may be slow for larger datasets.
- ARIMA Limitations:
- May not handle non-stationary data well without preprocessing.
- Real-Time Price Delay:
- Intraday data from Yahoo Finance may have a delay of up to 30 minutes.
For issues or suggestions, contact:
Developer: Atanas Youdanov
Email: [email protected]
GitHub: GitHub Profile