ASK KNOX
beta
LESSON 671

What Is a Trading Agent?

A trading agent is not a better indicator — it is an autonomous control loop that perceives market state, decides, acts on a venue, and reconciles intent against reality, running unattended 24/7.

8 min read·Trading Agent Fleets

The thing most people build first is not a trading agent

When most people automate a trading strategy, they build a script. It fetches a price, runs a calculation, places an order, and exits. Then they add a cron job to run it every hour. They call it an automated trading system.

It isn't.

A trading agent is something qualitatively different. Not just more code, and not just a fancier indicator. A trading agent is an autonomous control loop — a process that perceives market state, makes a decision, acts on a venue, and then does something a script can never do: it checks whether what it intended actually happened, and responds accordingly.

That reconcile step is the entire story. It is also what most automated systems skip, and why most of them eventually fail in ways that are invisible until they are expensive.

The four-step loop

Every trading agent, regardless of strategy or asset class, is a closed loop over four steps.

Walk it left to right, then follow the feedback wire back.

Perceive is where the agent reads market state — prices, order book depth, recent candles — from a live data feed. This is not a one-shot read; the agent keeps the feed open and processes each new update.

Decide is where the agent scores what it perceived. A signal engine turns market state into a directional intent: go long, go short, stay flat. The score includes confidence. Below a certain confidence threshold, the agent does nothing.

Act is where the agent submits orders to the exchange. For a futures agent this typically means placing a bracket: an entry order plus a stop-loss and a take-profit. The act step is the only moment the agent reaches outside its own boundary to the exchange.

Reconcile is the step that makes this a control loop instead of a pipeline. After acting, the agent asks the exchange: what do you show as my current position? It compares that answer against its own model of what it intended. If they match, the loop continues. If they diverge — a partial fill, a rejected bracket, an exchange-side error — the reconciler decides what to do: retry, adjust, or halt safely.

The loop wire from reconcile back to perceive is what you are building when you build an agent. Without it, you have a one-shot script.

What it is not

The loop diagram makes it easy to see the contrast with two approaches people often mistake for agents.

A discretionary human trader performs all four steps — they perceive, decide, act, and reconcile manually. The agent replaces the human in the loop. The agent's advantage is not intelligence; it is availability (24/7, no fatigue) and speed (milliseconds, not minutes). Its disadvantage is that it cannot exercise judgment outside its programmed parameters, which is why the halt state is safety-critical: when reality diverges from the model in a way the agent cannot handle, stopping is the correct response.

A script or cron performs perceive, decide, and act — but then exits. It has no reconcile step and no ongoing model of position state. This works in the ideal case where every order is filled exactly as specified. It fails silently when reality diverges, because the script is not running to notice. The cron fires again an hour later with no memory of what happened before.

The defining characteristic of an agent is not the quality of its signal. It is the presence of a running, stateful reconcile loop.

The intent-to-reality seam

The hard problem in building a trading agent is not picking the right indicator. It is managing the seam between what the agent believes about its own position and what the exchange has actually recorded.

This seam is where most agent failures occur. Not because the signal was wrong — the signal might have been perfectly correct. But because:

  • The order was submitted but only partially filled
  • The bracket was accepted, but one leg was silently rejected
  • The agent's position model said "flat" when the exchange showed "long 0.3 BTC"
  • A network partition caused the agent to miss a fill confirmation, so it submitted the order twice

Every one of these failures is invisible to a system without a reconcile step. The agent's internal model diverges from exchange reality, and every subsequent decision is made against the wrong ground truth. The losses compound quietly until something forces a reconciliation — usually a margin call, a liquidation, or a human noticing the P&L doesn't add up.

The reconcile step is the mechanism for closing this gap continuously, every tick, before small divergences become large ones.

The four pillars of this track

This lesson introduced the loop. The rest of the track builds each part of it at production depth.

The next two lessons cover the anatomy — how the five subsystems fit together, and how to pick the right venue for your agent's strategy. From there the track goes into signal engineering, risk and profit math, execution integrity, and finally fleet operations: running multiple agents as a coordinated system rather than a collection of scripts.

Throughout, the emphasis will be on the reconcile step. Every lesson that covers a failure mode will trace it back to a divergence between agent intent and exchange reality, because that is where the real work is.

Build it: model the agent control loop as a typed state machine

You are going to turn the four-step loop into a minimal TypeScript state machine. The state union must include a HALTED state that the reconcile logic can force. The tick() function is the loop: it reads the current state and agent context, transitions, and returns the next state. Make HALTED terminal — if reconcile forces the agent there, only an operator can clear it.

What is next

The loop is the architecture. Now you need to see the subsystems inside it. Lesson 672 dissects the anatomy of a production trading agent: the five subsystems, their contracts with each other, and why the data flow is deliberately one-directional except for the reconcile feedback wire. After that, lesson 673 covers venue selection — because where you trade shapes every decision your agent makes about margin math, reconciliation, and risk.