How dataguru9/akasei-hedgefund-agent works
Project Type and Purpose
• This is a Python-based, modular, command-line “backend” application (no GUI/front-end) that simulates an AI-driven hedge fund.
• It fetches market data, runs multiple AI agents (via LLMs and traditional analytics), manages risk, constructs portfolios, and optionally backtests strategies.
Major Components
A. External Services
• Financial Data API (financialdatasets.ai)
• LLM Providers (OpenAI, Groq, Anthropic, plus local Ollama)
B. Data Layer (src/data)
• Cache manager (cache.py)
• Domain models (models.py)
C. LLM Abstraction Layer
• OpenAI/Groq API wrappers (src/utils/ollama.py, src/ollama_utils.py)
• llm models definitions (src/llm/models.py)
D. Agent Modules (src/agents)
1. Named Strategist Agents (ben_graham.py, bill_ackman.py, … warren_buffett.py)
2. Specialized Analysis Agents (valuation.py, fundamentals.py, sentiment.py, technicals.py)
3. Risk Manager (risk_manager.py)
4. Portfolio Manager (portfolio_manager.py)
E. Orchestration & Core Logic
• Main entry point (src/main.py) – live mode
• Backtester (src/backtester.py) – historical simulation
• State machine / workflow graph (src/graph/state.py)
F. Utility Modules (src/utils)
• Data fetching and API tools (src/tools/api.py)
G. Output/Visualization
• Console logs (–show-reasoning)
Relationships and Data Flows
1. Orchestrator (main.py/backtester.py) invokes Data Layer → fetches raw market data via API tools → caching
2. Preprocessed data objects flow into the Graph/State manager → dispatches to each analysis agent
3. Each Agent requests LLMs (via LLM Abstraction) and/or applies rule-based logic → produces signals
4. Signals feed into Risk Manager → position sizing
5. Risk-adjusted signals feed into Portfolio Manager → final orders
6. Orders → trade simulation / backtester → performance results
7. Utility modules handle logging, progress bars, and chart generation
Architectural Patterns and Principles
• Modular pipeline: clearly separated layers for data, analysis, orchestration, and output
• Dependency inversion: agents depend on LLM abstraction rather than raw API calls
• Single responsibility: each agent module implements one style of analysis
• Extensibility: new agents can be dropped into src/agents and wired via the state graph