An AI-powered stock price prediction application that combines neural networks and sentiment analysis to provide comprehensive stock movement predictions.
- Neural Network Analysis: Uses MLPRegressor with technical indicators for price prediction
- Sentiment Analysis: Analyzes news sentiment using VADER sentiment analysis
- Technical Indicators: Includes moving averages, volume analysis, and price changes
- Real-time Data: Fetches live stock data from Yahoo Finance
- News Integration: Incorporates recent news sentiment for comprehensive analysis
- Beautiful UI: Modern, responsive React frontend with TypeScript
- RESTful API: Flask backend with CORS support
- Python 3.8+
- Flask: Web framework
- scikit-learn: Machine learning library
- yfinance: Stock data fetching
- NLTK: Natural language processing
- VADER Sentiment: Sentiment analysis
- pandas & numpy: Data manipulation
- React 18: UI framework
- TypeScript: Type safety
- CSS3: Modern styling with gradients and animations
- Axios: HTTP client
stock-price-predictor/
├── stock_predictor.py # Main Flask backend with ML models
├── requirements.txt # Python dependencies
├── package.json # Node.js dependencies and scripts
├── package-lock.json # Locked dependency versions
├── tsconfig.json # TypeScript configuration
├── README.md # Project documentation
├── public/
│ └── index.html # Main HTML template
└── src/
├── App.tsx # Main React application
├── App.css # App-level styles
├── index.tsx # React entry point
├── index.css # Global styles
└── components/
├── Header.tsx # Header component
├── Header.css # Header styles
├── StockPredictor.tsx # Main stock prediction component
└── StockPredictor.css # Stock predictor styles
- Python 3.8 or higher
- Node.js 16 or higher
- npm or yarn
-
Clone the repository:
git clone <your-repo-url> cd stock-price-predictor
-
Install Python dependencies:
pip install -r requirements.txt
-
Install Node.js dependencies:
npm install
-
Start the backend server:
python stock_predictor.py
The server will start on
http://localhost:5000 -
Start the frontend (in a new terminal):
npm start
The frontend will open on
http://localhost:3000
- Open the application in your browser
- Enter a stock ticker symbol (e.g., AAPL, MSFT, NVDA, TSLA)
- Click "Analyze Stock" to analyze the stock
- View comprehensive results including:
- Current vs. predicted price
- Buy/Sell/Hold recommendation
- Confidence level
- News sentiment analysis
- Technical analysis reasoning
Predicts stock movement for a given ticker.
Request:
{
"ticker": "AAPL"
}Response:
{
"ticker": "AAPL",
"current_price": 150.25,
"predicted_price": 152.80,
"predicted_change_percent": 1.70,
"movement": "BUY",
"confidence": "Medium",
"reasoning": "Technical analysis and sentiment...",
"sentiment_score": 0.15,
"sentiment_analysis": "Positive - News sentiment is generally favorable",
"analysis_date": "2025-01-15 14:30:00",
"features_used": ["Open", "High", "Low", "Close", "Volume", "sentiment_score"],
"recent_articles": [...]
}Health check endpoint.
- Type: Multi-layer Perceptron Regressor
- Layers: 100 → 50 → 25 neurons
- Activation: ReLU
- Optimizer: Adam
- Max Iterations: 1000
- Open, High, Low, Close prices
- Volume data
- Moving averages (20-day)
- News sentiment scores
- Uses VADER (Valence Aware Dictionary and sEntiment Reasoner)
- Analyzes news headlines
- Aggregates daily sentiment scores
- Preprocesses text (removes stopwords, tokenizes)
- Stock Data: Yahoo Finance API
- News Data: NewsAPI (requires API key)
- Technical Indicators: Calculated from price data
Symptoms: ModuleNotFoundError or import errors
Solutions:
pip install -r requirements.txtSymptoms: Cannot find module errors
Solutions:
npm installSymptoms: Address already in use errors
Solutions:
- Close other applications using ports 3000 or 5000
- Kill processes:
netstat -ano | findstr :5000(Windows) orlsof -i :5000(Mac/Linux)
Symptoms: News sentiment analysis fails Solutions:
- Get a free API key from https://newsapi.org/
- Update the API key in
stock_predictor.py
- The neural network trains on each prediction for accuracy
- First prediction may take longer due to model initialization
- Subsequent predictions for the same stock are faster
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Check the troubleshooting section above
- Review the API documentation
- Open an issue on GitHub
Built with ❤️ using AI and modern web technologies