A sophisticated financial sentiment analysis AI-agent that fetches real-time market news, analyzes sentiment using FinBERT, and provides AI-powered summaries to help with investment decisions.
- Real-time News Fetching: Automatically retrieves latest trending financial news from multiple sources
- Advanced Sentiment Analysis: Uses FinBERT (Financial BERT) model for accurate financial sentiment scoring and embedding
- Semantic Search: FAISS-powered similarity search to find relevant articles
- AI-Powered Summaries: OpenAI GPT integration for intelligent market sentiment summaries
- Interactive Queries: Ask specific questions about market sentiment and get tailored insights
- Python 3.11+
- Transformers & FinBERT: Financial sentiment analysis
- FAISS: Vector similarity search for semantic matching
- OpenAI GPT: Advanced natural language summarization
- Sentence Transformers: Text embedding generation
- pandas: Data manipulation and analysis
- News API: Real-time news data ingestion
- Python 3.11 or higher
- OpenAI API key
- News API key
git clone https://github.com/skondaparthi/FinSent-Agent.git
cd FinSent-Agentpython3 -m venv finsentenv
source finsentenv/bin/activate # On macOS/Linux
# or
finsentenv\Scripts\activate # On Windowspip install -r requirements.txtCreate a .env file in the root directory:
OPENAI_API_KEY=your_openai_api_key_here
NEWS_API_KEY=your_news_api_key_herepython main.pyFinSent-Agent/
├── main.py # Main application entry point
├── requirements.txt # Python dependencies
├── .env # Environment variables (create this)
├── Finsent.ipynb # Google Colab playground (experimental notebook)
├── ingest/
│ └── news_api.py # News data ingestion module using NewsAPI
├── models/
│ ├── finbert_model.py # FinBERT sentiment analysis
│ ├── faiss_model.py # FAISS similarity search
│ └── llm_model.py # OpenAI integration
└── README.md # This file
- OpenAI API Key: Get your OpenAI key at OpenAI Platform
- News API Key: Get NewsAPI key at NewsAPI.org
Add these to your .env file:
OPENAI_API_KEY=sk-your-actual-openai-key
NEWS_API_KEY=your-actual-news-api-keyRun the script and enter your query when prompted:
Enter a query to summarize market news: Tesla stock analysis
- "Should I invest in Tesla right now?"
- "AI market sentiment analysis"
- "Cryptocurrency market trends"
- "Tech stock outlook"
- "Federal Reserve interest rate impact"
- News Ingestion: Fetches latest financial news from News API
- Sentiment Scoring: FinBERT analyzes each article for financial sentiment
- Embedding Generation: Creates vector embeddings for semantic search
- FAISS Indexing: Builds searchable index for similarity matching efficiently
- Query Processing: Finds articles relevant to your specific query
- AI Summarization: OpenAI GPT generates comprehensive market insights
Summary of Market News:
The current market sentiment surrounding Tesla appears predominantly positive, despite some underlying concerns. Recent headlines highlight optimism about potential investment returns, with Elon Musk suggesting that a $150,000 investment could lead to millionaire status. Additionally, there's a recognition that Tesla is evolving beyond just a car manufacturer, which could open up new revenue streams. However, analysts express caution regarding dwindling sales and critical revenue sources, indicating a mixed outlook. Given this context, investing in Tesla could be worthwhile for those who believe in its long-term vision and innovations, but potential investors should remain aware of the challenges the company faces in the short term.
- Semantic Search: Find articles similar to your specific interests
- Multi-source Analysis: Aggregates sentiment from diverse news sources
- Customizable Analysis: Adjust the number of articles analyzed (k parameter)
- Real-time Processing: Always uses the latest available market news
- Missing API Keys: Ensure your
.envfile contains valid API keys - Package Conflicts: Use a fresh virtual environment
- FAISS Installation: On some systems, use
pip install faiss-cpu==1.10.0(M-Series Macs) - Tokenizer Warnings: These are handled automatically in the code
- ImportError: Run
pip install -r requirements.txtin your virtual environment - API Errors: Check your API keys and quotas
- No Articles Found: Try broader search terms or check News API status, or change date so that it is within one month of current date (NewsAPI limitation)
- Fork the repository
- Create a 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.
- FinBERT: For financial sentiment analysis capabilities
- FAISS: For efficient similarity search
- OpenAI: For advanced text generation
- News API: For real-time news data
If you encounter any issues or have questions:
- Check the troubleshooting section above
- Open an issue on GitHub
- Review the documentation for each component
Happy Trading!