TradingAgents-CN Multi-Agent Trading Framework

repository·main·Indexed 12 days ago

https://github.com/hsliuping/tradingagents-cn

A Chinese-enhanced multi-agent trading framework for analyzing A-shares, Hong Kong, and US stocks. Built with FastAPI and Vue 3, it features a system of 13 specialized AI agents (Analysts, Researchers, Debaters, Managers, and Traders) and a comprehensive Prompt Template System v1.0.1. Includes a 5-layer stock data architecture with support for AKShare and BaoStock data sources and a standardized MongoDB data model.

Tokens
365.5K
Snippets
950
Records
1.4K
Agent score
99%

What's inside TradingAgents-CN

  1. Overview of TradingAgents-CN

    main

    TradingAgents-CN is a multi-agent and Large Language Model (LLM) based stock analysis learning platform designed for Chinese users. It provides a systematic way to learn how to use multi-agent trading frameworks and AI models for compliant stock research and strategy experimentation.

    Key Capabilities:

    • Market Support: Analysis for A-shares, Hong Kong stocks, and US stocks.
    • LLM Integration: Native OpenAI support, full Google AI integration, and support for multiple LLM providers (including VolcEngine Ark/火山方舟).
    • Deployment: Supports Docker containerization (amd64 and arm64) and local source code installation.
    • Analysis Tools: Technical indicator calculation, fundamental analysis (PE, PB, etc.), and professional report exporting (Markdown, Word, PDF).

    Disclaimer: This tool provides data analysis only and does not constitute investment advice. It is intended for learning and research purposes and does not provide real-time trading instructions.

  2. Overview of Data Quality and System Stability Improvements (Nov 2025)

    main

    Between November 13 and 14, 2025, TradingAgents-CN implemented significant updates focused on data integrity, screening performance, and system reliability. Key improvements include:

    • Data Quality: Fixed issues with volume, turnover, and trade date displays.
    • Screening Performance: Optimized field types and enabled database-level optimized screening, resulting in a 10x+ performance increase.
    • Synchronization Mechanism: Resolved trade_date missing issues, implemented failure rollback mechanisms, and addressed API rate-limiting cascades.
    • Deployment Simplification: The application now automatically creates views and indexes upon startup, removing the need for manual script execution.
    • Bug Fixes: Resolved issues related to logger imports, MongoDB connections, and circular imports.
  3. Overview of Data Source Integration (v0.1.6)

    main

    TradingAgents-CN integrates multiple financial data sources with a specific focus on the Chinese A-share market to provide agents with comprehensive, accurate, and real-time market information.

    As of version 0.1.6, the system uses a hybrid strategy for data retrieval:

    • Tushare: Primary source for historical data.
    • AKShare: Used for real-time data.
    • Unified Interface: The system provides transparent switching between these sources, maintaining backward compatibility so existing API calls do not need to change.
  4. Overview of Compliance and Stability Updates (2025-10-27)

    main

    The October 27, 2025 update focused on improving system stability, user experience, and cross-platform compatibility. Key improvements include:

    • Compliance Optimization: Refinement of compliance-related terminology and expressions.
    • Error Handling: Improved error notification mechanisms.
    • Logging System: Fixes and enhancements to the logging infrastructure.
    • Architecture Support: Added support for ARM architectures.

    These changes were implemented across 12 commits to ensure a more robust and compliant environment for trading agents.

  5. Overview of Windows Installer and Fundamental Analysis Enhancements

    main

    Between November 1st and November 4th, 2025, TradingAgents-CN introduced significant updates focused on cross-platform deployment and data integrity. Key improvements include:

    • Windows Portable (Green) Version: A portable package that allows for one-click startup without a formal installation process.
    • Windows Installer: A standardized installation flow that supports setting the application to launch automatically on system startup.
    • Fundamental Analysis Enhancements: Added total market capitalization data to improve valuation metrics.
    • Port Conflict Detection: Automatic detection and cleanup of processes occupying required ports.
    • LLM Configuration Fixes: Resolved issues where API Key updates were not taking effect.
    • Multi-platform Packaging: Support for Windows, Linux, and macOS packaging.
  6. Overview of US Stock Data Source and Cache System Upgrade

    main

    As of the November 11, 2025 update, the US stock data source architecture and caching system have been overhauled to improve flexibility and performance.

    Key Improvements:

    • Multi-Source Support: The system now supports multiple data providers including yfinance, Alpha Vantage, and Finnhub.
    • Dynamic Configuration: Data source configurations and priorities are managed via database collections (datasource_groupings and system_configs).
    • Three-Layer Caching: A default integrated caching strategy using Redis, MongoDB, and File is enabled to accelerate data access.
    • Enhanced Data Management: Improved database import/export functionality, including fixes for collection naming, date format conversions, and parameter passing.
  7. Overview of the Message Data System features

    main

    The Message Data System provides a unified architecture for managing social media and internal financial messages. Key capabilities include:

    • Crawler System: Supports social media (Weibo, Douyin) and internal messages (research reports, analyst notes) via a unified scheduler.
    • Intelligent Processing: Automatic sentiment analysis (positive/negative/neutral), importance assessment (high/medium/low), and keyword extraction.
    • High Performance: Dual-collection storage with 24 optimized indexes for millisecond-level queries and full-text search support for Chinese content.
    • API & Production Ready: 30+ RESTful endpoints, standard response formats, error handling, and performance monitoring.
  8. Overview of the scripts directory structure

    main

    The scripts/ directory is organized by functional categories to assist with setup, validation, maintenance, development, deployment, containerization, and Git workflows.

    DirectoryPurposeExample Script
    setup/Environment configuration and initializationsetup_databases.py
    validation/Verification and checksverify_gitignore.py
    maintenance/Maintenance and managementbranch_manager.py
    development/Development assistanceprepare_upstream_contribution.py
    deployment/Deployment and releasecreate_github_release.py
    docker/Container managementstart_docker_services.bat
    git/Git toolsupstream_git_workflow.sh
  9. Overview of the Prompt Template System v1.0.1

    main

    The Prompt Template System v1.0.1 is an enhanced framework designed to manage and execute prompt templates for 13 specialized trading agents. It extends the base v1.0 functionality by adding persistent storage, user management, analysis preferences, and historical tracking.

    Core Components

    • 13 Agents: Categorized into Analysts (4), Researchers (2), Debaters (3), Managers (2), and Traders (1).
    • 31 Templates: Includes 2-3 preset templates per agent, supporting user customization and version management.
    • Analysis Preferences: Users can select from three modes: Aggressive (high risk/reward), Neutral (balanced), or Conservative (low risk/stable).
    • Key Features: Database storage (5 collections), User management, Template management, History tracking, Versioning, 27 Web API endpoints, and Frontend UI integration.
  10. Overview of the QuotesIngestionService

    main

    The QuotesIngestionService is a scheduled task responsible for fetching real-time market data for the entire market (5000+ stocks) from external data sources and storing it in the MongoDB market_quotes collection.

    Key Features

    • Scheduling Frequency: Executes every 30 seconds by default (configurable).
    • Data Source Fallback: Automatically switches between sources based on priority: Tushare $\rightarrow$ AKShare $\rightarrow$ BaoStock.
    • Trading Session Awareness: Automatically detects trading hours (09:30-11:30, 13:00-15:00) and skips collection during off-hours unless backfilling is enabled.
    • Cold Start Support: Automatically fills in the latest closing snapshots upon startup if the database is empty or data is stale.

    File Locations

    • Implementation: app/services/quotes_ingestion_service.py
    • Task Scheduling: app/main.py
    • Configuration: app/core/config.py
  11. Overview of Tushare financial data capabilities

    main

    The Tushare integration provides a standardized and reliable way to access fundamental financial data for quantitative analysis and investment research.

    Supported Data Types

    • Income Statement (利润表): Detailed revenue and expense data.
    • Balance Sheet (资产负债表): Assets, liabilities, and equity information.
    • Cash Flow Statement (现金流量表): Inflow and outflow of cash.
    • Financial Indicators (财务指标): Calculated ratios and key performance metrics.

    Key Features

    • Standardization: Unified data formats and field mapping across different reports.
    • Reliability: Built-in error handling and retry mechanisms for API calls.
    • Efficiency: Optimized API calling patterns and batch processing capabilities.
    • Flexibility: Supports various query methods and parameter configurations for multi-period trend analysis.
  12. What is TradingAgents-CN?

    main

    TradingAgents-CN is an AI-powered stock analysis learning platform that uses a multi-agent collaboration mechanism to help users understand stock analysis methods. It is specifically optimized for the Chinese A-share market and is an open-source project designed as a learning tool rather than a source of investment advice.

    Key Features:

    • Multi-agent collaborative analysis
    • Optimized for China A-shares
    • Open-source and self-deployable
    • Disclaimer: It is a learning tool and does NOT provide investment advice, guaranteed returns, or professional consulting.