A comprehensive stock analysis platform combining LSTM neural networks with AI-powered insights for professional financial analysis.
- β
Real-Time Stock Data Integration - Fetches live data using
yfinance(Yahoo Finance) - β Intelligent Price Forecasting - LSTM neural network generates 7-day price predictions
- β Real Closing Prices - Shows actual closing prices when available, not model predictions
- β AI-Powered Analysis - Google Gemini Flash 2.5 provides market sentiment and technical analysis
- β Comprehensive Technical Indicators - RSI, MACD, Bollinger Bands, Simple Moving Averages (SMA 20/50)
- β Interactive Charts - Beautiful visualizations with Recharts and dynamic trend coloring
- β Professional Report Generation - Export detailed analysis reports in Word or PDF format
- β Fallback Simulation Mode - Continues working even when backend services are unavailable
- β Modern Responsive UI - Built with React 19, TypeScript, and Tailwind CSS
- Frontend: React 19 + TypeScript + Vite + Tailwind CSS + Recharts
- Backend: FastAPI + Python + TensorFlow/Keras + Uvicorn
- Data Source: Yahoo Finance API (yfinance)
- AI Analysis: Google Gemini Flash 2.5
- Model: Pre-trained LSTM neural network for time series forecasting
- Supported Tickers: AAPL, GOOGL, MSFT, AMZN, TSLA
- Python 3.8+ with pip
- Node.js 18+ with npm
- Trained LSTM Model (
lstm_stock_predictor.keras) in project root - Internet Connection for real-time data fetching
git clone <repository-url>
cd stock-ai-forecaster
# Create virtual environment (recommended)
python -m venv venv
venv\Scripts\activate # On Windows
# source venv/bin/activate # On macOS/Linux
# Install Python dependencies
pip install -r requirements.txt
# Install Node.js dependencies
npm install
Create a .env.local file in the root directory:
VITE_GEMINI_API_KEY=your_gemini_api_key_here
GEMINI_API_KEY=your_gemini_api_key_here
GEMINI_API_KEY2=your_backup_gemini_api_key_here
This is a full-stack application requiring both backend and frontend to run simultaneously.
python server.py
Expected Output:
LSTM model loaded successfully
INFO: Started server process [PID] on http://0.0.0.0:8000
npm run dev
Expected Output:
VITE v6.2.0 ready in XXXX ms
β Local: http://localhost:5173/
β Network: http://192.168.X.X:5173/
Open your browser and navigate to http://localhost:5173/
Returns historical data and price forecasts for a given stock ticker.
Parameters:
ticker(string): Stock symbol (AAPL, GOOGL, MSFT, AMZN, TSLA)
Response:
{
"history": [
{
"date": "2024-01-01",
"open": 150.25,
"high": 152.10,
"low": 149.80,
"close": 151.50,
"volume": 12345678
}
],
"forecast": [
{
"date": "2024-01-01",
"price": 151.50,
"isForecast": false
},
{
"date": "2024-01-02",
"price": 153.25,
"isForecast": true
}
]
}
Generates comprehensive stock analysis reports.
Parameters:
ticker(string): Stock symbolformat(string): "word" or "pdf"
Response: File download
Health check endpoint.
Response:
{
"status": "healthy",
"model_loaded": true
}
VITE_GEMINI_API_KEY: Primary Gemini API key for frontendGEMINI_API_KEY: Primary Gemini API key for backendGEMINI_API_KEY2: Backup Gemini API key
- Look-back Period: 60 days of historical data for predictions
- Forecast Horizon: 7 days of price predictions
- Supported Tickers: AAPL, GOOGL, MSFT, AMZN, TSLA
"Model not loaded"
- Ensure
lstm_stock_predictor.kerasexists in the project root - Check file permissions
- Verify TensorFlow installation:
python -c "import tensorflow as tf; print(tf.__version__)"
"Server Disconnected (Simulated Mode)"
- Backend server not running on port 8000
- Check for firewall blocking port 8000
- Verify FastAPI is running:
curl http://localhost:8000/health
"Could not fetch data for {ticker}"
- Check internet connection
- Verify ticker symbol is supported
- Yahoo Finance API may be temporarily unavailable
"Failed to fetch" errors
- Backend server not running
- CORS issues (check browser console)
- Wrong API endpoint URL
Blank charts or missing data
- Check browser console for JavaScript errors
- Ensure backend is responding correctly
- Verify ticker selection
"Market sentiment analysis currently unavailable"
- Invalid or missing Gemini API key
- API quota exceeded
- Temporary Gemini service issues
Slow loading times
- Large historical data sets (180 days)
- Network latency for data fetching
- Heavy LSTM model computations
stock-ai-forecaster/
βββ components/ # React components
β βββ MainChart.tsx # Price and forecast visualization
β βββ ForecastCard.tsx # AI analysis display
β βββ IndicatorPanel.tsx # Technical indicators
β βββ MacdPanel.tsx # MACD indicator
βββ services/ # API and external services
β βββ apiService.ts # Backend API calls
β βββ dataService.ts # Fallback data simulation
β βββ geminiService.ts # AI analysis
βββ utils/ # Utility functions
β βββ financialMath.ts # Technical calculations
βββ server.py # FastAPI backend server
βββ update.py # Model update utilities
βββ grounding_search.py # Google search integration
βββ lstm_stock_predictor.keras # Trained model
βββ predictions_cache.csv # Forecast cache
βββ requirements.txt # Python dependencies
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature - Commit changes:
git commit -am 'Add new feature' - Push to branch:
git push origin feature/new-feature - Submit a pull request
This project is for educational and research purposes. Please ensure compliance with API terms of service and financial regulations.
This application is for educational purposes only and should not be considered as financial advice. Always consult with qualified financial advisors before making investment decisions. Past performance does not guarantee future results.
Built with β€οΈ using modern web technologies and machine learning