How rosemarycox5334-debug/pa_agent works
PA Agent is a desktop Price Action analysis assistant: traders select a market feed and request analysis; the app fetches bars, builds a snapshot, runs a two-stage market diagnosis and trade-decision workflow, then presents the result. The graph also shows documented incremental tracking, interactive decision visualization, follow-up chat, experience lookup, and record persistence. Main wiring and several workers are sampled; broader stage and capability links follow the README and module layout, so uncertain internal call details are omitted.
Main entry points: two_stage.py Two-stage analysis · main_window.py Main window · factory.py Data-source factory · client_factory.py AI client routing
Components 23
Desktop app
- Application entry
pa_agent/main.py - App wiring
pa_agent/app_context.py - Main window
pa_agent/gui/main_window.py
Market data
- Snapshot fetch
pa_agent/gui/snapshot_worker.py - Data-source factory
pa_agent/data/factory.py - Data refresh loop
pa_agent/data/refresh_loop.py
AI analysis
- Snapshot preparation
pa_agent/gui/analysis_prep_worker.py - Two-stage analysis
pa_agent/orchestrator/two_stage.py - Prompt assembly
pa_agent/ai/prompt_assembler.py - Strategy routing
pa_agent/ai/router.py - AI client routing
pa_agent/ai/client_factory.py - Response validation
pa_agent/ai/json_validator.py - Validation retry
pa_agent/orchestrator/validation_retry.py - Follow-up chat
pa_agent/orchestrator/free_chat.py
Results and history
- Analysis views
pa_agent/gui/decision_panel.py - Decision tree view
pa_agent/gui/decision_tree_panel.py - Future trend view
pa_agent/gui/future_trend_panel.py - Analysis history
pa_agent/records/analysis_history.py - Pending records
pa_agent/records/pending_writer.py - Experience lookup
pa_agent/records/experience_reader.py
External services
- Market data providers
- LLM providers
Other components
- Trader
Connections 27
- Trader → Application entry: launches
- Application entry → App wiring: bootstraps
- Application entry → Main window: opens
- App wiring → Data-source factory: creates source
- App wiring → AI client routing: creates client
- Main window → Snapshot fetch: requests bars
- Snapshot fetch → Data-source factory: fetches snapshot
- Data-source factory → Market data providers: retrieves bars
- Snapshot fetch → Snapshot preparation: returns bars
- Snapshot preparation → Analysis history: looks up base
- Main window → Two-stage analysis: starts analysis
- Two-stage analysis → Prompt assembly: assembles prompts
- Two-stage analysis → Strategy routing: routes strategy
- Two-stage analysis → AI client routing: requests analysis
- AI client routing → LLM providers: streams completion
- Two-stage analysis → Response validation: validates response
- Two-stage analysis → Validation retry: retries failures
- Two-stage analysis → Experience lookup: loads examples
- Two-stage analysis → Pending records: writes analysis
- Two-stage analysis → Analysis history: records outcome
- Two-stage analysis → Analysis views: returns analysis
- Analysis views → Decision tree view: shows decision flow
- Analysis views → Future trend view: shows forecast
- Main window → Follow-up chat: starts follow-up
- Follow-up chat → AI client routing: requests reply
- Follow-up chat → Analysis history: persists conversation
- Data refresh loop → Data-source factory: refreshes data