$ show rosemarycox5334-debug/PA_Agent
PA Agent is a desktop application (PyQt6) that combines Al Brooks' price action theory with large language models (DeepSeek, MiMo, QClaw, etc.) to generate two-stage trading analysis: Stage 1 diagnoses market structure (cycle, pattern, direction), Stage 2 produces a trading decision (order type, entry, stop-loss, take-profit). The system ingests K-line data from multiple sources (MT5, TradingView, East Money, Tushare, AkShare) and provides real-time charting, AI reasoning streaming, decision tree visualization, and demo replay. It includes deterministic fallback nodes for data validation, direction voting, and pattern routing, reducing reliance on LLM output consistency. The architecture is modular with a data source abstraction, AI provider abstraction, event bus, incremental indicator computation, and a two-stage orchestration pipeline with retry and validation. While the codebase is well-structured and heavily tested (unit, integration, property-based), it suffers from complexity due to many provider connectors, hardcoded normalizer heuristics, and prompt engineering files that require ongoing maintenance.
The LLM identified 4 files worth highlighting for reuse:
Implements a Qt signal-based event bus for decoupled inter-component communication. The EventBus class allows any widget or service to emit and subscribe to events without direct references. This is a clean, self-contained pattern that could be extracted into any Qt application needing publish-subscribe messaging.
Defines the DataSource abstract base class and core data models (KlineBar, KlineFrame, IndicatorBundle). The ABC establishes a contract for fetching K-line data with methods like fetch_bars, subscribe, and close. This decouples data ingestion from the rest of the system and supports multiple implementations (MT5, TradingView, AkShare, etc.). The interface is minimal and reusable for any time-series financial data project.
Provides an EMA (Exponential Moving Average) implementation with both full vector and incremental state machine modes. The EmaState class tracks alpha, previous EMA, and warm-up phase, allowing efficient updates as new bars arrive without recomputing the entire series. This pattern is reusable for any streaming compute scenario and demonstrates clean separation of stateful incremental logic.
Contains pure functions for deterministic preflight data validation (gate), direction voting (5-signal system), always-in determination, and momentum strength assessment. These judges compute trace nodes that constrain and correct AI output. The logic is well-documented with clear thresholds and can be extracted as a standalone library for rule-based trading signal generation.