A comprehensive stock analysis and forecasting application powered by machine learning, featuring real-time market data, sentiment analysis, and AI-powered predictions.
- Real-time tracking of global market indices (S&P 500, Dow Jones, NASDAQ, FTSE 100, DAX, Nikkei 225, etc.)
- Sector-based stock monitoring across 8 major categories
- Interactive charts with customizable time ranges
- Live price updates and percentage changes
- Comprehensive technical analysis with moving averages (20-day, 50-day)
- Candlestick and line charts
- Volume analysis
- Key financial metrics (P/E ratio, Market Cap, 52-week range)
- Company information and business summaries
- AI-powered success rate predictions using Random Forest
- Real-time news aggregation from Yahoo Finance
- Sentiment analysis using TextBlob
- Overall sentiment scoring (Positive/Negative/Neutral)
- Integration with NewsAPI for broader financial news coverage
- Facebook Prophet model for time-series forecasting
- Configurable prediction periods (1-5 years)
- Trend decomposition and seasonality analysis
- Forecast visualization with confidence intervals
- Auto-refresh capability for real-time updates
- User-friendly sidebar navigation
- Custom stock selection with feedback mechanism
- Responsive design with custom CSS styling
- Python 3.8 or higher
- pip package manager
-
Clone the repository
git clone https://github.com/LIKHITHADITHYA/Stock-Forecast.git cd Stock-Forecast -
Create a virtual environment (recommended)
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables (optional)
Create a
.envfile in the root directory:NEWS_API_KEY=your_newsapi_key_here
-
Run the application
Web Interface (Streamlit):
streamlit run app.py # Or use the legacy interface streamlit run stock4.pyCommand Line Interface (CLI):
# Analyze a stock python cli.py analyze AAPL --period 1y # Predict future prices python cli.py predict MSFT --days 30 # Get news and sentiment python cli.py news GOOGL # Compare multiple stocks python cli.py compare AAPL MSFT GOOGL --period 1mo
-
Access the web application
Open your browser and navigate to
http://localhost:8501
- Navigate to "π Live Market Dashboard" from the sidebar
- View global market indices by region (US & Global markets)
- Select sectors to monitor using the multiselect dropdown
- Adjust time range (1d, 5d, 1mo, 3mo, 6mo, 1y)
- Toggle between line and candlestick charts
- View real-time price updates and key metrics
- Select "π Stock Analysis" from the sidebar
- Choose a sector (Tech Giants, E-commerce, EV & Auto, etc.)
- Pick a specific stock from the dropdown
- Set your desired date range
- View:
- Company information and financial metrics
- Technical analysis with moving averages
- Volume charts and RSI indicators
- Returns distribution and correlation heatmaps
- AI-powered next-day price movement predictions
- Navigate to "π° News & Sentiment Analysis"
- Select a stock symbol
- View overall sentiment score with breakdown:
- Positive/Negative/Neutral percentages
- Individual article sentiments
- Browse latest news articles from Yahoo Finance
- (Optional) Configure NewsAPI for additional financial news
- Select "π€ AI Predictions" from the sidebar
- Choose a stock symbol
- Set prediction period (1-5 years)
- View:
- Interactive forecast charts with confidence intervals
- Trend decomposition (yearly, weekly, daily seasonality)
- Key metrics (current vs forecasted price)
- Download forecast data as CSV
The CLI provides quick access to analysis features:
# Stock Analysis
python cli.py analyze AAPL --period 1y --output aapl_data.csv
# Shows: company info, latest prices, technical indicators, AI predictions
# Price Prediction
python cli.py predict MSFT --days 30 --output msft_forecast.csv
# Shows: forecast summary, 7-day outlook, predicted changes
# News & Sentiment
python cli.py news GOOGL --limit 15
# Shows: sentiment analysis, latest news articles
# Stock Comparison
python cli.py compare AAPL MSFT GOOGL AMZN --period 6mo
# Shows: side-by-side performance comparisonCLI Options:
--period: Time period (1d, 5d, 1mo, 3mo, 6mo, 1y, max)--days: Number of days to predict (default: 30)--limit: Number of news articles (default: 10)--output: Save results to file
Stock-Forecast/
βββ app.py # Enhanced Streamlit application
βββ stock4.py # Legacy application (maintained for compatibility)
βββ cli.py # Command-line interface
βββ requirements.txt # Python dependencies
βββ .env.example # Example environment variables
βββ .gitignore # Git ignore rules
βββ README.md # This file
βββ CONTRIBUTING.md # Contribution guidelines
β
βββ modules/ # Modular components
β βββ __init__.py
β βββ config.py # Configuration and constants
β βββ data_handler.py # Data fetching and processing
β βββ ml_models.py # Machine learning models
β βββ visualization.py # Chart generation
β βββ sentiment.py # Sentiment analysis
β βββ utils.py # Utility functions
β
βββ tests/ # Unit and integration tests
β βββ __init__.py
β βββ conftest.py # Test configuration
β βββ test_utils.py
β βββ test_data_handler.py
β βββ test_ml_models.py
β βββ test_sentiment.py
β βββ test_visualization.py
β
βββ models/ # Saved ML models
βββ logs/ # Application logs
β
βββ .github/
βββ workflows/ # CI/CD workflows
βββ ci.yml # GitHub Actions workflow
The application supports NewsAPI for extended news coverage. To use this feature:
- Get a free API key from NewsAPI
- Add it to your
.envfile:NEWS_API_KEY=your_key_here
Create .streamlit/config.toml for custom settings:
[theme]
primaryColor = "#0068c9"
backgroundColor = "#ffffff"
secondaryBackgroundColor = "#f0f2f6"
textColor = "#262730"
font = "sans serif"
[server]
maxUploadSize = 200
enableCORS = falseRun tests using pytest:
# Run all tests
pytest
# Run with coverage
pytest --cov=. --cov-report=html
# Run specific test file
pytest tests/test_models.pyWe welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and linting
- Commit your changes (
git commit -m 'Add amazing feature') - Push to your branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 guidelines
- Use Black for code formatting
- Add docstrings to all functions
- Write unit tests for new features
- Tech Giants: AAPL, MSFT, GOOGL, META, NVDA, TSM
- E-commerce: AMZN, SHOP, BABA, MELI, SE, ETSY
- EV & Auto: TSLA, F, GM, TM, NIO, RIVN
- Finance: JPM, BAC, GS, MS, V, MA
- Healthcare: JNJ, PFE, MRNA, ABBV, UNH, CVS
- Crypto & Blockchain: COIN, MSTR, RIOT, MARA, SQ, PYPL
- AI & Robotics: PATH, AI, IRBT, ISRG, ROK, ABB
- Clean Energy: ENPH, SEDG, FSLR, NEE, BE, PLUG
- Never commit API keys or sensitive data
- Use
.envfiles for environment variables - Keep dependencies up to date
- Report security vulnerabilities via GitHub Issues
- Use Case: Long-term time-series forecasting
- Features: Handles seasonality, trends, and holidays
- Parameters: Configurable changepoint prior scale
- Use Case: Short-term price movement prediction
- Features: Uses technical indicators (MA, RSI, Volume)
- Output: Probability of next-day price increase
- Moving Averages: 5-day, 20-day, 50-day
- RSI: Relative Strength Index (14-period)
- Volume Analysis: 20-day moving average
- Candlestick Patterns: OHLC data visualization
- Auto-refresh feature may cause performance issues with many stocks
- NewsAPI integration requires manual key entry per session
- Large date ranges may slow down initial data loading
- Modular architecture with separated concerns
- Comprehensive documentation and contribution guidelines
- Command-line interface (CLI)
- Unit tests with pytest
- CI/CD with GitHub Actions
- Environment variable management
- Advanced technical indicators
- Sentiment analysis for news
- Prophet forecasting model
- Random Forest price prediction
- Enhanced visualizations (RSI, correlation, returns)
- Model evaluation metrics
- LSTM neural network model
- ARIMA for classical time-series analysis
- Portfolio management features
- Real-time alerts and notifications
- Stock comparison dashboard
- Mobile-responsive design improvements
- PDF report generation
- User authentication system
- Model versioning and tracking
- Enhanced feature engineering
- Backtesting framework
- Multiple timeframe analysis
This project is licensed under the MIT License - see the LICENSE file for details.
- Yahoo Finance for market data
- Facebook Prophet for forecasting capabilities
- Streamlit for the web framework
- NewsAPI for financial news data
For questions, suggestions, or issues:
- Open an issue on GitHub
- Contact: [Your Contact Info]
This application is for educational and informational purposes only. It should not be used as the sole basis for investment decisions. Always consult with a qualified financial advisor before making investment decisions.
Made with β€οΈ by LIKHITHADITHYA