A Python-based financial news analysis tool that fetches real-time financial news and provides sentiment analysis, market impact assessment, and key insights extraction.
- Real-time Financial News: Fetches latest financial news using the Currents API
- Smart Filtering: Automatically identifies and filters finance-related news
- Sentiment Analysis: Dual-mode sentiment analysis using:
- OpenAI GPT-3.5 for advanced analysis
- Rule-based fallback system for reliability
- Entity Extraction: Identifies key financial entities including:
- Companies
- Sectors
- Financial instruments
- Metrics Analysis: Extracts and analyzes financial metrics from news content
- Comprehensive Reporting: Generates detailed analysis reports including:
- Overall sentiment score
- Market impact assessment
- Confidence levels
- Critical quotes
- Market implications
- Python 3.8+
- Currents API key
- OpenAI API key (optional, falls back to rule-based analysis if not provided)
- Clone the repository:
git clone https://github.com/yourusername/financial-news-analyzer.git
cd financial-news-analyzer
- Install required packages:
pip install -r requirements.txt
- Create a
.env
file in the project root:
NEWS_API_KEY=your_currents_api_key
OPENAI_API_KEY=your_openai_api_key # Optional
Run the analyzer:
python main.py
The program will:
- Fetch the latest financial news
- Filter for finance-related articles
- Perform sentiment analysis
- Generate detailed reports for each article
financial-news-analyzer/
├── config.py # Configuration settings
├── main.py # Main application entry point
├── models/
│ └── article.py # Data models
├── services/
│ ├── news_service.py # News fetching service
│ └── analysis/
│ ├── entity_extractor.py # Entity extraction
│ ├── metrics_extractor.py # Financial metrics extraction
│ └── sentiment_analyzer.py # Sentiment analysis
└── utils/
├── date_utils.py # Date handling utilities
└── text_processor.py # Text processing utilities
Key configuration options in config.py
:
MAX_ARTICLES
: Maximum number of articles to analyzeSENTIMENT_THRESHOLD
: Threshold values for sentiment classificationOPENAI_MODEL
: OpenAI model selection- API configuration settings
The system includes robust error handling:
- Graceful fallback to rule-based analysis if OpenAI is unavailable
- Comprehensive logging for debugging
- Input validation and error reporting
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Currents API for financial news data
- OpenAI for advanced text analysis capabilities