* docs: add implementation plan for medium-term positioning upgrade Covers 4 objectives: increased debate rounds, 8-quarter TTM fundamentals, sector/peer relative performance, and macro regime classification. https://claude.ai/code/session_01TuPpssTo83whKkNgSu57HH * feat: medium-term positioning upgrade (debate rounds, TTM, peer comparison, macro regime) ## Changes ### Step 1: Agentic Debate Depth - Increase `max_debate_rounds` and `max_risk_discuss_rounds` from 1 → 2 in `default_config.py` - Fix bug in `trading_graph.py`: wire config values into `ConditionalLogic()` (was ignoring config, using hardcoded defaults) ### Step 2: 8-Quarter TTM Fundamental Analysis - New `tradingagents/dataflows/ttm_analysis.py`: parses quarterly income/balance/cashflow CSV strings, computes TTM (sum of last 4 quarters), QoQ/YoY growth rates, margin trends across 8 quarters - New `@tool get_ttm_analysis` in `fundamental_data_tools.py` - Wire into fundamentals ToolNode; register in `TOOLS_CATEGORIES` - Update fundamentals analyst prompt: "last 8 quarters (2 years)" focus ### Step 3: Sector & Peer Relative Performance - New `tradingagents/dataflows/peer_comparison.py`: sector peer lookup, 1W/1M/3M/6M/YTD return ranking, alpha vs sector ETF - New `@tool get_peer_comparison` and `@tool get_sector_relative` - Wire into fundamentals ToolNode ### Step 4: Macro Regime Flag - New `tradingagents/dataflows/macro_regime.py`: 6-signal classifier (VIX level/trend, credit spread HYG/LQD, yield curve TLT/SHY, market breadth SPX vs 200-SMA, sector rotation) → risk-on / transition / risk-off - New `@tool get_macro_regime`; add `macro_regime_report` field to AgentState - Wire into market ToolNode; feed into research_manager and risk_manager prompts ### Step 5: Tests (88 new unit tests, 0 integration) - `tests/test_debate_rounds.py` (17 tests) - `tests/test_ttm_analysis.py` (18 tests) - `tests/test_peer_comparison.py` (11 tests) - `tests/test_macro_regime.py` (16 tests) - `tests/test_config_wiring.py` (12 tests) All 88 new unit tests pass; no regressions in existing tests. https://claude.ai/code/session_01TuPpssTo83whKkNgSu57HH * test: mark live yfinance network tests as integration TestYfinanceIndustryPerformance, TestRouteToVendorFallback, and TestFallbackRouting all make live HTTP calls to yfinance (yfinance.Sector / market movers). Mark them @pytest.mark.integration so they're skipped in standard offline runs. https://claude.ai/code/session_01TuPpssTo83whKkNgSu57HH * docs: update memory files for medium-term positioning upgrade - PROGRESS.md: add milestone section with all new files and changes - DECISIONS.md: add decisions 008-010 (macro regime, TTM data source, peer comparison) - MISTAKES.md: add mistakes 10-11 (Python 3.11 f-string, mock data precision) https://claude.ai/code/session_01TuPpssTo83whKkNgSu57HH * docs: document git remote setup (origin = aguzererler fork) origin points to aguzererler/TradingAgents which IS the fork. No upstream remote configured. All feature branches push to origin. https://claude.ai/code/session_01TuPpssTo83whKkNgSu57HH * docs: redirect tracking files to memory system Replace DECISIONS.md/MISTAKES.md/PROGRESS.md references in CLAUDE.md with instructions to use /remember memory system. A PreToolUse hook in ~/.claude/settings.json enforces this by blocking writes to those files. https://claude.ai/code/session_01TuPpssTo83whKkNgSu57HH * Initial plan * Add integration tests for yfinance and Alpha Vantage APIs (78 tests, all passing) Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com> * Initial plan * fix: allow .env variables to override DEFAULT_CONFIG values Merged origin/main and resolved all 8 conflicting files: - CLAUDE.md: merged MISTAKES.md ref + Project Tracking section + env override docs - cli/main.py: kept top-level json import, kept try/except in run_pipeline - tool_runner.py: kept descriptive comments for MAX_TOOL_ROUNDS - alpha_vantage_common.py: kept thread-safe rate limiter, robust error handling - interface.py: kept broader exception catch (AlphaVantageError + ConnectionError + TimeoutError) - default_config.py: kept _env()/_env_int() env var overrides with load_dotenv() at module level - scanner_graph.py: kept debug mode fix (stream for debug, invoke for result) - macro_bridge.py: kept get_running_loop() over deprecated get_event_loop() Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com> * fix: move rate limiter sleep outside lock to avoid blocking threads Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com> * docs: update PROGRESS, DECISIONS, MISTAKES, CLAUDE with env override implementation - PROGRESS.md: added env override milestone, updated test count (38 total), marked Mistake #9 as resolved, added all new/modified files from PR #9 - DECISIONS.md: added Decision 008 (env var config overrides), Decision 009 (thread-safe rate limiter), Decision 010 (broader vendor fallback exceptions), updated Decision 007 status to superseded - MISTAKES.md: updated Mistake #9 status to RESOLVED, added Mistake #10 (rate limiter held lock during sleep) - CLAUDE.md: added env var override convention docs, updated critical patterns with rate limiter and config fallback key lessons, updated mistake count to 10 Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com> * merge main into branch (-X theirs) and fix tests to pass against current main code Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com> * feat: add scanner tests, global demo key in conftest, remove 48 inline key patches Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com> * feat: add agentic memory scaffold and migrate tracking files to docs/agent/ Migrate DECISIONS.md, MISTAKES.md, PROGRESS.md, agents/, plans/, and tradingagents/llm_clients/TODO.md into a structured docs/agent/ scaffold with ADR-style decisions, plans, templates, and a live state tracker. This gives agent workflows a standard memory structure for decisions, plans, logs, and session continuity via CURRENT_STATE.md. Agent-Ref: docs/agent/plans/global-macro-scanner.md State-Updated: Yes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: improve Industry Deep Dive report quality with enriched data, sector routing, and tool-call nudge * Initial plan * Improve Industry Deep Dive quality: enrich tool data, explicit sector keys, tool-call nudge - Enrich get_industry_performance_yfinance with 1-day/1-week/1-month price returns via batched yf.download() for top 10 tickers (Step 1) - Add VALID_SECTOR_KEYS, _DISPLAY_TO_KEY, _extract_top_sectors() to industry_deep_dive.py to pre-extract top sectors from Phase 1 report and inject them into the prompt (Step 2) - Add tool-call nudge to run_tool_loop: if first LLM response has no tool calls and is under 500 chars, re-prompt with explicit instruction to call tools (Step 3) - Update scanner_tools.py get_industry_performance docstring to list all valid sector keys (Step 4) - Add 15 unit tests covering _extract_top_sectors, tool_runner nudge, and enriched output (Step 5) Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com> * Address code review: move cols[3] access into try block for IndexError safety Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com> * fix: align display row count with download count in get_industry_performance_yfinance The enriched function downloads price data for top 10 tickers but displayed 20 rows, causing rows 11-20 to show N/A in all price columns. This broke test_industry_perf_falls_back_to_yfinance which asserts N/A count < 5. Now both download and display use head(10) for consistency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com> Co-authored-by: Ahmet Guzererler <guzererler@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> * docs: update memory files after PR #13 (Industry Deep Dive quality fix) - CURRENT_STATE.md: remove Industry Deep Dive blocker (resolved), update test count 38 → 53, add PR #13 to Recent Progress, update milestone focus - decisions/009-industry-deep-dive-quality.md: new ADR documenting the three-pronged fix (enriched data, explicit sector routing, tool-call nudge) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add architecture-coordinator skill for mandatory ADR reading protocol New Claude Code skill that enforces reading docs/agent/CURRENT_STATE.md, decisions/, and plans/ before any code changes. Includes conflict resolution protocol that stops work and quotes the violated ADR rule when user requests conflict with established architectural decisions. Files: - .claude/skills/architecture-coordinator/SKILL.md - .claude/skills/architecture-coordinator/references/adr-template.md - .claude/skills/architecture-coordinator/references/reading-checklist.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com> |
||
|---|---|---|
| .claude/skills/architecture-coordinator | ||
| assets | ||
| cli | ||
| docs/agent | ||
| tests | ||
| tradingagents | ||
| .env.example | ||
| .gitignore | ||
| CLAUDE.md | ||
| LICENSE | ||
| PLAN.md | ||
| README.md | ||
| main.py | ||
| pyproject.toml | ||
| requirements.txt | ||
| test.py | ||
| uv.lock | ||
README.md
TradingAgents: Multi-Agents LLM Financial Trading Framework
News
- [2026-02] TradingAgents v0.2.0 released with multi-provider LLM support (GPT-5.x, Gemini 3.x, Claude 4.x, Grok 4.x) and improved system architecture.
- [2026-01] Trading-R1 Technical Report released, with Terminal expected to land soon.
🎉 TradingAgents officially released! We have received numerous inquiries about the work, and we would like to express our thanks for the enthusiasm in our community.
So we decided to fully open-source the framework. Looking forward to building impactful projects with you!
🚀 TradingAgents | ⚡ Installation & CLI | 🎬 Demo | 📦 Package Usage | 🤝 Contributing | 📄 Citation
TradingAgents Framework
TradingAgents is a multi-agent trading framework that mirrors the dynamics of real-world trading firms. By deploying specialized LLM-powered agents: from fundamental analysts, sentiment experts, and technical analysts, to trader, risk management team, the platform collaboratively evaluates market conditions and informs trading decisions. Moreover, these agents engage in dynamic discussions to pinpoint the optimal strategy.
TradingAgents framework is designed for research purposes. Trading performance may vary based on many factors, including the chosen backbone language models, model temperature, trading periods, the quality of data, and other non-deterministic factors. It is not intended as financial, investment, or trading advice.
Our framework decomposes complex trading tasks into specialized roles. This ensures the system achieves a robust, scalable approach to market analysis and decision-making.
Analyst Team
- Fundamentals Analyst: Evaluates company financials and performance metrics, identifying intrinsic values and potential red flags.
- Sentiment Analyst: Analyzes social media and public sentiment using sentiment scoring algorithms to gauge short-term market mood.
- News Analyst: Monitors global news and macroeconomic indicators, interpreting the impact of events on market conditions.
- Technical Analyst: Utilizes technical indicators (like MACD and RSI) to detect trading patterns and forecast price movements.
Researcher Team
- Comprises both bullish and bearish researchers who critically assess the insights provided by the Analyst Team. Through structured debates, they balance potential gains against inherent risks.
Trader Agent
- Composes reports from the analysts and researchers to make informed trading decisions. It determines the timing and magnitude of trades based on comprehensive market insights.
Risk Management and Portfolio Manager
- Continuously evaluates portfolio risk by assessing market volatility, liquidity, and other risk factors. The risk management team evaluates and adjusts trading strategies, providing assessment reports to the Portfolio Manager for final decision.
- The Portfolio Manager approves/rejects the transaction proposal. If approved, the order will be sent to the simulated exchange and executed.
Installation and CLI
Installation
Clone TradingAgents:
git clone https://github.com/TauricResearch/TradingAgents.git
cd TradingAgents
Create a virtual environment in any of your favorite environment managers:
conda create -n tradingagents python=3.13
conda activate tradingagents
Install dependencies:
pip install -r requirements.txt
Required APIs
TradingAgents supports multiple LLM providers. Set the API key for your chosen provider:
export OPENAI_API_KEY=... # OpenAI (GPT)
export GOOGLE_API_KEY=... # Google (Gemini)
export ANTHROPIC_API_KEY=... # Anthropic (Claude)
export XAI_API_KEY=... # xAI (Grok)
export OPENROUTER_API_KEY=... # OpenRouter
export ALPHA_VANTAGE_API_KEY=... # Alpha Vantage
For local models, configure Ollama with llm_provider: "ollama" in your config.
Alternatively, copy .env.example to .env and fill in your keys:
cp .env.example .env
CLI Usage
You can also try out the CLI directly by running:
python -m cli.main
You will see a screen where you can select your desired tickers, date, LLMs, research depth, etc.
An interface will appear showing results as they load, letting you track the agent's progress as it runs.
TradingAgents Package
Implementation Details
We built TradingAgents with LangGraph to ensure flexibility and modularity. The framework supports multiple LLM providers: OpenAI, Google, Anthropic, xAI, OpenRouter, and Ollama.
Python Usage
To use TradingAgents inside your code, you can import the tradingagents module and initialize a TradingAgentsGraph() object. The .propagate() function will return a decision. You can run main.py, here's also a quick example:
from tradingagents.graph.trading_graph import TradingAgentsGraph
from tradingagents.default_config import DEFAULT_CONFIG
ta = TradingAgentsGraph(debug=True, config=DEFAULT_CONFIG.copy())
# forward propagate
_, decision = ta.propagate("NVDA", "2026-01-15")
print(decision)
You can also adjust the default configuration to set your own choice of LLMs, debate rounds, etc.
from tradingagents.graph.trading_graph import TradingAgentsGraph
from tradingagents.default_config import DEFAULT_CONFIG
config = DEFAULT_CONFIG.copy()
config["llm_provider"] = "openai" # openai, google, anthropic, xai, openrouter, ollama
config["deep_think_llm"] = "gpt-5.2" # Model for complex reasoning
config["quick_think_llm"] = "gpt-5-mini" # Model for quick tasks
config["max_debate_rounds"] = 2
ta = TradingAgentsGraph(debug=True, config=config)
_, decision = ta.propagate("NVDA", "2026-01-15")
print(decision)
See tradingagents/default_config.py for all configuration options.
Contributing
We welcome contributions from the community! Whether it's fixing a bug, improving documentation, or suggesting a new feature, your input helps make this project better. If you are interested in this line of research, please consider joining our open-source financial AI research community Tauric Research.
Citation
Please reference our work if you find TradingAgents provides you with some help :)
@misc{xiao2025tradingagentsmultiagentsllmfinancial,
title={TradingAgents: Multi-Agents LLM Financial Trading Framework},
author={Yijia Xiao and Edward Sun and Di Luo and Wei Wang},
year={2025},
eprint={2412.20138},
archivePrefix={arXiv},
primaryClass={q-fin.TR},
url={https://arxiv.org/abs/2412.20138},
}