Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Finance News Intelligence Generation

A comprehensive system for extracting financial intelligence from news sources, analyzing market impact, and generating actionable insights using NLP and knowledge graphs.

🎯 Overview

This project combines Natural Language Processing (NLP), Knowledge Graph technology, and financial data analysis to:

  • Extract financial events and entities from news articles
  • Perform sentiment analysis on financial news
  • Build a knowledge graph of relationships between companies, events, and market impacts
  • Generate market impact predictions
  • Provide explainable trading signals based on news sentiment

πŸ“‹ Project Structure

finance-news-intelligence/
β”œβ”€β”€ backend/                    # Python backend (API & Pipeline)
β”‚   β”œβ”€β”€ config.py              # Configuration management
β”‚   β”œβ”€β”€ server.py              # FastAPI application
β”‚   β”œβ”€β”€ pipeline.py            # ETL pipeline
β”‚   β”œβ”€β”€ database.py            # Database operations
β”‚   β”œβ”€β”€ datetime_utils.py       # Utility functions
β”‚   β”‚
β”‚   β”œβ”€β”€ nlp/                    # NLP Module
β”‚   β”‚   β”œβ”€β”€ ner_model.py       # Named Entity Recognition
β”‚   β”‚   β”œβ”€β”€ event_extractor.py # Event extraction
β”‚   β”‚   └── aspect_sentiment.py # Aspect-based sentiment analysis
β”‚   β”‚
β”‚   β”œβ”€β”€ intelligence/           # Intelligence Module
β”‚   β”‚   β”œβ”€β”€ knowledge_graph.py  # Knowledge graph construction
β”‚   β”‚   β”œβ”€β”€ query_engine.py     # Graph query engine
β”‚   β”‚   β”œβ”€β”€ signal_generator.py # Trading signal generation
β”‚   β”‚   └── summarizer.py       # Report summarization
β”‚   β”‚
β”‚   β”œβ”€β”€ market/                 # Market Analysis Module
β”‚   β”‚   β”œβ”€β”€ market_data_loader.py # Market data fetching
β”‚   β”‚   β”œβ”€β”€ price_loader.py     # Price data handling
β”‚   β”‚   └── impact_analysis.py  # Market impact analysis
β”‚   β”‚
β”‚   β”œβ”€β”€ evaluation/             # Evaluation Module
β”‚   β”‚   β”œβ”€β”€ accuracy_report.py  # Accuracy metrics
β”‚   β”‚   β”œβ”€β”€ logic_tester.py     # Logic validation
β”‚   β”‚   └── visual_report.py    # Report visualization
β”‚   β”‚
β”‚   β”œβ”€β”€ data/                   # Data Directory
β”‚   β”‚   β”œβ”€β”€ finance.db          # SQLite database
β”‚   β”‚   β”œβ”€β”€ stocks_universe.csv # Supported stocks list
β”‚   β”‚   β”œβ”€β”€ raw/                # Raw data storage
β”‚   β”‚   └── yfinance_cache/     # Finance data cache
β”‚   β”‚
β”‚   └── lib/                    # Frontend libraries
β”‚       β”œβ”€β”€ vis-9.1.2/          # Vis.js network visualization
β”‚       β”œβ”€β”€ tom-select/         # Select dropdown library
β”‚       └── bindings/           # JavaScript bindings
β”‚
β”œβ”€β”€ frontend/                   # React + Vite Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ ExplainableReasoning.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ MarketNews.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ PortfolioImpact.jsx
β”‚   β”‚   β”‚   └── RippleEffect.jsx
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx
β”‚   β”‚   β”‚   └── Login.jsx
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   β”œβ”€β”€ api.js
β”‚   β”‚   └── main.jsx
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ vite.config.js
β”‚   └── eslint.config.js
β”‚
β”œβ”€β”€ requirements.txt            # Python dependencies
β”œβ”€β”€ README.md                   # This file

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • Node.js 16+
  • SQLite3

Backend Setup

  1. Create and activate virtual environment:
python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Initialize database:
# Database will be initialized automatically when the server starts
python backend/server.py

Frontend Setup

  1. Install dependencies:
cd frontend
npm install
  1. Start development server:
npm run dev

πŸ“š Common Commands

Backend

  • Run API Server:

    python backend/server.py

    API will be available at http://localhost:8000

  • Run ETL Pipeline:

    python backend/pipeline.py

Frontend

  • Development:
    npm run dev

πŸ”§ Core Modules

NLP Module (backend/nlp/)

Handles natural language processing tasks:

  • NER Model: Extracts named entities (companies, people, locations)
  • Event Extractor: Identifies financial events from text
  • Aspect Sentiment: Analyzes sentiment for specific aspects (price, risk, growth)

Intelligence Module (backend/intelligence/)

Generates actionable intelligence:

  • Knowledge Graph: Builds relationships between entities and events
  • Query Engine: Retrieves relevant information from the graph
  • Signal Generator: Creates trading signals based on news impact
  • Summarizer: Generates concise reports

Market Module (backend/market/)

Analyzes market data:

  • Market Data Loader: Fetches real-time and historical data
  • Price Loader: Manages stock price information
  • Impact Analysis: Quantifies news impact on prices

Evaluation Module (backend/evaluation/)

Validates and reports results:

  • Accuracy Report: Metrics and performance analysis
  • Logic Tester: Validates business logic
  • Visual Report: Generates dashboard visualizations

πŸ“Š API Endpoints

News Analysis

  • GET /api/news - Get latest news
  • POST /api/news/analyze - Analyze news article
  • GET /api/sentiment/{ticker} - Get sentiment for a stock

Knowledge Graph

  • GET /api/graph/entities - List all entities
  • GET /api/graph/relations/{entity} - Get entity relations
  • POST /api/graph/query - Query the knowledge graph

Signals

  • GET /api/signals/{ticker} - Get trading signals
  • GET /api/signals/portfolio - Portfolio impact analysis

Market Impact

  • GET /api/impact/{ticker} - Historical impact analysis
  • POST /api/impact/predict - Predict market impact

πŸ” Authentication

The system uses JWT-based authentication:

  • Login: POST /api/auth/login
  • Logout: POST /api/auth/logout
  • Verify: GET /api/auth/verify

Credentials are secured using bcrypt hashing.

πŸ“ˆ Features

  • Real-time News Processing - Fetches and processes financial news
  • Sentiment Analysis - Multi-aspect sentiment scoring
  • Entity Recognition - Identifies companies, executives, financial terms
  • Knowledge Graph - Visual representation of relationships
  • Trading Signals - AI-generated buy/sell recommendations
  • Portfolio Impact - Analyze impact on your portfolio
  • Explainable AI - Understand reasoning behind signals
  • Market Impact Analysis - Quantify news effect on prices

πŸ§ͺ Testing

Run the logic tester to validate the system:

python backend/evaluation/logic_tester.py

Generate an accuracy report:

python backend/evaluation/accuracy_report.py

πŸ“¦ Dependencies

Backend

  • feedparser - RSS feed parsing
  • yfinance - Stock data fetching
  • pandas - Data manipulation
  • networkx - Graph algorithms
  • pyvis - Graph visualization
  • fastapi - Web framework
  • uvicorn - ASGI server
  • passlib - Password hashing
  • python-jose - JWT handling
  • requests - HTTP client
  • matplotlib - Plotting

Frontend

  • react - UI framework
  • vite - Build tool
  • axios - HTTP client

See requirements.txt for full dependencies.

πŸ”„ Data Flow

News Source
    ↓
Feed Parser (feedparser)
    ↓
NLP Pipeline (NER, Event Extraction, Sentiment)
    ↓
Knowledge Graph Construction
    ↓
Market Impact Analysis
    ↓
Signal Generation
    ↓
Dashboard Visualization
    ↓
User

πŸ“ Configuration

Edit backend/config.py to customize:

  • Database path
  • API port and host
  • News sources
  • Model parameters
  • Update frequency

πŸ“„ License

This project is licensed under the MIT License.

About

A rule-based financial news intelligence system that automatically ingests news from RSS feeds, extracts named entities and financial events using NLP, performs aspect-based sentiment analysis across six financial dimensions, constructs a knowledge graph of entity relationships, and generates explainable Buy/Sell/Hold trading signals.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages