Commit Graph

27 Commits

Author SHA1 Message Date
swj.premkumar 97d13ee1ed 2026-01-15 (Phase 1: The Foundation)
### Added
- **Hyper-Immutability (Physically Secured State)**: Implemented `FactLedger` (TypedDict) and `write_once_enforce` reducer in `agent_states.py` to cryptographically lock data reality.
    - Ledger is hashed (SHA-256) upon creation.
    - Wrapped in `MappingProxyType` to prevent any downstream agent from mutating the facts.
- **The Data Registrar (Parallel Gatekeeper)**: Created `DataRegistrar` node (`tradingagents/agents/data_registrar.py`) that acts as the Single Source of Truth.
    - **Parallel I/O**: Fetches Price, Fundamentals, News, and Insider data concurrently (4x speedup over sequential).
    - **Partial Poisoning Guard**: Hard "Fail-Fast" if critical domains (Price, Fundamentals) are missing.
    - **Freshness Simulation**: Configurable `TRADING_MODE` (simulation/production) to allow rigorous testing without stale-data aborts.

### Fixed
- **Hallucination Vectors (The Lobotomy)**: Removed ALL tool access from `Market`, `Social`, `News`, and `Fundamentals` analysts.
    - Analysts now consume exclusively from `FactLedger`.
    - Eliminated "Tool Use Loop" latency and potential for agents to fetch divergent data.
- **Graph Wiring**: Refactored `setup.py` to route `START` -> `Data Registrar` -> `Market Analyst` -> Parallel Fan-Out.
2026-01-15 11:02:35 -06:00
swj.premkumar 3a5bc02879 ### Changed
- **Risk Star Topology (Strategy 2)**: Replaced sequential "Round Robin" risk debate with a parallel "Fan-Out / Fan-In" architecture.
    - `Trader` now triggers `Risky`, `Safe`, and `Neutral` analysts simultaneously.
    - Implemented `Risk Sync` node and `merge_risk_states` reducer (AgentStates) to handle concurrent updates safely.
    - Reduced Risk Phase latency by ~60%.
- **Batch Reflection (Strategy 1)**: Consolidated 5 sequential reflection calls into a single "Session Audit" call, reducing token usage and latency by ~80% in the post-trade phase.
- **Parallel I/O (Strategy 3)**: Refactored `tradingagents/dataflows/local.py` (Reddit News) to use `ThreadPoolExecutor` (max 10 workers), achieving 5x-10x speedup in data fetching.
2026-01-14 20:11:06 -06:00
swj.premkumar 532ef1849b **Parallel Architecture (AsyncIO)**: Refactored `setup.py` to implement a "Fan-Out / Fan-In" pattern using LangGraph.
- `Market Analyst` now triggers `Social`, `News`, and `Fundamentals` analysts **concurrently**.
    - Added `Analyst Sync` node to synchronize parallel branches.
    - Added `Analyst Sync` node to synchronize parallel branches.
    - reduced total runtime by ~50% by overlapping heavy LLM/Tool operations.
- **Fail Fast Scraper**: Optimized `googlenews_utils.py` to timeout after ~30s (down from 3m) when blocked, ensuring rapid failover to backup vendors.

### Fixed
- **API Error 400 (Dangling Tool Use)**: Fixed crash in `Fundamentals Analyst` and others caused by unhandled tool exceptions (e.g. Rate Limits).
    - Wrapped all tools in `fundamental_data_tools.py`, `news_data_tools.py`, `core_stock_tools.py`, and `technical_indicators_tools.py` with `try/except` blocks.
    - Tools now return error strings instead of crashing, ensuring stricter API compliance and system resilience.
2026-01-14 07:29:12 -06:00
swj.premkumar 24edac65c4 - **Standalone HTML Reports**: Refactored report generation to perform server-side Markdown-to-HTML rendering using Python.
- Removed dependency on client-side `marked.js` and CDNs.
    - Reports are now fully offline-capable.
    - Cleaned up JSON keys to remove `.md` extensions for cleaner data structure.
- **Google News Adapter**: Implemented `get_google_global_news` adapter in `google.py` to match the standard `(curr_date, look_back_days)` interface, adhering to the Adapter Pattern and fixing signature mismatches.
- **Robust Demo Script**: Created `run_agent.py` (replacing demo scripts) with:
    - Automatic `.env` loading.
    - `backend_url` handling (clearing OpenAI defaults when using Anthropic).
    - Hardened configuration for "Deep Analysis" (Debate Rounds=2).
    - Pre-configured Google News vendor to bypass AlphaVantage rate limits.

### Fixed
- **Rate Limit Crash**: Fixed `AlphaVantageRateLimitError` by switching default news vendor to Google in `run_agent.py`.
2026-01-14 05:58:33 -06:00
swj.premkumar 1f279a9df2 - **Insider Veto Protocol (Rule B)**: Hard-coded safety gate in `trading_graph.py` that blocks ALL buy signals if Net Insider Selling exceeds $50M while the stock is in a technical downtrend (Price < 50 SMA). This prevents "Falling Knife" catches.
- **Relative Strength Determinism**: Upgraded `market_analyst.py` to calculate a mathematical `risk_multiplier` (0.0x - 1.5x) based on the Asset Regime vs. SPY Regime correlation, removing LLM "confidence" hallucinations from position sizing.
- **Portfolio Awareness (Rule 72)**: Implemented State Persistence (`portfolio`, `cash_balance`) and a hard-coded Stop Loss check in `trading_graph.py`. If a position's unrealized PnL drops below -10%, the system forces a "LIQUIDATE" order, bypassing all AI debate.
- **Self-Tuning Architecture**: Updated `reflection.py` to output a structured JSON block (`UPDATE_PARAMETERS`) instead of prose advice, enabling future automated parameter optimization.
2026-01-13 05:27:24 -06:00
swj.premkumar e88a01d0ea Fixed
Override Logic Mismatches: Fixed critical Enum-to-String type mismatch in
apply_trend_override
 that was silencing the "Safety Valve" logic.
Data Pipeline Failures: Injected robust error handling and type checking in
market_analyst.py
 to identify why RegimeDetector receives invalid data (causing "UNKNOWN" regimes).
Gemini 404 Errors: Removed invalid/deprecated model names causing 404s
2026-01-11 20:13:01 -06:00
swj.premkumar a6e4c9b770 feat: implement trend override, harden regime detection, and organize tests
**Core Logic (Safety Valve & Regime Detection):**

  *   Added "Momentum Override": `Overall Return > 30%` now forces `TRENDING_UP` (Bull) regime to capture volatile winners.
    *   Prioritized Trend Strength (ADX) over Volatility for single stocks.
    *   Fixed `Hurst Exponent` calculation to handle non-positive inputs safely.
*   **Data Reliability ([market_analyst.py]
2026-01-11 11:18:46 -06:00
swj.premkumar 903e5d0aeb Adjusted default character truncation to safer levels for local embedding models. 2026-01-11 08:07:13 -06:00
swj.premkumar 0f46729f09 **Global Market News**: Implemented `get_global_market_news` in Alpha Vantage module to support generic market news (topics: economy_macro, financial_markets), fixing the lack of a primary vendor for global news.
- **Configurable Embeddings Truncation**: Added `EMBEDDING_TRUNCATION_LIMIT` env var (default 1000) to prevent `413 Payload Too Large` errors with local models.
2026-01-10 12:45:04 -06:00
swj.premkumar 54a3395b37 Phase 2 changes 2026-01-10 05:17:58 -06:00
swj.premkumar 66c9807ed8 Alpaca Integration**: Added `tradingagents/dataflows/alpaca.py` to support `get_stock_data` via Alpaca Data API v2. 2026-01-10 04:32:46 -06:00
swj.premkumar 9347a419e4 fix 2026-01-09 20:59:52 -06:00
swj.premkumar a0ab1a9b3e The **TradingAgents** system is a risk-managed, LLM-driven trading engine designed to execute trades based on validated truth, not hallucinations. It connects hierarchical LLM agents with deterministic safety gates to ensure that every trade is architecturally sound, factually correct, and risk-compliant. 2026-01-09 19:28:49 -06:00
Edward Sun 7bb2941b07 optimized yfin fetching to be much faster 2025-10-06 19:58:01 -07:00
Edward Sun c07dcf026b added fallbacks for tools 2025-10-03 22:40:09 -07:00
luohy15 d23fb539e9 minor fix 2025-09-30 13:27:48 +08:00
luohy15 b01051b9f4 Switch default data vendor
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 12:43:27 +08:00
luohy15 6211b1132a Improve Alpha Vantage indicator column parsing with robust mapping
- Replace hardcoded column indices with column name lookup
- Add mapping for all supported indicators to their expected CSV column names
- Handle missing columns gracefully with descriptive error messages
- Strip whitespace from header parsing for reliability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 23:36:36 +08:00
luohy15 8b04ec307f minor fix 2025-09-26 23:25:33 +08:00
luohy15 0ab323c2c6 Add Alpha Vantage API integration as primary data provider
- Replace FinnHub with Alpha Vantage API in README documentation
- Implement comprehensive Alpha Vantage modules:
  - Stock data (daily OHLCV with date filtering)
  - Technical indicators (SMA, EMA, MACD, RSI, Bollinger Bands, ATR)
  - Fundamental data (overview, balance sheet, cashflow, income statement)
  - News and sentiment data with insider transactions
- Update news analyst tools to use ticker-based news search
- Integrate Alpha Vantage vendor methods into interface routing
- Maintain backward compatibility with existing vendor system

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 22:57:50 +08:00
luohy15 a6734d71bc WIP 2025-09-26 16:17:50 +08:00
Max Wong 43aa9c5d09
Local Ollama (#53)
- Fix typo 'Start' 'End'
- Add llama3.1 selection
- Use 'quick_think_llm' model instead of hard-coding GPT
2025-06-26 00:27:01 -04:00
Edward Sun da84ef43aa main works, cli bugs 2025-06-15 22:20:59 -07:00
Edward Sun 90b23e72f5
Merge pull request #25 from maxer137/main
Add support for other backends, such as OpenRouter and Ollama
2025-06-15 16:06:20 -07:00
saksham0161 570644d939
Fix ticker hardcoding in prompt (#28) 2025-06-11 19:43:39 -07:00
maxer137 99789f9cd1 Add support for other backends, such as OpenRouter and olama
This aims to offer alternative OpenAI capable api's.
This offers people to experiment with running the application locally
2025-06-11 14:19:25 +02:00
Yijia-Xiao cc97cb6d5d chore(release): v0.1.0 – initial public release of TradingAgents 2025-06-05 04:27:57 -07:00