TradingAgents/tests
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
..
v2_overhaul 2026-01-15 (Phase 1: The Foundation) 2026-01-15 11:02:35 -06:00
README.md Fixed 2026-01-11 20:13:01 -06:00
bench_yfinance.py feat: implement trend override, harden regime detection, and organize tests 2026-01-11 11:18:46 -06:00
demo_regime_detection.py 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
ignition_tests.py 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
test_analyst_node.py Fixed 2026-01-11 20:13:01 -06:00
test_anonymizer.py 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
test_fatal_flaw_fixes.py 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
test_finance_args.py Fixed 2026-01-11 20:13:01 -06:00
test_global_news.py feat: implement trend override, harden regime detection, and organize tests 2026-01-11 11:18:46 -06:00
test_google_api.py - **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. 2026-01-13 05:27:24 -06:00
test_integrated_workflow.py 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
test_macro_regime.py Fixed 2026-01-11 20:13:01 -06:00
test_market_node.py feat: implement trend override, harden regime detection, and organize tests 2026-01-11 11:18:46 -06:00
test_override.py feat: implement trend override, harden regime detection, and organize tests 2026-01-11 11:18:46 -06:00
test_pltr_regime.py Fixed 2026-01-11 20:13:01 -06:00
test_rag_isolator.py 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
test_regime_detection.py feat: implement trend override, harden regime detection, and organize tests 2026-01-11 11:18:46 -06:00
test_regime_detector.py 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
test_regime_propagation.py Fixed 2026-01-11 20:13:01 -06:00
test_semantic_fact_checker.py 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
torture_test_2022.py 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
verify_alpaca.py feat: implement trend override, harden regime detection, and organize tests 2026-01-11 11:18:46 -06:00
verify_google_key.py feat: implement trend override, harden regime detection, and organize tests 2026-01-11 11:18:46 -06:00
verify_local_embeddings.py feat: implement trend override, harden regime detection, and organize tests 2026-01-11 11:18:46 -06:00
verify_ollama_embeddings.py feat: implement trend override, harden regime detection, and organize tests 2026-01-11 11:18:46 -06:00
verify_override_fix.py Fixed 2026-01-11 20:13:01 -06:00
verify_pltr_pipeline.py Fixed 2026-01-11 20:13:01 -06:00
verify_reflection_loop.py ### Added 2026-01-13 06:40:07 -06:00
verify_regime_flow.py Fixed 2026-01-11 20:13:01 -06:00
verify_regime_integration.py feat: implement trend override, harden regime detection, and organize tests 2026-01-11 11:18:46 -06:00
verify_tei_native.py feat: implement trend override, harden regime detection, and organize tests 2026-01-11 11:18:46 -06:00

README.md

Trading Agents Verification Suite

This folder contains unit tests and verification scripts to validate the functionality of the Trading Agents system.

Available Tests

Core Logic Tests

  1. test_regime_detection.py

    • Purpose: Validates mathematical components (ADX, Volatility, Hurst) of the RegimeDetector.
    • Usage: python tests/test_regime_detection.py
  2. test_market_node.py

    • Purpose: End-to-end verification of market_analyst_node. Checks data fetching logic and regime integration.
    • Usage: python tests/test_market_node.py
  3. test_override.py

    • Purpose: Unit tests for "Don't Fight the Tape" safety logic. Verifies protection of growth leaders.
    • Usage: python tests/test_override.py

Integration & API Tests

  1. test_global_news.py

    • Purpose: Verifies news fetching capabilities.
    • Usage: python tests/test_global_news.py
  2. test_google_api.py & verify_google_key.py

    • Purpose: Validates Google Gemini API connectivity and key validity.
    • Usage: python tests/test_google_api.py
  3. verify_alpaca.py

    • Purpose: Checks Alpaca trading API connection.
    • Usage: python tests/verify_alpaca.py

Infrastructure & Performance

  1. verify_local_embeddings.py & verify_ollama_embeddings.py

    • Purpose: Validates local embedding models (Ollama/TEI) for RAG.
    • Usage: python tests/verify_local_embeddings.py
  2. verify_tei_native.py

    • Purpose: Tests Text Embeddings Inference (TEI) native endpoint.
    • Usage: python tests/verify_tei_native.py
  3. bench_yfinance.py

    • Purpose: Benchmarks yfinance data fetch performance (latency/throughput).
    • Usage: python tests/bench_yfinance.py
  4. verify_regime_integration.py

    • Purpose: Integration test for regime detection within the broader graph context.
    • Usage: python tests/verify_regime_integration.py
  5. test_finance_args.py

    • Purpose: Verifies robustness of financial tools against extraneous LLM arguments and type mismatches.
    • Usage: python tests/test_finance_args.py

How to Run

Ensure your virtual environment is activated:

source .venv/bin/activate
export PYTHONPATH=$PYTHONPATH:.
python tests/test_market_node.py