An adaptation of virattt's hedge-fund-agent-team, modified to analyze Brazilian market stocks using BRAPI API. The project implements a multi-agent system where each agent specializes in different aspects of financial analysis.
-
Orquestra.py: Main orchestration file that:
- Configures and manages the agent team
- Defines agent roles and behaviors
- Handles the workflow between agents
- Processes user queries and generates final analysis
-
tools.py: Contains all BRAPI API tool implementations:
- Financial statement tools (income statements, balance sheets)
- Market data tools (quotes, listings)
- Analysis tools (key statistics, financial data)
- Economic indicators (inflation, prime rate)
-
prettyprint.py: Handles output formatting:
- Rich text formatting for terminal output
- Custom styling for different message types
- Organized display of analysis results
-
brapi_wrapper.py: API wrapper interface:
- Imports tools from tools.py
- Provides high-level access to BRAPI endpoints
-
Multi-Agent Analysis:
- Fundamental Analyst: Financial statements and company health
- Valuation Analyst: Market data and valuation ratios
- Price Analyst: Price action and trends
-
BRAPI Integration:
- Real-time market data
- Historical financial statements
- Company statistics and metrics
-
Rich Output Formatting:
- Color-coded analysis sections
- Clear visual hierarchy
- Organized data presentation
graph TD
A[Start] --> B[Supervisor Router]
B --> C{Route Query}
C -->|Fundamental Analysis| D[Fundamental Analyst]
C -->|Valuation Analysis| E[Valuation Analyst]
C -->|Price Analysis| F[Price Analyst]
D -->|Uses Tools| D1[get_balance_sheet_history<br/>get_income_statements<br/>get_balance_sheet_history_quarterly<br/>get_income_statement_history_quarterly]
E -->|Uses Tools| E1[get_default_key_statistics<br/>get_financial_data]
F -->|Uses Tools| F1[get_quote]
D -->|Next Step| G{Get Next Step}
E -->|Next Step| G
F -->|Next Step| G
G -->|More Analysts| C
G -->|All Complete| H[Final Summary Agent]
H -->|Portfolio Manager| I[End]
subgraph "Agent State"
J[messages]
K[selected_analysts]
L[current_analyst_idx]
M[error_count]
N[completed_analyses]
end
- Python 3.8+
- BRAPI API Key
- Required packages:
langchain langgraph rich pandas requests python-dotenv
- Clone the repository:
git clone <https://github.com/PedroDnT/HedgeFund>
cd <repository-directory>
- Install dependencies:
pip install -r requirements.txt
- Configure environment variables:
Run the main orchestration script:
python Orquestra.py
Example query: "What is PETR4's current financial health and how has its price been performing?"
- User query → Orquestra.py
- Query routed to appropriate analysts
- Analysts use tools.py to fetch data via BRAPI
- Analysis results formatted by prettyprint.py
- Final comprehensive analysis presented to user
MIT License