← All work

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.

ACTUAL APPLICATIONCaptured interface · Paper trading

Scroll the screenshot horizontally to inspect the interface, or open it at full size.

QML TRADING WORKSPACERUN CAPTURED VIEW
Actual QML trading workspace for RUN. Daily and five-minute candlestick charts sit beside the current rule and protection panel. The snapshot shows no rule evaluation or QML position for this asset.

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.

Open full-size screenshot
Linked chart views

Daily structure and five-minute price action share crosshair and navigation context.

Visible data quality

Adjustment basis, indicator availability and missing intervals appear in the interface.

Action context

Rule state and protection context sit beside the charts, with absence shown explicitly.

SCREENSHOT · 04 NOV 2026

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 screenshot

Decision 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 screenshot

HOW 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.

IMPLEMENTED ARCHITECTUREClick an agent to follow its handoff
Rule & execution pathOwns trading actions
01 / INPUTFrozen evidenceData + timestamps + versions
02 / DECISIONStrategy & risk rulesQualification → trigger → reservation
03 / ACTIONPaper executionOutbox → broker → fills → protection
Saved decision-time facts → independent analysis queue
Agent analysis pathAdvisory · Does not block execution
Gather opinions, failures and skipped states

One structured assessment.
Evidence, counter-evidence and unknowns.

SEPARATE POST-CLOSE JOBExecution ledger → factual reportRecorded fills, incidents and known outcomes

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
Complete agent contracts · Readable without JavaScript
RoleInputOutput & handoff
MarketFrozen 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.
TechnicalSaved 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.
EventCatalyst 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.
ThemeRecorded 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.
SynthesisThe 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 reviewA 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.

RECORDED DECISION

RUN / BREAKOUT

03 Nov 2026 · 17:15:15 UTC · Paper experiment

WAIT Daily qualification failed
02 / SETUP

Breakout qualification failed

The strategy recorded failed daily-structure checks, including the rising moving-average condition and base-selection checks. The outcome remained WAIT.

RECORDED CHECKS18 passed · 16 failed
Inspect all 34 check results
Original rule identifiers and reason codes · Saved decision
RuleResultReason code
daily_currentPASSDAILY_CURRENT
corporate_actionsPASSCORPORATE_ACTIONS
daily_history_contiguousPASSDAILY_HISTORY_CONTIGUOUS
candidate_qualifiedPASSCANDIDATE_QUALIFIED
atr20_availablePASSATR20_AVAILABLE
adr20_setupPASSADR20_SETUP
close_above_sma50PASSCLOSE_ABOVE_SMA50
sma20_risingFAILSMA20_RISING
base_10_coveragePASSBASE_10_COVERAGE
base_10_prior_legFAILBASE_10_PRIOR_LEG
base_10_depthPASSBASE_10_DEPTH
base_10_contractionFAILBASE_10_CONTRACTION
base_10_higher_lowPASSBASE_10_HIGHER_LOW
base_15_coveragePASSBASE_15_COVERAGE
base_15_prior_legFAILBASE_15_PRIOR_LEG
base_15_depthPASSBASE_15_DEPTH
base_15_contractionFAILBASE_15_CONTRACTION
base_15_higher_lowPASSBASE_15_HIGHER_LOW
base_20_coveragePASSBASE_20_COVERAGE
base_20_prior_legFAILBASE_20_PRIOR_LEG
base_20_depthPASSBASE_20_DEPTH
base_20_contractionFAILBASE_20_CONTRACTION
base_20_higher_lowFAILBASE_20_HIGHER_LOW
base_30_coveragePASSBASE_30_COVERAGE
base_30_prior_legFAILBASE_30_PRIOR_LEG
base_30_depthPASSBASE_30_DEPTH
base_30_contractionFAILBASE_30_CONTRACTION
base_30_higher_lowFAILBASE_30_HIGHER_LOW
base_40_coveragePASSBASE_40_COVERAGE
base_40_prior_legFAILBASE_40_PRIOR_LEG
base_40_depthFAILBASE_40_DEPTH
base_40_contractionFAILBASE_40_CONTRACTION
base_40_higher_lowFAILBASE_40_HIGHER_LOW
base_selectedFAILBASE_SELECTED
Saved evidence · Offline inspector

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
RECORDED CHECKS6 passed · 0 failed
Inspect all 6 check results
Original rule identifiers and reason codes · Saved decision
RuleResultReason code
security_eligiblePASSSECURITY_CLASSIFICATION
previous_close_minPASSR2_THRESHOLD
market_capPASSR2_THRESHOLD
adv20_dollarPASSR2_THRESHOLD
volatility_weekPASSR2_THRESHOLD
close_above_ema21PASSR2_THRESHOLD
RECORDED CHECKS18 passed · 16 failed
Inspect all 34 check results
Original rule identifiers and reason codes · Saved decision
RuleResultReason code
daily_currentPASSDAILY_CURRENT
corporate_actionsPASSCORPORATE_ACTIONS
daily_history_contiguousPASSDAILY_HISTORY_CONTIGUOUS
candidate_qualifiedPASSCANDIDATE_QUALIFIED
atr20_availablePASSATR20_AVAILABLE
adr20_setupPASSADR20_SETUP
close_above_sma50PASSCLOSE_ABOVE_SMA50
sma20_risingFAILSMA20_RISING
base_10_coveragePASSBASE_10_COVERAGE
base_10_prior_legFAILBASE_10_PRIOR_LEG
base_10_depthPASSBASE_10_DEPTH
base_10_contractionFAILBASE_10_CONTRACTION
base_10_higher_lowPASSBASE_10_HIGHER_LOW
base_15_coveragePASSBASE_15_COVERAGE
base_15_prior_legFAILBASE_15_PRIOR_LEG
base_15_depthPASSBASE_15_DEPTH
base_15_contractionFAILBASE_15_CONTRACTION
base_15_higher_lowPASSBASE_15_HIGHER_LOW
base_20_coveragePASSBASE_20_COVERAGE
base_20_prior_legFAILBASE_20_PRIOR_LEG
base_20_depthPASSBASE_20_DEPTH
base_20_contractionFAILBASE_20_CONTRACTION
base_20_higher_lowFAILBASE_20_HIGHER_LOW
base_30_coveragePASSBASE_30_COVERAGE
base_30_prior_legFAILBASE_30_PRIOR_LEG
base_30_depthPASSBASE_30_DEPTH
base_30_contractionFAILBASE_30_CONTRACTION
base_30_higher_lowFAILBASE_30_HIGHER_LOW
base_40_coveragePASSBASE_40_COVERAGE
base_40_prior_legFAILBASE_40_PRIOR_LEG
base_40_depthFAILBASE_40_DEPTH
base_40_contractionFAILBASE_40_CONTRACTION
base_40_higher_lowFAILBASE_40_HIGHER_LOW
base_selectedFAILBASE_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.

01

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 referenceagents/queue.py · agents/orchestrator.py
02

Contracts 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 referenceagents/context.py · agents/models.py
03

Recoverable 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 referenceledger.py · executor.py
04

An 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 referencedecision_graph/view.py · QmlDecisionGraph.tsx
BOUNDED MODEL WORK

A 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
Current QML flow · Private codebase · Reviewed 2026-11-04
StageResponsibility & artifactImplementation
Freeze the evidenceMarket data, indicators and the candidate set are saved with their availability times and strategy version.Decision-time frameagents/context.py
Evaluate the rulesBreakout, Pullback and EP have separate qualification and trigger checks. Waiting and rejected decisions are recorded too.Rule decision + reason codesstrategies/engine.py
Reserve and executeA 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 intentledger.py
Manage the lifecycleBroker events update actual fills, position plans and protection. Unknown submissions are reconciled using the original order identity.Execution ledger + protection stateexecutor.py
Analyse asynchronouslyAn 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 + costsagents/orchestrator.py
Review the factsAfter the exchange closes, a factual report can feed a separate Prime review. Hypotheses remain research inputs.Factual report + review recordagents/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.

Discuss an AI Application