Skip to main content

tradingagents-astock-multi-agent-framework

A-share multi-agent investment research framework with 7 AI analysts, bull/bear debate, and risk assessment adapted for Chinese stock market

Ir para a instalação

Informações da origem

Repositório
reason-machines/ai-agent-skills
Última atividade na origem
25 de maio de 2026 às 21:59
Idioma detectado do SKILL.md
inglês
Estrelas
1
Forks
1

Opções de instalação

Por padrão, está selecionado o prompt que primeiro revisa a origem. Você pode mudar para um comando direto ou baixar uma cópia local.

Revise os arquivos de origem

Leia o SKILL.md e os arquivos complementares exibidos pelo SkillsMP antes de decidir se vai instalar.

Exibindo SKILL.md

SKILL.md
Instruções da origem · Visualização somente leitura
name
tradingagents-astock-multi-agent-framework
description
A-share multi-agent investment research framework with 7 AI analysts, bull/bear debate, and risk assessment adapted for Chinese stock market
triggers
["analyze Chinese stock with AI agents","set up A-share trading analysis framework","run multi-agent stock research for A-shares","configure TradingAgents for Chinese market","analyze stock with 7 AI analysts","implement bull bear debate for stock analysis","use mootdx for A-share data","create trading decision pipeline with LLM agents"]
# TradingAgents-Astock Multi-Agent Framework > Skill by [ara.so](https://ara.so) — AI Agent Skills collection. ## Overview TradingAgents-Astock is a multi-agent investment research framework specifically adapted for Chinese A-share markets. It orchestrates 7 specialized AI analyst agents that generate research reports, engage in bull/bear debates, perform risk assessment, and produce trading decisions. The framework handles A-share specific constraints (T+1 settlement, price limits, minimum lots) and uses free Chinese data sources (mootdx, EastMoney, Sina, THS) instead of Western APIs. **Key Features:** - 7 specialized analysts (Market, Social, News, Fundamentals, Policy, Hot Money, Lockup) - Bull vs Bear research debate system - 3-way risk assessment (Aggressive, Conservative, Neutral) - A-share trading constraints (T+1, 涨跌停, minimum lots, ST rules) - Dual LLM architecture (quick_think + deep_think) - Web UI with real-time progress tracking - Chinese output with English internal reasoning ## Installation ```bash # Clone the repository git clone https://github.com/simonlin1212/tradingagents-astock.git cd tradingagents-astock # Install base package (Python >= 3.10) pip install -e . # Optional: Install with Google Gemini support pip install -e ".[google]" ``` ## Configuration ### LLM Provider Setup Create a `.env` file in the project root with your chosen LLM provider: ```bash # MiniMax (Recommended for China, cost-effective) MINIMAX_API_KEY=sk-your-key-here # DeepSeek DEEPSEEK_API_KEY=sk-your-key-here # Zhipu GLM ZHIPU_API_KEY=your-key-here # Alibaba Qwen DASHSCOPE_API_KEY=sk-your-key-here # OpenAI OPENAI_API_KEY=sk-your-key-here # Anthropic ANTHROPIC_API_KEY=sk-ant-your-key-here # Kimi (uses Anthropic-compatible API) ANTHROPIC_AUTH_TOKEN=your-kimi-token ``` ### Graph Configuration Object ```python config = { "llm_provider": "minimax", # Provider: minimax, deepseek, zhipu, qwen, openai, anthropic, google, xai, ollama "deep_think_llm": "MiniMax-M2.7", # Model for Research Manager & Portfolio Manager "quick_think_llm": "MiniMax-M2.7-highspeed", # Model for analysts, researchers, traders "output_language": "Chinese", # Final report language (Chinese/English) "backend_url": None, # Optional: Custom API endpoint "max_debate_rounds": 3, # Bull/Bear debate iterations "enable_policy_analyst": True, # A-share specific analysts "enable_hotmoney_analyst": True, "enable_lockup_analyst": True, } ``` ## Core API Usage ### Basic Analysis ```python from tradingagents.graph.trading_graph import TradingAgentsGraph # Initialize with MiniMax config = { "llm_provider": "minimax", "deep_think_llm": "MiniMax-M2.7", "quick_think_llm": "MiniMax-M2.7-highspeed", "output_language": "Chinese", } ta = TradingAgentsGraph(debug=True, config=config) # Run analysis for stock 688017 on 2026-05-12 final_state, decision = ta.propagate("688017", "2026-05-12") # Access decision print(f"Signal: {decision['signal']}") # BUY, HOLD, or SELL print(f"Confidence: {decision['confidence']}") # 0-100 print(f"Position: {decision['position_size']}") # Suggested position size print(f"Reasoning: {decision['reasoning']}") ``` ### Using DeepSeek ```python config = { "llm_provider": "deepseek", "deep_think_llm": "deepseek-chat", "quick_think_llm": "deepseek-chat", "output_language": "Chinese", } ta = TradingAgentsGraph(config=config) final_state, decision = ta.propagate("600519", "2026-05-15") ``` ### Using Anthropic with Kimi Backend ```python config = { "llm_provider": "anthropic", "deep_think_llm": "claude-sonnet-4-6", "quick_think_llm": "claude-sonnet-4-6", "backend_url": "https://api.kimi.com/coding/", "output_language": "Chinese", } ta = TradingAgentsGraph(config=config) final_state, decision = ta.propagate("000001", "2026-05-20") ``` ### Accessing Individual Analyst Reports ```python final_state, decision = ta.propagate("688017", "2026-05-12") # Access 7 analyst reports market_report = final_state["market_analyst_report"] social_report = final_state["social_analyst_report"] news_report = final_state["news_analyst_report"] fundamentals_report = final_state["fundamentals_analyst_report"] policy_report = final_state["policy_analyst_report"] hotmoney_report = final_state["hotmoney_analyst_report"] lockup_report = final_state["lockup_analyst_report"] # Access debate and risk assessment bull_research = final_state["bull_researcher_report"] bear_research = final_state["bear_researcher_report"] risk_assessment = final_state["risk_assessment"] trading_plan = final_state["trading_plan"] ``` ## CLI Commands ### Interactive Mode ```bash # Launch interactive CLI tradingagents # CLI will prompt for: # - Stock code (e.g., 688017, 600519) # - Analysis date (YYYY-MM-DD) # - LLM provider selection ``` ### Direct Execution ```bash # Analyze with specific parameters tradingagents --stock 688017 --date 2026-05-12 --provider minimax # Use different models tradingagents --stock 600519 --date 2026-05-15 \ --provider deepseek \ --deep-model deepseek-chat \ --quick-model deepseek-chat # Enable debug output tradingagents --stock 000001 --date 2026-05-20 --debug ``` ### Web UI ```bash # Launch Streamlit web interface tradingagents-web # Alternative streamlit run web/app.py # Access at http://localhost:8501 ``` ## Data Source Integration ### Available Data Tools The framework provides these tools to analysts (all free, no API keys needed): ```python # Market data (OHLCV, indicators) get_stock_data(ticker, start_date, end_date) get_indicators(ticker, start_date, end_date) # Fundamental data get_fundamentals(ticker) get_balance_sheet(ticker) get_cashflow(ticker) get_income_statement(ticker) # News and sentiment get_news(ticker, start_date, end_date) get_global_news(start_date, end_date) # A-share specific get_insider_transactions(ticker) # Lockup releases, insider trading # Dragon-Tiger list data available via get_news ``` ### Data Provider Mapping | Data Type | Provider | Protocol | |-----------|----------|----------| | OHLCV K-lines | mootdx | TCP 7709 | | PE/PB/Market Cap | Tencent Finance | HTTP | | Dragon-Tiger List | EastMoney | HTTP | | Lockup Schedule | EastMoney | HTTP | | Financial Statements | Sina Finance | HTTP | | EPS Consensus | THS (10jqka) | HTTP | | News Feed | CLS.cn | HTTP | | Sector Classification | Baidu Finance | HTTP | ## Agent Pipeline Architecture ### 12-Stage Execution Flow ```python # Stage 1-7: Analyst Reports stages = [ "market_analyst", # Technical analysis "social_analyst", # Social sentiment "news_analyst", # News and events "fundamentals_analyst", # Financial statements "policy_analyst", # Regulatory policy (A-share specific) "hotmoney_analyst", # Dragon-Tiger list tracking (A-share specific) "lockup_analyst", # Share lockup monitoring (A-share specific) ] # Stage 8: Quality Gate # Checks if analysts provided sufficient data # Stage 9-10: Bull/Bear Debate # Bull and Bear researchers debate up to N rounds # Stage 11: Research Manager # Deep-think LLM synthesizes debate into investment plan # Stage 12: Trader + Risk Assessment # Trader proposes execution plan # 3 risk debaters (Aggressive, Conservative, Neutral) assess # Stage 13: Portfolio Manager # Deep-think LLM makes final BUY/HOLD/SELL decision ``` ### Custom Analyst Configuration ```python # Disable A-share specific analysts config = { "llm_provider": "minimax", "deep_think_llm": "MiniMax-M2.7", "quick_think_llm": "MiniMax-M2.7-highspeed", "output_language": "Chinese", "enable_policy_analyst": False, "enable_hotmoney_analyst": False, "enable_lockup_analyst": False, } ta = TradingAgentsGraph(config=config) ``` ## A-Share Trading Constraints The framework automatically applies A-share market rules: ```python # T+1 Settlement # Cannot sell shares bought today # Price Limits # ST stocks: ±5% # Regular stocks: ±10% (or ±20% for ChiNext/STAR) # Minimum Lot Size # 100 shares (1 lot) # Must trade in multiples of 100 # Trading Hours # Morning: 09:30-11:30 # Afternoon: 13:00-15:00 # Call auction: 09:15-09:25, 14:57-15:00 ``` These constraints are built into the Trader agent's decision logic. ## Common Patterns ### Batch Analysis ```python from tradingagents.graph.trading_graph import TradingAgentsGraph from datetime import datetime, timedelta config = { "llm_provider": "minimax", "deep_think_llm": "MiniMax-M2.7", "quick_think_llm": "MiniMax-M2.7-highspeed", "output_language": "Chinese", } ta = TradingAgentsGraph(config=config) # Analyze portfolio of stocks stocks = ["600519", "000858", "600036", "601318"] date = "2026-05-15" results = {} for ticker in stocks: try: final_state, decision = ta.propagate(ticker, date) results[ticker] = decision print(f"{ticker}: {decision['signal']} (confidence: {decision['confidence']})") except Exception as e: print(f"Error analyzing {ticker}: {e}") continue ``` ### Time Series Analysis ```python from datetime import datetime, timedelta ta = TradingAgentsGraph(config=config) ticker = "688017" # Analyze over 5 trading days base_date = datetime(2026, 5, 10) signals = [] for i in range(5): analysis_date = (base_date + timedelta(days=i)).strftime("%Y-%m-%d") try: final_state, decision = ta.propagate(ticker, analysis_date) signals.append({ "date": analysis_date, "signal": decision["signal"], "confidence": decision["confidence"], }) except Exception as e: print(f"Error on {analysis_date}: {e}") continue # Track signal consistency print(f"Signal history for {ticker}:") for s in signals: print(f"{s['date']}: {s['signal']} ({s['confidence']}%)") ``` ### Custom LLM Backend ```python # Use local Ollama instance config = { "llm_provider": "ollama", "deep_think_llm": "qwen2.5:32b", "quick_think_llm": "qwen2.5:14b", "backend_url": "http://localhost:11434", "output_language": "Chinese", } ta = TradingAgentsGraph(config=config) final_state, decision = ta.propagate("600519", "2026-05-15") ``` ### Extracting Structured Data ```python final_state, decision = ta.propagate("688017", "2026-05-12") # Extract key metrics from analyst reports def extract_pe_ratio(fundamentals_report): # Parse PE from report text import re match = re.search(r'PE.*?(\d+\.\d+)', fundamentals_report) return float(match.group(1)) if match else None def extract_lockup_events(lockup_report): # Parse lockup schedule events = [] lines = lockup_report.split('\n') for line in lines: if '解禁' in line: events.append(line.strip()) return events pe_ratio = extract_pe_ratio(final_state["fundamentals_analyst_report"]) lockup_events = extract_lockup_events(final_state["lockup_analyst_report"]) print(f"PE Ratio: {pe_ratio}") print(f"Upcoming lockups: {lockup_events}") ```
Ver no GitHub
Este SKILL.md e muito grande, entao o SkillsMP mostra aqui apenas a primeira secao. Ver no GitHub