This project provides a robust framework for analyzing, predicting, and generating actionable insights on stock prices using machine learning and natural language processing. By combining historical data analysis with predictive modeling and investment insights, it empowers users to make informed financial decisions.
The Stock Price Analysis and Prediction with AI project is designed for anyone interested in leveraging AI to understand stock market trends and make data-driven investment decisions. It integrates historical data analysis, machine learning predictions, and insights generated by a natural language processing model. The tool is highly customizable and can be adapted for various stocks, durations, and advanced use cases.
-
Data Collection:
- Fetches historical stock price data for any ticker symbol using the
yfinancelibrary.
- Fetches historical stock price data for any ticker symbol using the
-
Data Processing:
- Computes financial metrics such as moving averages, daily returns, and percentage changes.
-
Predictive Modeling:
- Uses a trained machine learning model to predict the next trading day's stock price.
-
Actionable Recommendations:
- Offers "Buy", "Sell", or "Hold" advice based on the predicted vs. current stock price.
-
LLM-Driven Insights:
- Leverages a Hugging Face language model to generate human-readable investment analysis and summaries.
Ensure you have Python 3.8 or higher installed.
-
Clone the repository:
git clone https://github.com/yash-dave/stock-analysis-predictor.git cd stock-analysis-predictor -
Install required dependencies:
pip install -r requirements.txt
-
Create the
modelsdirectory if it doesn't exist:mkdir models
-
Run the main script:
python main.py
-
Enter the required details when prompted:
- Stock Ticker: For example,
AAPLfor Apple,GOOGLfor Alphabet. - Duration: Specify the number of years of historical data to analyze.
- Stock Ticker: For example,
-
View the outputs:
- Predicted stock price for the next trading day.
- Recommendations: Buy, Sell, or Hold.
- A summary of historical stock performance and investment insights.
- Fetch Data: Retrieve historical stock prices for the specified ticker and duration.
- Process Data: Compute key metrics like moving averages and daily returns.
- Train or Load Model: Train a Random Forest model (or load an existing one) to predict future stock prices.
- Generate Prediction: Predict the next day's stock price using the trained model.
- Provide Recommendations: Compare the predicted price to the current price and suggest investment actions.
- LLM Insights: Summarize the stock’s performance using a pre-trained language model.
-
Advanced Prediction Models:
- Implement deep learning models such as LSTMs or GRUs for more accurate time-series analysis.
-
Additional Data Integration:
- Include trading volumes, news sentiment analysis, or macroeconomic indicators.
-
Real-Time Features:
- Enable real-time stock price predictions with live market data.
-
Interactive Dashboard:
- Develop a web-based or GUI-based interface for enhanced user experience.