Skip to content

fahad10inb/Stock_prediction

License: MIT Contributors Issues Forks Stars

FINSIGHT Documentation

An intelligent stock market insights platform simplifying investment decisions with AI-driven recommendations and real-time data.

Introduction

FINSIGHT is an intelligent stock market insights platform designed to simplify the investment journey for both beginners and seasoned investors. The platform centralizes essential stock market data, financial news, and personalized recommendations, providing users with actionable insights to make informed decisions.

Project Overview

Objective

To create a user-friendly application that integrates historical stock data, real-time news sentiment analysis, and AI-driven recommendations for smarter investment decisions.

Key Features

  1. Centralized stock market data from trusted sources like NSE India, Economic Times, and Yahoo Finance.
  2. Sentiment analysis of financial news headlines for real-time market insights.
  3. Personalized investment recommendations based on historical data, sentiment analysis, and trends.
  4. Portfolio management tools to track and analyze investment performance.
  5. Visual representation of stock trends, sentiment scores, and recommendation confidence.
  6. Real-time alerts for significant market fluctuations and investment opportunities.

System Architecture

1. Data Layer

  • Stock Data Sources: NSE Website, Economic Times, Finnhub API, Google API, Yahoo Finance API.
  • News Sources: NewsAPI, Reuters API.
  • Data Processing:
    • Text preprocessing using SpaCy.
    • Semantic embeddings with SentenceTransformer.
    • Numerical normalization using StandardScaler.
    • Sentiment classification with fine-tuned BERT models.

2. Processing Layer

  • Sentiment Analysis Models:
    • VADER for basic sentiment scoring.
    • FinBERT for financial context analysis.
    • Fine-tuned BERT models for enhanced sentiment classification.
  • Summarization Model:
    • Gemini for generating concise and informative summaries of financial news.
  • Trend Prediction:
    • Machine Learning Models: LSTM, GRU, Transformer models for time-series predictions.
  • Feature Integration:
    • Combines numerical stock data with semantic news embeddings and user-defined preferences.

3. Application Layer

  • Frontend:
    • Built with React for dynamic interfaces.
    • Styled using Tailwind CSS and Bootstrap.
  • Backend:
    • Flask/FastAPI for API handling.
    • Axios for HTTP requests.
  • Deployment:
    • Hosted on Vercel with model training on Google Colab and Hugging Face Spaces.

Tech Stack

Frontend

  • React, Tailwind CSS, JavaScript, Bootstrap

Backend

  • Python, Flask/FastAPI

Data Scraping

  • NSE Website, Economic Times, Finnhub API, Google API, Yahoo Finance API, NewsAPI, Reuters API

Cloud and Hosting

  • Google Colab, Vercel, Hugging Face Spaces

Version Control

  • GitHub

Libraries and Tools

  • SpaCy, SentenceTransformer, VADER, FinBERT, StandardScaler, Gemini, Hugging Face Transformers

Key Functionalities

1. Real-Time Stock Data Aggregation

  • Scrapes stock data from multiple sources.
  • Updates trends dynamically for user convenience.

2. News Sentiment Analysis

  • Processes headlines using sentiment analysis tools (VADER, FinBERT, fine-tuned BERT models).
  • Categorizes sentiments into positive, neutral, and negative.

3. Summarization of Financial News

  • Utilizes Gemini to generate concise and informative summaries of financial news articles, allowing users to quickly understand key points.

4. Personalized Investment Recommendations

  • Analyzes historical trends, market sentiment, and user preferences.
  • Suggests investment actions (e.g., invest, hold, avoid) with confidence scores based on sentiment analysis and market trends.

5. Portfolio Management

  • Tracks stock purchase price, current value, profit/loss, and percentage changes.

6. Real-Time Alerts

  • Provides notifications for major market shifts and investment opportunities based on AI-driven insights.

7. Visualizations

  • Interactive graphs for stock trends.
  • Sentiment dashboards for quick market sentiment overviews.

Development Workflow

1. Data Collection

  • Set up APIs for data aggregation (Finnhub, Google, NewsAPI, Reuters API, Yahoo Finance API).
  • Automate scraping tasks for real-time updates.

2. Preprocessing

  • Clean and tokenize news data using SpaCy.
  • Normalize numerical stock data for consistency.
  • Fine-tune sentiment analysis models for accuracy.

3. Model Training

  • Train sentiment analysis models on labeled datasets.
  • Fine-tune Gemini for financial news summarization.
  • Fine-tune LSTM, GRU, and Transformer models for time-series predictions.

4. API Integration

  • Build Flask/FastAPI endpoints for model predictions.
  • Handle user requests and serve real-time data.

5. Frontend Development

  • Create interactive dashboards and widgets with React.
  • Use Chart.js and D3.js for graph visualizations.

Deployment

  • Hosting: Vercel for the web application.
  • Model Training: Google Colab, Hugging Face Spaces for scalable training.
  • Version Control: GitHub for code management and collaboration.

API Documentation

Overview

The FINSIGHT API provides programmatic access to stock market data, financial news sentiment analysis, and AI-driven investment recommendations. This documentation covers the available endpoints, authentication, request/response formats, error handling, and usage examples.

Authentication

  • API uses Bearer Token authentication.
  • Include your API key in the Authorization header as:
    Authorization: Bearer YOUR_API_KEY
  • Obtain API keys by registering on the platform.

Base URL

https://api.finsight.com/v1

Endpoints

1. Get Stock Data

  • URL: /stocks/{symbol}
  • Method: GET
  • URL Params:
    symbol=[string] (required) - Stock ticker symbol (e.g., "AAPL", "TCS.NS")
  • Success Response:
    • Code: 200
    • Content:
    {
      "symbol": "AAPL",
      "price": 150.25,
      "change": -0.45,
      "volume": 1200000,
      "timestamp": "2024-06-01T12:00:00Z"
    }
  • Error Response:
    • Code: 404 NOT FOUND
    • Content: { "error": "Stock symbol not found" }

2. Get News Sentiment

  • URL: /news/sentiment
  • Method: POST
  • Body Params:
    {
      "symbols": ["AAPL", "GOOG"],
      "date_range": {
        "start": "2024-05-01",
        "end": "2024-05-31"
      }
    }
  • Success Response:
    • Code: 200
    • Content:
    {
      "AAPL": { "positive": 0.6, "neutral": 0.3, "negative": 0.1 },
      "GOOG": { "positive": 0.5, "neutral": 0.4, "negative": 0.1 }
    }
  • Error Response:
    • Code: 400 BAD REQUEST
    • Content: { "error": "Invalid request parameters" }

3. Get Investment Recommendations

  • URL: /recommendations/{user_id}
  • Method: GET
  • URL Params:
    user_id=[string] (required) - Unique user identifier
  • Success Response:
    • Code: 200
    • Content:
    {
      "user_id": "12345",
      "recommendations": [
        { "symbol": "AAPL", "action": "buy", "confidence": 0.85 },
        { "symbol": "TSLA", "action": "hold", "confidence": 0.65 }
      ]
    }
  • Error Response:
    • Code: 401 UNAUTHORIZED
    • Content: { "error": "Invalid or missing API key" }

Error Handling

  • Standard HTTP status codes are used.
  • Error responses include an error field with a descriptive message.
  • Common codes: 400 (Bad Request), 401 (Unauthorized), 404 (Not Found), 500 (Internal Server Error).

Rate Limiting

  • API requests are limited to 1000 requests per minute per API key.
  • Exceeding the limit returns HTTP 429 Too Many Requests.

SDK / Code Examples

Python Example

import requests

API_KEY = "YOUR_API_KEY"
headers = {"Authorization": f"Bearer {API_KEY}"}

response = requests.get("https://api.finsight.com/v1/stocks/AAPL", headers=headers)
if response.status_code == 200:
    data = response.json()
    print(f"Price of AAPL: {data['price']}")
else:
    print(f"Error: {response.json()['error']}")

cURL Example

curl -H "Authorization: Bearer YOUR_API_KEY" https://api.finsight.com/v1/stocks/AAPL

Getting Started

  1. Register for an API key on the FINSIGHT platform.
  2. Review the API endpoints and authentication method.
  3. Use the provided SDK examples or your preferred HTTP client to integrate.
  4. Handle errors and respect rate limits in your application.

Future Enhancements

  1. Integration with global stock markets (e.g., NYSE, NASDAQ, London Stock Exchange).
  2. Enhanced AI-driven recommendations using reinforcement learning and transformer-based models.
  3. Mobile application development for on-the-go insights.
  4. Advanced analytics for institutional investors.
  5. Automated trade execution based on AI-driven predictions.
  6. Expansion to include cryptocurrency and forex market insights.
  7. Multi-language support for international investors.

Project Status

The project is currently in active development. Contributions and feedback are welcome!

Roadmap

  • Add support for additional global stock markets.
  • Improve AI recommendation models with reinforcement learning.
  • Develop mobile applications for iOS and Android.
  • Implement automated trade execution features.
  • Expand to cryptocurrency and forex markets.
  • Add multi-language support.

FAQ

Q: How do I contribute to the project?
A: Please see the CONTRIBUTING.md file for detailed guidelines.

Q: Where can I report issues?
A: Use the GitHub Issues tab to report bugs or request features.

Q: Is there a code of conduct?
A: Yes, please see the CODE_OF_CONDUCT.md file.

Repository Information

How to Contribute

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Commit your changes and push them to your branch.
  4. Create a pull request detailing your contributions.

For detailed contribution guidelines, please see the CONTRIBUTING.md file.

Issue and Pull Request Templates

Please use the provided issue and pull request templates to help maintainers understand your contributions and issues.

Code of Conduct

This project follows a Code of Conduct. By participating, you agree to abide by its terms.

Setup Instructions

  1. Clone the repository: git clone https://github.com/fahad10inb/Stock_prediction.git
  2. Install dependencies:
    • Frontend: npm install
    • Backend: pip install -r requirements.txt
  3. Start the development server:
    • Frontend: npm start
    • Backend: python app.py

License

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

For any questions or contributions, please visit the GitHub repository.

About

Stock Prediction is a project focused on predicting stock market trends using data-driven techniques. The repository is designed to help users analyze financial data and enhance their understanding of stock price behavior with practical code examples. With an MIT License, it encourages collaboration and is open for contributions.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors