Commit Graph

6 Commits

Author SHA1 Message Date
swj.premkumar 5a6d22cb32 ## VIII. MENTAL MODELS (The Cognitive Framework)
To prevent "Value Trap" logic in Tech/Platform stocks, the Trader utilizes specific mental models distinct from traditional Value Investing.

### 1. CapEx Distinction (The "Moat" Rule)
*   **Maintenance CapEx:** Spending to keep the lights on (e.g., repairing a factory). This is a **COST**.
*   **Strategic CapEx:** Spending to capture a new platform (e.g., Google building Data Centers for AI). This is **DEFENSE**.
*   **The Rule:** For dominant platforms, massive CapEx during a platform shift is a **BULLISH** signal of durability, not a bearish signal of inefficiency.
2026-01-14 20:11:37 -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 05ce55125f ### Added
- **Dynamic Parameter Tuning (The Learning Loop)**: Implemented full self-reflection cycle. The Reflector agent now parses its own advice into JSON (`rsi_period`, `stop_loss_pct`), persists it to `data_cache/runtime_config.json`, and the Market Analyst loads it to tune the Regime Detector in real-time.
- **Audit Archival**: Every tuning event is now archived to `results/{TICKER}/{DATE}/runtime_config.json` for historical auditing, ensuring we can reproduce why parameters changed on any given day.
- **Atomic Persistence**: Implemented `agent_utils.write_json_atomic` to prevent race conditions during config saves.
- **Centralized Config**: Moved hardcoded paths to `default_config.py` (DRY principle).

### Fixed
- **Reflector Logic Gap**: The Reflector was previously "shouting into the void"—making suggestions but having no mechanism to apply them. This circuit is now closed.
2026-01-13 06:40:07 -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