Skip to content

Interactive Streamlit app for real-time stock analysis and prediction. Features live market data, sector-wise stock charts, technical indicators, news sentiment analysis, and AI-driven price forecasting with Prophet. Customize sectors, date ranges, and chart types for informed investing decisions.

Notifications You must be signed in to change notification settings

LIKHITHADITHYA/Stock-Forecast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ˆ Stock Forecast - Advanced Stock Analysis & Prediction Platform

A comprehensive stock analysis and forecasting application powered by machine learning, featuring real-time market data, sentiment analysis, and AI-powered predictions.

🌟 Features

1. Live Market Dashboard

  • 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

2. Stock Analysis

  • 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

3. News & Sentiment Analysis

  • 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

4. AI-Powered Predictions

  • Facebook Prophet model for time-series forecasting
  • Configurable prediction periods (1-5 years)
  • Trend decomposition and seasonality analysis
  • Forecast visualization with confidence intervals

5. Additional Features

  • Auto-refresh capability for real-time updates
  • User-friendly sidebar navigation
  • Custom stock selection with feedback mechanism
  • Responsive design with custom CSS styling

πŸš€ Quick Start

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Installation

  1. Clone the repository

    git clone https://github.com/LIKHITHADITHYA/Stock-Forecast.git
    cd Stock-Forecast
  2. Create a virtual environment (recommended)

    python -m venv venv
    
    # On Windows
    venv\Scripts\activate
    
    # On macOS/Linux
    source venv/bin/activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up environment variables (optional)

    Create a .env file in the root directory:

    NEWS_API_KEY=your_newsapi_key_here
  5. Run the application

    Web Interface (Streamlit):

    streamlit run app.py
    # Or use the legacy interface
    streamlit run stock4.py

    Command 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
  6. Access the web application

    Open your browser and navigate to http://localhost:8501

πŸ“Š Usage Guide

Web Interface (app.py)

Live Market Dashboard

  1. Navigate to "πŸ“Š Live Market Dashboard" from the sidebar
  2. View global market indices by region (US & Global markets)
  3. Select sectors to monitor using the multiselect dropdown
  4. Adjust time range (1d, 5d, 1mo, 3mo, 6mo, 1y)
  5. Toggle between line and candlestick charts
  6. View real-time price updates and key metrics

Stock Analysis

  1. Select "πŸ“ˆ Stock Analysis" from the sidebar
  2. Choose a sector (Tech Giants, E-commerce, EV & Auto, etc.)
  3. Pick a specific stock from the dropdown
  4. Set your desired date range
  5. 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

News & Sentiment

  1. Navigate to "πŸ“° News & Sentiment Analysis"
  2. Select a stock symbol
  3. View overall sentiment score with breakdown:
    • Positive/Negative/Neutral percentages
    • Individual article sentiments
  4. Browse latest news articles from Yahoo Finance
  5. (Optional) Configure NewsAPI for additional financial news

AI Predictions

  1. Select "πŸ€– AI Predictions" from the sidebar
  2. Choose a stock symbol
  3. Set prediction period (1-5 years)
  4. View:
    • Interactive forecast charts with confidence intervals
    • Trend decomposition (yearly, weekly, daily seasonality)
    • Key metrics (current vs forecasted price)
  5. Download forecast data as CSV

Command Line Interface (cli.py)

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 comparison

CLI 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

πŸ—οΈ Project Structure

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

πŸ”§ Configuration

API Keys

The application supports NewsAPI for extended news coverage. To use this feature:

  1. Get a free API key from NewsAPI
  2. Add it to your .env file:
    NEWS_API_KEY=your_key_here

Streamlit Configuration

Create .streamlit/config.toml for custom settings:

[theme]
primaryColor = "#0068c9"
backgroundColor = "#ffffff"
secondaryBackgroundColor = "#f0f2f6"
textColor = "#262730"
font = "sans serif"

[server]
maxUploadSize = 200
enableCORS = false

πŸ§ͺ Testing

Run tests using pytest:

# Run all tests
pytest

# Run with coverage
pytest --cov=. --cov-report=html

# Run specific test file
pytest tests/test_models.py

🀝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and linting
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to your branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Code Style

  • Follow PEP 8 guidelines
  • Use Black for code formatting
  • Add docstrings to all functions
  • Write unit tests for new features

πŸ“ Available Stock Categories

  • 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

πŸ” Security

  • Never commit API keys or sensitive data
  • Use .env files for environment variables
  • Keep dependencies up to date
  • Report security vulnerabilities via GitHub Issues

πŸ“ˆ Machine Learning Models

Prophet Model

  • Use Case: Long-term time-series forecasting
  • Features: Handles seasonality, trends, and holidays
  • Parameters: Configurable changepoint prior scale

Random Forest

  • Use Case: Short-term price movement prediction
  • Features: Uses technical indicators (MA, RSI, Volume)
  • Output: Probability of next-day price increase

πŸ“Š Technical Indicators

  • 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

πŸ› Known Issues

  • 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

πŸ—ΊοΈ Roadmap

Implemented βœ…

  • 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

Planned 🚧

  • 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

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘ Acknowledgments

πŸ“§ Contact

For questions, suggestions, or issues:

  • Open an issue on GitHub
  • Contact: [Your Contact Info]

⚠️ Disclaimer

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

About

Interactive Streamlit app for real-time stock analysis and prediction. Features live market data, sector-wise stock charts, technical indicators, news sentiment analysis, and AI-driven price forecasting with Prophet. Customize sectors, date ranges, and chart types for informed investing decisions.

Resources

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages