How huayaoai/fingenius works
Project type and purpose
• FinGenius is an open-source, command-line AI-powered financial analysis tool for A-share markets.
• It orchestrates a “Research–Battle” multi-agent architecture: six specialized AI agents collaborate to analyze market data (Research) then engage in a structured debate (Battle) and produce an HTML report.
File structure
• Top level
• main.py – entry point
• config/ – example configuration for LLM API and MCP protocol
• src/ – source code
• report/ – generated HTML templates and assets
• requirements.txt, LICENSE, README.md
• src/
• agent/ – BaseAgent, ReActAgent, ToolCallAgent, MCPAgent, and six concrete agents (sentiment, risk_control, hot_money, technical_analysis, chip_analysis, big_deal_analysis, report)
• environment/ – BaseEnvironment, ResearchEnvironment, BattleEnvironment, BattleState, EnvironmentFactory
• mcp/ – MCP servers (battle_server, sentiment_server, risk_control_server, hot_money_server, technical_analysis_server, server.py)
• prompt/ – system and next-step prompts for each agent
• tool/ – Tool abstraction and concrete tools (LLM calls, HTML generation, web/financial search, text-to-speech)
• ollama_client.py – wrapper for local LLM hosting
• llm.py, logger.py, schema.py, exceptions.py, console.py
• utils/ – report manager and cleanup scripts
README for additional insights
• Describes twin-environment flow:
1. ResearchEnvironment: parallel/sequential deep analysis by 6 professional agents, each can invoke tools via MCP protocol.
2. BattleEnvironment: structured multi-round debate where agents speak in sequence, vote, and reach consensus.
Essential elements to capture
• Entry point (main.py → EnvironmentFactory)
• Dual-environment sequence (Research → Battle)
• Agent hierarchy and tool invocation flow
• MCP protocol servers as separate processes
• Report generation path