$ show TauricResearch/TradingAgents
TradingAgents is a multi-agent LLM framework for financial trading research and backtesting. It orchestrates specialized agents (analysts, researchers, debaters, trader, portfolio manager) through a LangGraph state machine to produce trading decisions. The system emphasizes point-in-time data isolation to prevent lookahead bias, supports multiple LLM providers and data vendors, and includes a comprehensive backtesting engine. It is structured as a Python library with a rich CLI interface. The architecture is a hybrid of a software application and a research framework. It demonstrates high craftsmanship in its data pipeline (vendor routing, symbol normalization, date windowing), LLM integration (capability registry, structured output fallback), and concurrency handling (atomic file writes). While the core abstractions are clean and reusable, the codebase is tightly coupled to the specific behaviors of its external dependencies (LLM APIs, Yahoo Finance, SEC EDGAR), making it sensitive to ecosystem drift. The extensive test suite provides good coverage for unit and integration scenarios, but the reliance on mocking means regressions in vendor adapters may go undetected without manual integration runs.
The LLM identified 8 files worth highlighting for reuse:
Provides a suite of functions for point-in-time data isolation, preventing lookahead bias in historical backtesting. Functions like `as_of`, `in_window`, and `withhold_live_profile` are completely self-contained and can be extracted to enforce temporal consistency in any data pipeline.
Implements robust symbol normalization and validation for financial instruments. Handles forex, crypto, equities, and index CFDs with a clear alias table and exchange-specific rules. The `safe_ticker_component` function prevents path traversal, making it a secure and reusable data cleaning component.
Demonstrates a sophisticated pattern for handling time-series data quality from external vendors. Includes cache freshness checks, unsettled bar detection (intraday data), and stale frame rejection. This pattern is directly applicable to any project consuming financial or IoT time-series data.
Implements an append-only decision log with atomic file writes and cross-process locking. The `replace_file` and `locked` patterns are robust, well-tested solutions for concurrent data persistence that can be extracted into any application requiring a durable, concurrent-safe log.
Provides a clean, dataclass-based registry for mapping LLM model IDs to their capabilities (structured output, tool use, reasoning effort). This pattern solves the non-trivial problem of managing the expanding matrix of LLM provider quirks and is highly reusable for any multi-provider LLM application.
Implements the Chain of Responsibility pattern for data vendor routing. Uses a configurable vendor chain and a custom error hierarchy (`VendorError`, `NoMarketDataError`) to provide graceful degradation. This is a clean, extractable pattern for any application that needs resilient, multi-source data fetching.
Implements a robust structured output extraction pattern with free-text fallback. Attempts provider-native structured output first, and on failure, falls back to parsing generated text. This pattern is critical for production LLM applications requiring reliability across diverse providers and models.
Provides an adapter for external content moderation (TypeSafe Jev) with graceful degradation. If the service is unavailable or unconfigured, it returns unscreened results instead of failing. This is a textbook example of the Adapter pattern for integrating external AI safety services.