Skip to content

PedroDnT/HedgeFund-AgentsOrch

Repository files navigation

Hedge Fund Agent Team for Brazilian Markets

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.

Project Structure

  • 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

Key Features

  • 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

Flow

  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
Loading

Requirements

  • Python 3.8+
  • BRAPI API Key
  • Required packages:
    langchain
    langgraph
    rich
    pandas
    requests
    python-dotenv

Installation

  1. Clone the repository:
git clone <https://github.com/PedroDnT/HedgeFund>
cd <repository-directory>
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure environment variables:

Usage

Run the main orchestration script:

python Orquestra.py

Example query: "What is PETR4's current financial health and how has its price been performing?"

Data Flow

  1. User query → Orquestra.py
  2. Query routed to appropriate analysts
  3. Analysts use tools.py to fetch data via BRAPI
  4. Analysis results formatted by prettyprint.py
  5. Final comprehensive analysis presented to user

License

MIT License

Acknowledgments

  • Original concept by virattt
  • Powered by BRAPI for Brazilian market data
  • Built with LangGraph for agent orchestration

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published