FinAgent Pro is a sophisticated AI-powered agent designed to perform financial analysis of U.S. companies. By leveraging a multi-step, tool-based workflow orchestrated by LangGraph, this agent can retrieve SEC filings, calculate technical stock indicators, and synthesize the information into a concise report. The interactive user interface is built with Streamlit.
- Automated SEC Filing Retrieval: Automatically finds a company's CIK and fetches the latest annual (10-K) or quarterly (10-Q) reports directly from the SEC EDGAR database.
- Technical Indicator Calculation: Gathers historical stock data using
yfinanceand calculates key technical indicators like RSI, MACD, and SMA usingpandas-ta. - Web Content Parsing: Intelligently reads the content of SEC filings from the web for analysis.
- Stateful, Multi-Step Workflow: Utilizes LangGraph to create a robust, sequential chain of actions, ensuring a reliable analysis process.
- Conversational Interface: A simple and intuitive chat interface powered by Streamlit allows users to make requests in natural language.
- Error Handling: The agent is designed to identify and report tool execution errors, providing clear feedback to the user.
FinAgent Pro operates as a stateful agent graph. When a user provides a company name, the agent initiates a sequential workflow managed by LangGraph:
-
Get Company Info
Callsget_company_infoto find the company's CIK and ticker from SEC data. -
Fetch Filings & Stock Data
- Calls
get_latest_sec_filingsto retrieve the most recent 10-K filing (in.txtformat). - Calls
get_stock_datato fetch the last 365 days of price history.
- Calls
-
Process Data
- Sends stock data to
calculate_technical_indicators. - Sends filing URL to
read_webpageto extract text.
- Sends stock data to
-
Synthesize Final Report
The LLM generates a final summary based on the gathered data.
This process includes robust error handling to inform the user about any failed steps.
- Frontend: Streamlit
- AI Orchestration: LangChain, LangGraph
- LLM Provider: OpenRouter (e.g., DeepSeek, GPT-4o, etc.)
- Data Sources:
- SEC EDGAR API
- Yahoo Finance (
yfinance)
- Libraries:
langchain-openai,pandas,pandas-ta,requests,beautifulsoup4
- Python 3.11+
pipandvenv
git clone https://github.com/nam-htran/FinAgent-RAG
cd FinAgent-RAG# macOS/Linux
python3 -m venv venv
source venv/bin/activate
# Windows
python -m venv venv
.env\Scripts\activatepip install -r requirements.txtCopy the example file and update your credentials:
cp .env.example .envEdit .env:
# .env
# Get your key from https://openrouter.ai/keys
OPENROUTER_API_KEY="sk-or-..."
# Required for SEC API access
SEC_USER_AGENT="YourFullName YourEmail@example.com"The SEC requires a valid
User-Agent. Generic agents likepython-requestswill be blocked.
streamlit run app.pyYour browser should now open the app interface.
Once the app is running, type a query in the chat such as:
Analyze the latest annual report for MicrosoftGive me a financial and technical summary for TeslaApple 2024 financial report analysis
The agent will retrieve data, analyze it, and return a summarized report.
- Data Visualization: Add charts with matplotlib or plotly.
- Streaming Responses: Show real-time steps of agent reasoning.
- News Analysis Tool: Include company news with sentiment scoring.
- Advanced Caching: Speed up repeated queries with caching.
- Model Comparison UI: Let users test and compare LLM outputs.