INTELLIGENT AGENT SYSTEMS / QML
Coordinated agents.
Traceable execution.
A paper-trading application that connects specialist AI analysis, automated strategy checks and controlled execution. Follow how evidence becomes a decision—and how every stage leaves a record.
- PROJECT
- QML R3 · Automated paper-trading system
- MY ROLE
- Independent system design & architecture
- STACK
- Python · FastAPI · SQLite · React / TypeScript
THE ENGINEERING CHALLENGE
Connect intelligent analysis
to a reliable workflow.
The application screens stocks, evaluates three swing-trading strategies and manages eligible paper orders and positions. Alongside that path, specialised agents analyse the saved evidence and produce structured opinions.
The design gives each part a clear responsibility: agents interpret evidence, rule code controls trading actions, and the ledger records what actually happened. The same pattern applies to AI applications that coordinate knowledge, tools and consequential business actions.
THE APPLICATION INTERFACE
A workspace for the whole decision.
The actual dashboard brings market charts, rule context and decision tracing into one application. Explore two captured views, with English notes explaining the engineering behind each.
Scroll the screenshot horizontally to inspect the interface, or open it at full size.

RUN · 04 Nov 2026 view · No rule evaluation or QML position shown
Market structure and next-action context, together.
Daily and five-minute charts, shared overlays, volume and a next-action panel connect market structure to the recorded rule and position state.
Daily structure and five-minute price action share crosshair and navigation context.
Adjustment basis, indicator availability and missing intervals appear in the interface.
Rule state and protection context sit beside the charts, with absence shown explicitly.
The source shows 72 missing five-minute intervals. Its charts rebuild currently known history; they are not decision-time order evidence. Original Chinese labels are preserved; account panels and internal identifiers are outside the captured region.
Read both dashboard views and their context
Trading workspace
RUN · 04 Nov 2026 view · No rule evaluation or QML position shown
Daily and five-minute charts, shared overlays, volume and a next-action panel connect market structure to the recorded rule and position state.
The source shows 72 missing five-minute intervals. Its charts rebuild currently known history; they are not decision-time order evidence.
Open trading workspace screenshotDecision graph
RUN · 03 Nov 2026 saved Breakout decision · WAIT
The application’s graph separates baseline rules, execution, advisory analysis and post-close review. Each node keeps its recorded state.
Advisory nodes show no recorded execution in this decision. The graph is a captured read-only view, not a running model demo.
Open decision graph screenshotHOW THE AGENTS COLLABORATE
A clear job for every agent.
Four specialists read different parts of the same frozen evidence. Their results meet at Synthesis. Prime reviews the factual record after the close.
One structured assessment.
Evidence, counter-evidence and unknowns.
ROLE 01 / 06
Market
What is the wider context?
- READS
- Frozen market state, coverage and available benchmark evidence.
- PRODUCES
- A structured market-context opinion with evidence, counter-evidence and unknowns.
- HANDS OFF
- The gather stage collects this result alongside the other three analyses.
- PERMISSION BOUNDARY
- Explains the recorded market context. Cannot change the market gate or release an order.
Source-based architecture walkthrough. The four specialist tasks share a bounded model-call limit; Synthesis follows collection. These panels describe role contracts, not generated trading opinions.
Read every agent’s input, output and handoff
| Role | Input | Output & handoff |
|---|---|---|
| Market | Frozen market state, coverage and available benchmark evidence. | A structured market-context opinion with evidence, counter-evidence and unknowns. The gather stage collects this result alongside the other three analyses. |
| Technical | Saved indicators, strategy checks, the baseline outcome and frozen price-level references. | A technical opinion tied to the recorded structure and explicit missing information. Passes a versioned assessment, or an explicit failure/skip state, to gather. |
| Event | Catalyst and future-earnings facts available at the decision time. | An event-evidence opinion that separates supporting facts, conflicting facts and unknowns. Supplies evidence context to gather and Synthesis. |
| Theme | Recorded theme memberships and available theme-news fields; missing news remains unknown. | A theme-context opinion with citations and limitations. Shares its result with gather, then Synthesis. |
| Synthesis | The frozen facts plus collected specialist results, including failed and skipped states. | A combined advisory assessment: supported, conflicted or needing more data. Stores an inspectable opinion alongside the original rule decision. |
| Prime review | A post-close factual report built from recorded execution events and available context. | A bounded review and unvalidated research hypotheses, with explicit unknowns. Feeds subsequent research and human review as a separate job. |
THE SYSTEM IN PRACTICE
Make “why no action?”
as visible as the action.
This saved RUN example shows why a watchlist candidate did not become an order. Select a stage to inspect the recorded checks and the execution boundary.
RUN / BREAKOUT
03 Nov 2026 · 17:15:15 UTC · Paper experiment
Breakout qualification failed
The strategy recorded failed daily-structure checks, including the rising moving-average condition and base-selection checks. The outcome remained WAIT.
Inspect all 34 check results
| Rule | Result | Reason code |
|---|---|---|
daily_current | PASS | DAILY_CURRENT |
corporate_actions | PASS | CORPORATE_ACTIONS |
daily_history_contiguous | PASS | DAILY_HISTORY_CONTIGUOUS |
candidate_qualified | PASS | CANDIDATE_QUALIFIED |
atr20_available | PASS | ATR20_AVAILABLE |
adr20_setup | PASS | ADR20_SETUP |
close_above_sma50 | PASS | CLOSE_ABOVE_SMA50 |
sma20_rising | FAIL | SMA20_RISING |
base_10_coverage | PASS | BASE_10_COVERAGE |
base_10_prior_leg | FAIL | BASE_10_PRIOR_LEG |
base_10_depth | PASS | BASE_10_DEPTH |
base_10_contraction | FAIL | BASE_10_CONTRACTION |
base_10_higher_low | PASS | BASE_10_HIGHER_LOW |
base_15_coverage | PASS | BASE_15_COVERAGE |
base_15_prior_leg | FAIL | BASE_15_PRIOR_LEG |
base_15_depth | PASS | BASE_15_DEPTH |
base_15_contraction | FAIL | BASE_15_CONTRACTION |
base_15_higher_low | PASS | BASE_15_HIGHER_LOW |
base_20_coverage | PASS | BASE_20_COVERAGE |
base_20_prior_leg | FAIL | BASE_20_PRIOR_LEG |
base_20_depth | PASS | BASE_20_DEPTH |
base_20_contraction | FAIL | BASE_20_CONTRACTION |
base_20_higher_low | FAIL | BASE_20_HIGHER_LOW |
base_30_coverage | PASS | BASE_30_COVERAGE |
base_30_prior_leg | FAIL | BASE_30_PRIOR_LEG |
base_30_depth | PASS | BASE_30_DEPTH |
base_30_contraction | FAIL | BASE_30_CONTRACTION |
base_30_higher_low | FAIL | BASE_30_HIGHER_LOW |
base_40_coverage | PASS | BASE_40_COVERAGE |
base_40_prior_leg | FAIL | BASE_40_PRIOR_LEG |
base_40_depth | FAIL | BASE_40_DEPTH |
base_40_contraction | FAIL | BASE_40_CONTRACTION |
base_40_higher_low | FAIL | BASE_40_HIGHER_LOW |
base_selected | FAIL | BASE_SELECTED |
At the earlier 04 Nov premarket capture, the RUN view had no saved decisions. This example is from 03 Nov. Model calls were disabled in that status snapshot; this decision has no recorded agent output.
Read the complete saved decision without the inspector
- DECISION
- WAIT · DAILY_QUALIFICATION_FAILED
- DECISION TIME / RECORDED TIME
- AUTHORITY
- DETERMINISTIC_RULES_ONLY
- EXECUTION
- NOT_RUN risk · 0 orders · 0 fills
Inspect all 6 check results
| Rule | Result | Reason code |
|---|---|---|
security_eligible | PASS | SECURITY_CLASSIFICATION |
previous_close_min | PASS | R2_THRESHOLD |
market_cap | PASS | R2_THRESHOLD |
adv20_dollar | PASS | R2_THRESHOLD |
volatility_week | PASS | R2_THRESHOLD |
close_above_ema21 | PASS | R2_THRESHOLD |
Inspect all 34 check results
| Rule | Result | Reason code |
|---|---|---|
daily_current | PASS | DAILY_CURRENT |
corporate_actions | PASS | CORPORATE_ACTIONS |
daily_history_contiguous | PASS | DAILY_HISTORY_CONTIGUOUS |
candidate_qualified | PASS | CANDIDATE_QUALIFIED |
atr20_available | PASS | ATR20_AVAILABLE |
adr20_setup | PASS | ADR20_SETUP |
close_above_sma50 | PASS | CLOSE_ABOVE_SMA50 |
sma20_rising | FAIL | SMA20_RISING |
base_10_coverage | PASS | BASE_10_COVERAGE |
base_10_prior_leg | FAIL | BASE_10_PRIOR_LEG |
base_10_depth | PASS | BASE_10_DEPTH |
base_10_contraction | FAIL | BASE_10_CONTRACTION |
base_10_higher_low | PASS | BASE_10_HIGHER_LOW |
base_15_coverage | PASS | BASE_15_COVERAGE |
base_15_prior_leg | FAIL | BASE_15_PRIOR_LEG |
base_15_depth | PASS | BASE_15_DEPTH |
base_15_contraction | FAIL | BASE_15_CONTRACTION |
base_15_higher_low | PASS | BASE_15_HIGHER_LOW |
base_20_coverage | PASS | BASE_20_COVERAGE |
base_20_prior_leg | FAIL | BASE_20_PRIOR_LEG |
base_20_depth | PASS | BASE_20_DEPTH |
base_20_contraction | FAIL | BASE_20_CONTRACTION |
base_20_higher_low | FAIL | BASE_20_HIGHER_LOW |
base_30_coverage | PASS | BASE_30_COVERAGE |
base_30_prior_leg | FAIL | BASE_30_PRIOR_LEG |
base_30_depth | PASS | BASE_30_DEPTH |
base_30_contraction | FAIL | BASE_30_CONTRACTION |
base_30_higher_low | FAIL | BASE_30_HIGHER_LOW |
base_40_coverage | PASS | BASE_40_COVERAGE |
base_40_prior_leg | FAIL | BASE_40_PRIOR_LEG |
base_40_depth | FAIL | BASE_40_DEPTH |
base_40_contraction | FAIL | BASE_40_CONTRACTION |
base_40_higher_low | FAIL | BASE_40_HIGHER_LOW |
base_selected | FAIL | BASE_SELECTED |
ENGINEERING DESIGN
My system design.
I independently designed how the agents, strategy rules and execution fit together, with clear contracts, persistent state and visible decision records.
A durable handoff
Model latency should not hold up time-sensitive rules.
The rule decision commits first. A separate SQLite-backed queue feeds the advisory worker, with leases and explicit failed, skipped and reused states.
Clear failure boundaries and inspectable task state.Implementation reference
agents/queue.py · agents/orchestrator.pyContracts around the model
Fluent output needs a connection to the actual evidence.
Each role receives a scoped fact set. Typed responses carry evidence and counter-evidence; validation rejects unknown references and unsupported price levels.
Traceable opinions with explicit uncertainty.Implementation reference
agents/context.py · agents/models.pyRecoverable execution
A network timeout can leave an order’s outcome unknown.
Risk reservation and the order outbox share a transaction. A single execution owner reconciles the original order identity, deduplicates broker events and tracks protection against actual fills.
Persistent state for retries, restarts and partial fills.Implementation reference
ledger.py · executor.pyAn observable workflow
An operator needs to explain both actions and inaction.
The decision graph connects source snapshots, rule checks, agent spans, costs and execution events. Replay uses when records became known to the system.
A decision can be inspected through its evidence.Implementation reference
decision_graph/view.py · QmlDecisionGraph.tsxA shared cost gateway reserves budget before each billable attempt. Concurrency, retries and deadlines are bounded; unknown usage retains a reservation. Exhausting analysis budget does not stop existing position management.
SCOPE & EVIDENCE
What the case demonstrates.
Implemented application
Agent role contracts, a durable advisory queue, rule-based strategies, risk reservation and outbox, paper-broker integration, position management and a read-only decision graph.
Architecture checked against the current private codebase on 04 Nov 2026. The original design document provides context; current code and saved records support the implementation shown here.
Recorded demonstration
The case uses an allowlisted export of a RUN decision and a separate premarket status snapshot. Model calls were disabled in the earlier premarket status snapshot. The interactive role panels explain the architecture; they do not simulate successful model responses.
This is engineering evidence from a paper-trading project. Actual-fill, partial-fill and held-position recovery acceptance remains incomplete; the case makes no investment-performance claim. Grok supervision, MCP and cloud hosting remain future design scope.
Read the complete application flow and implementation references
| Stage | Responsibility & artifact | Implementation |
|---|---|---|
| Freeze the evidence | Market data, indicators and the candidate set are saved with their availability times and strategy version.Decision-time frame | agents/context.py |
| Evaluate the rules | Breakout, Pullback and EP have separate qualification and trigger checks. Waiting and rejected decisions are recorded too.Rule decision + reason codes | strategies/engine.py |
| Reserve and execute | A valid signal must pass risk checks. Reservation and an outbox action commit together before the sole execution path contacts the paper broker.Risk reservation + durable order intent | ledger.py |
| Manage the lifecycle | Broker events update actual fills, position plans and protection. Unknown submissions are reconciled using the original order identity.Execution ledger + protection state | executor.py |
| Analyse asynchronously | An independent durable worker distributes the saved facts to four specialists, gathers their states and runs Synthesis. Model work does not block rule execution.Versioned assessments + spans + costs | agents/orchestrator.py |
| Review the facts | After the exchange closes, a factual report can feed a separate Prime review. Hypotheses remain research inputs.Factual report + review record | agents/review.py |
APPLY THIS TO YOUR WORKFLOW
Need agents that work
with your business systems?
I build AI applications with defined responsibilities, tool integrations and a clear record of what happened.