Community研究与数据分析github.com

GrantDeng/trading-analysis-skill

Simulate the TradingAgents multi-role equity analysis workflow with subagents.

兼容平台~Claude Code~Codex CLI~Cursor
npx add-skill GrantDeng/trading-analysis-skill

name: tradingagents-role-simulator description: Simulate the TradingAgents multi-role equity analysis workflow with subagents. Use when the user wants a Chinese stock analysis report generated by analyst, researcher, trader, risk, and portfolio-manager roles that mirror this repository's business protocol without directly running the LangGraph pipeline.

TradingAgents Role Simulator

Use this skill when the user wants to simulate the TradingAgents workflow itself, not merely explain the codebase. This skill reproduces the repository's stable business protocol with subagents and a coordinator:

  • 4 analysts produce specialist reports
  • bull and bear researchers debate for a fixed maximum-depth sequence
  • a research manager writes the investment plan
  • a trader turns that plan into a transaction proposal
  • aggressive, conservative, and neutral risk roles debate for a fixed maximum-depth sequence
  • a portfolio manager produces one final rating and execution summary

Do not call TradingAgentsGraph or the CLI as the primary path. The point of this skill is to reproduce the role protocol with subagents, not the LangGraph runtime.

Use This Skill For

  • Requests to "simulate the TradingAgents roles"
  • Requests to generate a TradingAgents-style report for a ticker and date
  • Requests to reproduce the repository's analysis chain with subagents
  • Requests to compare or audit how different roles contribute to the final decision

Do not use this skill for:

  • Simple codebase walkthroughs with no report generation
  • Requests that explicitly require running the repository pipeline end to end

Required Inputs

Collect or infer these inputs before spawning subagents:

  • ticker
  • analysis_date: default to the current local date if the user does not provide one
  • language: default zh-CN
  • output_root: default to the current workspace's reports/ directory

Preserve the exact ticker everywhere, including exchange suffixes such as .HK, .TO, .T, .L.

The coordinator must not expose configurable depth or data-mode switches for this skill. This skill always runs with:

  • maximum-depth research debate
  • maximum-depth risk debate
  • latest live evidence only

Maximum-depth semantics are fixed and must not be inferred or shortened:

  • research debate: exactly 5 bull/bear exchanges after the opening bull turn, alternating one turn per side until 5 rounds are completed
  • risk debate: exactly 5 full cycles of Aggressive -> Conservative -> Neutral

Output Persistence

Unless the user explicitly requests another destination, persist the final result package under the current workspace's reports/ directory.

Default directory naming:

  • reports/<ticker>_<analysis_date>_skill_test_<timestamp>/

Timestamp should be appended to avoid collisions between repeated runs on the same ticker/date.

Recommended timestamp format:

  • YYYYMMDD_HHMMSS

Recommended package structure:

  • 1_analysts/
  • 2_research/
  • 3_trading/
  • 4_risk/
  • 5_portfolio/
  • complete_report.md

The coordinator should write both:

  • stage-level files for auditability
  • one merged complete_report.md for human review

Model Selection Policy

Do not default every role to the same model. Use role-appropriate model tiers.

Recommended defaults:

  • Analyst roles (Market, Social Sentiment, News, Fundamentals): gpt-5.4 with medium reasoning
  • Debate roles (Bull, Bear, Aggressive, Conservative, Neutral): gpt-5.4 with medium reasoning
  • Synthesis roles (Research Manager, Trader, Portfolio Manager): gpt-5.4 with medium or high reasoning

Escalate only if the task needs it:

  • use gpt-5.4 with high reasoning for the Research Manager, Trader, or Portfolio Manager when the evidence is highly conflicting or the user explicitly wants maximum rigor
  • do not use mini models for role subagents in this skill

The coordinator should prefer consistent gpt-5.4 use across role agents so specialist extraction, debate, and synthesis share the same reasoning floor.

Workflow

1. Prepare a Central Evidence Packet

The coordinator gathers evidence once, then distributes the same packet to role subagents. Do not let each role independently rediscover the full dataset unless the task explicitly requires it.

The coordinator must use latest live evidence only. Historical artifacts and user-provided material may be used only as secondary validation context, never as the primary runtime evidence source.

Define "latest" in this priority order:

  1. newest available primary-source financial disclosure
  2. newest available company-originated event disclosure
  3. newest available credible news and macro context
  4. newest available market or technical context

Every evidence item must carry:

  • metric_name
  • period_end
  • source_date
  • fetch_date
  • source
  • trust_level
  • source_quality_score
  • freshness_score
  • original_currency_or_unit
  • normalized_currency_or_unit

Use this source priority order:

  • Financials: company IR, SEC filings, exchange filings
  • Company events: company IR, official releases
  • News and macro: primary news outlets
  • Market and technical context: third-party aggregators only if primary exchange-style data is unavailable

The evidence packet should contain:

  • instrument block: exact ticker, analysis date, market/exchange if known
  • market block: price action and technical-indicator summary
  • sentiment block: company-specific sentiment and discussion summary
  • news block: company news plus macro/global news summary
  • fundamentals block: financial profile, key metrics, and statement highlights
  • valuation block: minimum valuation anchor, historical context, and sensitivity notes
  • source block: where the evidence came from and its freshness

Before evidence is passed downstream, normalize key numerical items:

  • preserve the original currency and unit
  • define one coordinator-side normalized currency and unit for comparison
  • explicitly label period type such as quarter, FY, TTM, YoY, or QoQ
  • do not compare metrics across periods unless the period type is explicit
  • do not collapse original and normalized numbers into one unlabeled value

Before any subagent is spawned, run an evidence validation pass and classify each item as:

  • trusted: internally consistent, date-stamped, and plausibly sourced
  • questionable: usable with caution because the number, date, unit, or source quality is weaker
  • conflicted: materially inconsistent with another item or not safe to pass downstream as fact

Also produce a short validation summary with:

  • stale or mixed-date items
  • unit mismatches
  • duplicate claims with different numbers
  • malformed action labels such as HOLD-1

Also produce a conflict_resolution_summary before any role is spawned:

  • disputed metric or claim
  • candidate values
  • chosen value or chosen non-decision
  • why that treatment was selected
  • whether the issue remains unresolved downstream

Mixed-date evidence is allowed only if:

  • each item is explicitly date-stamped
  • each item is explicitly labeled trusted or questionable
  • no mixed-date item is presented downstream as if it were a same-day snapshot

Third-party market or technical data must be labeled questionable whenever primary exchange-style data is unavailable.

Evidence weighting must use both:

  • source_quality_score
  • freshness_score

Coordinator guidance:

  • high-quality but slightly older primary-source evidence beats newer low-quality aggregator evidence for company facts
  • lower-quality but newer market context may be used for timing discussion only
  • downstream roles should prioritize high combined weight evidence and explicitly downweight lower-score evidence

Do not let technical or sentiment proxies dominate a company-quality judgment when fresher or higher-quality fundamental evidence exists.

Do not pass conflicted items into downstream role prompts as if they were facts. Either remove them or explicitly label them as disputed.

If latest live evidence cannot be fetched, is materially conflicted, or freshness cannot be validated, stop before spawning role agents and ask the user how to proceed. Do not silently downgrade to artifact mode or user-provided mode.

Minimum evidence thresholds before role execution:

  • if the latest primary financial disclosure cannot be validated, stop
  • if no credible company or news source can support the latest company-event context, downgrade confidence and explicitly mark the news role as thin-evidence
  • if no reliable market-context source is available, allow the market role to discuss regime and uncertainty only, not precise same-day technical conclusions
  • if social-sentiment evidence is thin, allow the social role to use public-discussion proxies, but it must explicitly state reduced confidence

The evidence packet should be handed off in a structured form, not as one undifferentiated wall of text. Maintain these coordinator-side packets:

  • analyst_packet
  • conflict_resolution_packet
  • debate_packet
  • investment_plan_packet
  • trader_packet
  • risk_packet
  • final_decision_packet

Each packet must carry these required keys:

  • summary
  • evidence_table
  • confidence
  • contradictions
  • key_triggers
  • freshness_notes
  • normalization_notes

This optional key may also be carried:

  • full_text

Downstream default handoff is summary + evidence_table. full_text is retained for auditability and should be passed downstream only when a dispute is unresolved or a stage explicitly needs the raw transcript.

Load references/handoff-schema.md before constructing these packets.

2. Run Analyst Stage In Parallel

Spawn four independent subagents in parallel:

  • Market Analyst
  • Social Sentiment Analyst
  • News Analyst
  • Fundamentals Analyst

Each analyst receives:

  • the shared analyst_packet
  • the conflict_resolution_packet
  • its own role objective
  • the output contract from references/output-contract.md

Each analyst must return a Chinese Markdown report with:

  • clear conclusion
  • evidence
  • reasoning chain
  • key risks
  • downstream implications for later roles

Analyst stage output must remain role-separated. Do not collapse it into one blended summary.

3. Run Bull/Bear Debate

Create a debate context from the four analyst reports and the debate_packet. Then run alternating subagent turns in this exact sequence:

  1. Bull Researcher opening turn
  2. Bear Researcher response
  3. Bull Researcher response
  4. Bear Researcher response
  5. Bull Researcher response
  6. Bear Researcher response
  7. Bull Researcher response
  8. Bear Researcher response
  9. Bull Researcher response
  10. Bear Researcher final response

This sequence constitutes the fixed maximum-depth research debate. Do not shorten it unless the user explicitly asks for a lighter-weight mode outside this skill.

Rules:

  • each side must directly answer the other side's previous argument
  • each side must cite evidence from analyst reports or debate-packet items, not invent unsupported facts
  • debate output must stay conversational and adversarial, not become a neutral summary
  • each side must respect the coordinator's conflict_resolution_summary and must not revive rejected values as if they were accepted facts

After the final round:

  • persist the full debate transcript to disk
  • compress the debate into investment_plan_packet
  • send the compressed packet plus any unresolved dispute notes to the Research Manager

Do not respawn new bull/bear agents every round. Reuse the same role agents via follow-up input so the debate stays coherent and thread usage remains bounded.

4. Research Manager Produces The Investment Plan

The Research Manager must:

  • summarize the strongest bull and bear points
  • choose a clear stance
  • write a Chinese investment_plan
  • include rationale, risks, and concrete actions for the trader
  • include a minimum valuation view tied to the evidence packet

Do not allow the manager to stay vague. It must commit to a directional recommendation.

The manager should consume the compressed investment_plan_packet by default, not the raw debate transcript, unless unresolved disputes require direct inspection.

Minimum valuation view means:

  • current valuation anchor or market-implied level when available
  • how that compares with the company's current profitability visibility
  • what would justify re-rating up or down

5. Trader Produces The Transaction Proposal

The Trader receives:

  • the investment_plan
  • the four analyst reports
  • the compressed trader packet derived from prior stages

The Trader must output:

  • main body in Chinese
  • explicit execution considerations
  • one Chinese conclusion line with buy/hold/sell wording
  • one final English anchor line in exactly this format:

FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL**

The Trader should not redo the entire upstream analysis. It should convert the investment plan into an executable trade view.

Trader output is execution-layer advice only. The Trader should treat valuation as an execution constraint, not as a replacement for the manager's directional stance.

6. Run Risk Debate

Create a risk context from:

  • trader proposal
  • four analyst reports
  • research manager plan
  • risk_packet

Run the risk roles in this fixed cycle:

  1. Aggressive Risk Analyst
  2. Conservative Risk Analyst
  3. Neutral Risk Analyst

Repeat that full cycle exactly 5 times.

Rules:

  • aggressive argues for upside and opportunity cost
  • conservative argues for downside control and capital preservation
  • neutral challenges both extremes and proposes balanced adjustments
  • each turn must answer the prior positions, not merely restate a static view

Persist the full risk transcript to disk, but pass a compressed final_decision_packet downstream by default unless unresolved disputes require raw transcript review.

Reuse the same three risk-role agents across all cycles instead of creating new ones each cycle.

7. Portfolio Manager Issues One Final Rating

The Portfolio Manager receives the compressed final_decision_packet and may inspect the full risk debate transcript only if unresolved disputes require it.

The Portfolio Manager must produce exactly one final rating:

  • Buy
  • Overweight
  • Hold
  • Underweight
  • Sell

It must also produce:

  • 评级
  • 执行摘要
  • 投资逻辑

Do not allow multiple conflicting ratings or hedged wording that obscures the decision.

Portfolio-manager output is allocation-layer advice and may differ from the Trader's BUY/HOLD/SELL execution-layer proposal without being treated as an inconsistency. The Portfolio Manager should explicitly incorporate the minimum valuation view plus the risk debate's final adjustment.

8. Assemble The Final Report

The coordinator combines role outputs into one Markdown report with exactly these top-level sections:

  • ## 一、分析师团队报告
  • ## 二、研究团队结论
  • ## 三、交易团队计划
  • ## 四、风险管理团队结论
  • ## 五、投资组合经理决策

State evidence freshness near the beginning of the final report. The final report preamble must explicitly state whether all evidence was live and current enough for role execution.

Add a decision_ladder near the beginning of the final report with:

  • analyst consensus
  • bull/bear debate outcome
  • research manager stance
  • trader transaction proposal
  • risk adjustment
  • final portfolio rating

Also include near the beginning:

  • a freshness_block
  • a normalization_block
  • a conflict_resolution_summary

After assembling the final report, persist the output package to the default report directory unless the user asked not to write files.

Subagent Orchestration Rules

  • Use subagents only because the user requested role simulation or a TradingAgents-style multi-role report.
  • The coordinator owns sequencing, evidence normalization, freshness validation, and final assembly.
  • Prefer parallel subagents only for the four analysts. Debate stages should be sequential because each turn depends on the previous turn.
  • Keep a clean handoff packet between stages. Pass compressed summaries and evidence tables by default, plus exact prior outputs only when a dispute is unresolved.
  • Reuse exact role names from this skill so the final report remains auditable.
  • Close completed analyst agents as soon as their outputs are captured.
  • Close completed debate/risk agents once their stage is fully consumed.
  • Reuse the same debate/risk agents across all rounds instead of spawning fresh ones every turn.
  • Keep the live thread count low enough to avoid agent-thread exhaustion; do not leave completed agents open unnecessarily.
  • If the coordinator cannot safely maintain thread limits, reduce concurrency before dropping role fidelity.

Failure Rules

  • If one analyst fails, the coordinator may continue only if the missing view is explicitly marked as unavailable in the report.
  • If multiple analyst roles fail, stop and explain that the role protocol could not be completed with acceptable fidelity.
  • If evidence is thin, keep the role structure but downgrade confidence. Do not fabricate certainty.
  • If the ticker or exchange suffix is ambiguous, stop and resolve it before any role output is generated.
  • If latest live evidence cannot be fetched, freshness cannot be validated, or evidence validation finds widespread conflicted items, stop role execution before spawning subagents and ask the user how to proceed.

Accuracy Guardrails

Before spawning any role agent, the coordinator should verify:

  • no mixed-date item is being described as a same-day fact
  • no third-party technical item is being treated as a primary company fact
  • no media inference is being rewritten as an official company disclosure
  • no execution-layer action is being confused with allocation-layer rating
  • no unlabeled unit or currency conversion remains in the packet

Before assembling the final report, the coordinator should verify:

  • analyst consensus does not overrule higher-quality primary evidence
  • unresolved conflicts remain explicitly marked as unresolved
  • thin-evidence roles carry downgraded confidence
  • valuation comments are tied to dated evidence, not generic narrative

Repository Mapping

Load references/repo-mapping.md when you need to verify how this skill aligns with the actual repository flow.

Output Contract

Load references/output-contract.md before spawning role subagents or assembling the final report.

相关技能