Skip to content

AI-powered sentiment analysis of financial news and tweets for stock market insights.

Notifications You must be signed in to change notification settings

paraggit/Stock-Market-Sentiment

Repository files navigation

πŸ“ˆ AI Stock Market Sentiment Analyzer

Stock Sentiment Analyzer

A powerful AI-driven application that analyzes stock market sentiment using Google's Gemini AI. Get real-time sentiment analysis, technical indicators, news feeds, and investment recommendations for any stock across multiple exchanges.

✨ Features

  • πŸ” Multi-Exchange Support: NSE, BSE, NASDAQ, NYSE, LSE, TSE
  • πŸ€– AI-Powered Analysis: Uses Google Gemini 2.5 Flash for sentiment analysis
  • πŸ“Š Technical Indicators: RSI, Moving Averages, Volume analysis
  • πŸ“° News Integration: Latest news articles and market updates
  • πŸ“ˆ Interactive Charts: Price charts with technical overlays
  • 🎯 Investment Recommendations: Buy/Hold/Sell suggestions with reasoning
  • πŸ“± Responsive Design: Works on desktop, tablet, and mobile
  • πŸ”„ Real-time Data: Up-to-date market information
  • πŸ“€ Export & Share: CSV export and social media sharing

πŸš€ Quick Start

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • Google Gemini API Key

Installation

  1. Clone the repository

    git clone <your-repo-url>
    cd Stock-Market-Sentiment
  2. Install dependencies

    npm install
  3. Set up environment variables

    # Copy the template file
    cp env.template .env
    
    # Edit .env file and add your API key
    GEMINI_API_KEY=your_gemini_api_key_here
  4. Get your Gemini API Key

  5. Run the development server

    npm run dev
  6. Open your browser

    • Navigate to http://localhost:3000
    • Start analyzing stocks! πŸŽ‰

πŸ› οΈ Available Scripts

# Development
npm run dev          # Start development server
npm run build        # Build for production
npm run preview      # Preview production build

# Docker
docker build -t stock-sentiment-analyzer .                    # Build Docker image
docker run -p 3000:3000 -e GEMINI_API_KEY=xxx stock-sentiment-analyzer  # Run container
docker-compose up -d                                          # Run with Docker Compose
docker-compose --profile dev up                              # Run development mode

# Linting
npm run lint         # Run ESLint
npm run lint:fix     # Fix ESLint issues

πŸ“ Project Structure

Stock-Market-Sentiment/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/          # React components
β”‚   β”‚   β”œβ”€β”€ icons/          # SVG icon components
β”‚   β”‚   β”œβ”€β”€ AspectRadarChart.tsx
β”‚   β”‚   β”œβ”€β”€ LoadingSpinner.tsx
β”‚   β”‚   β”œβ”€β”€ NewsFeed.tsx
β”‚   β”‚   β”œβ”€β”€ PriceChart.tsx
β”‚   β”‚   β”œβ”€β”€ SentimentChart.tsx
β”‚   β”‚   β”œβ”€β”€ SentimentResult.tsx
β”‚   β”‚   └── StockInputForm.tsx
β”‚   β”œβ”€β”€ services/           # API services
β”‚   β”‚   └── geminiService.ts
β”‚   β”œβ”€β”€ types.ts           # TypeScript type definitions
β”‚   β”œβ”€β”€ utils.ts           # Utility functions
β”‚   └── App.tsx            # Main application component
β”œβ”€β”€ public/                # Static assets
β”œβ”€β”€ .env                   # Environment variables
β”œβ”€β”€ env.template          # Environment template
β”œβ”€β”€ package.json          # Dependencies and scripts
β”œβ”€β”€ vite.config.ts        # Vite configuration
└── README.md            # This file

πŸ”§ Configuration

Environment Variables

Create a .env file in the root directory:

# Required: Gemini API Configuration
GEMINI_API_KEY=your_gemini_api_key_here

# Optional: Server Configuration
PORT=3000

Supported Exchanges

  • NSE (India) - National Stock Exchange
  • BSE (India) - Bombay Stock Exchange
  • NASDAQ (USA) - National Association of Securities Dealers
  • NYSE (USA) - New York Stock Exchange
  • LSE (UK) - London Stock Exchange
  • TSE (Japan) - Tokyo Stock Exchange

πŸ“Š How It Works

  1. Input: Enter a stock symbol and select an exchange
  2. AI Analysis: Gemini AI analyzes market sentiment using:
    • Recent news articles
    • Social media trends
    • Financial reports
    • Technical indicators
  3. Results: Get comprehensive analysis including:
    • Overall sentiment score (-1 to +1)
    • Investment recommendation
    • Positive and negative points
    • Technical indicators (RSI, Moving Averages)
    • Historical price data
    • Recent news articles

🎨 Technologies Used

  • Frontend: React 18, TypeScript, Vite
  • Styling: Tailwind CSS
  • Charts: Recharts
  • AI: Google Gemini 2.5 Flash
  • Icons: Custom SVG components
  • Build Tool: Vite

πŸš€ Deployment

Docker (Recommended)

Using Docker Compose

  1. Set up environment variables

    cp env.template .env
    # Edit .env with your API key
  2. Build and run with Docker Compose

    # Production
    docker-compose up -d
    
    # Development with hot reload
    docker-compose --profile dev up
  3. Access the application

Using Docker directly

  1. Build the image

    docker build -t stock-sentiment-analyzer .
  2. Run the container

    docker run -p 3000:3000 \
      -e GEMINI_API_KEY=your_api_key_here \
      stock-sentiment-analyzer

Vercel (Cloud Platform)

  1. Push your code to GitHub
  2. Connect your repository to Vercel
  3. Add environment variables in Vercel dashboard
  4. Deploy!

Netlify

  1. Build the project: npm run build
  2. Deploy the dist folder to Netlify
  3. Add environment variables in Netlify dashboard

Manual Deployment

  1. Build the project:
    npm run build
  2. Upload the dist folder to your web server
  3. Configure your server to serve the built files

πŸ”’ Security Notes

  • Never commit your .env file to version control
  • Keep your API keys secure
  • Use environment variables for all sensitive data
  • Consider using a proxy server for production API calls

πŸ› Troubleshooting

Common Issues

"GEMINI_API_KEY environment variable is not set"

  • Ensure your .env file exists in the root directory
  • Check that the API key is correctly formatted
  • Restart the development server after adding the key

"Network error"

  • Check your internet connection
  • Verify your API key is valid
  • Ensure the Gemini API is accessible from your location

"Model not found"

  • The app uses gemini-2.5-flash model
  • Ensure your API key has access to this model
  • Check Google's model availability

Getting Help

  1. Check the browser console for detailed error messages
  2. Verify your API key is working: https://makersuite.google.com/app/apikey
  3. Ensure all dependencies are installed: npm install
  4. Try restarting the development server

πŸ“ License

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

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

πŸ“ž Support

If you encounter any issues or have questions:

  1. Check the troubleshooting section above
  2. Search existing issues in the repository
  3. Create a new issue with detailed information
  4. Include error messages and steps to reproduce

πŸ™ Acknowledgments

  • Google Gemini AI for powerful language processing
  • Recharts for beautiful chart components
  • Tailwind CSS for utility-first styling
  • React team for the amazing framework

Disclaimer: This application is for educational and informational purposes only. It is not intended as financial advice. Always consult with a qualified financial advisor before making investment decisions.

About

AI-powered sentiment analysis of financial news and tweets for stock market insights.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published