SBCJuly 31Flashbots

The Trading Agent Loop: How to build Claude Code for trading_

Coding agents became useful when they learned to determine intent, read context, change files, test the result, and loop on failure. Michael Feng maps that pattern onto trading: define a measurable strategy, collect and clean the right data, backtest without fooling yourself, promote cautiously into live markets, and feed every failure back into an isolated, repeatable operating loop.

speaker Michael Fengruntime 16:56format talkreading time ~8 min

Watch on Youtube

tl;dr

›
The breakthrough is a verified loop, not a more fluent chatbot.

A coding agent determines intent, reads the environment, edits files, and tests its work; failed verification sends it around again. A trading agent needs the same feedback structure, with market-facing tools and evidence replacing code alone. The test makes failure actionable instead of merely descriptive.

›
A trading objective must become a testable specification.

The loop defines strategy logic, adjustable and fixed parameters, metrics, risk limits, and shutdown conditions; then it collects data, runs a backtest, begins with paper trading, and scales live capital only when observations support the original assumptions. Every stage must leave evidence for the next one.

›
Isolation is what makes repeated experimentation survivable.

Domain expertise, token efficiency, reliable data, long-running autonomy, execution, and key security remain practical gaps. The proposed harness separates attempts across strategies, while a builder competition supplies concrete feedback about what people can create and where the system fails. Operational constraints are part of the research method.

If you're new to any of this

A trading agent is not just a chatbot with an exchange key. In Michael Feng’s proposal, Hummingbot supplies deterministic market connections while Condor gives model-driven agents a guarded place to reason, use tools, and receive feedback.[3][4][5][6]

The workflow moves from defining a strategy and gathering context to backtesting it on history, then paper trading before live execution. Isolation matters because the language model proposes actions while deterministic software enforces permissions, risk limits, and order submission.[7][6]

›A bit more background

A backtest asks how a fixed strategy would have behaved on historical data; paper trading rehearses it against live data without risking capital. Neither guarantees future profit: historical tests can overfit, while paper trading still misses real fills, slippage, and market impact. The loop therefore promotes strategies gradually while deterministic execution software enforces keys, venue permissions, and risk limits.

Show slides
01

A coding agent erodes the framework’s old advantage

Seven years ago, I sat in a meeting like this and described Hummingbot for the first time. Hummingbot is open-source software: public software that people can download and use. A lot of users are projects looking to market make their own token; others are individuals looking to farm rewards, or market makers who want to start with some piece of software. Because we already connect to lots of exchanges and have open-source strategies, it is a natural place to start.

Black slide asking whether Hummingbot is still needed if Claude can build anything for the user.
slide 03A coding agent challenges the need for a fixed trading framework.

A coding agent changes that calculation. I asked Claude to build a simple Binance market-making bot; soon afterward I had code that basically worked. It was not Hummingbot, but I owned it and could customize it. For a narrow task, that may be enough to skip the packaged framework.

“Ten minutes later, you have a simple market-making bot that basically works.”

— Michael Feng
Diagram contrasting a ChatGPT chatbot with a Claude Code coding agent, connected by a right-pointing arrow.
slide 04The interface shifts from conversational chatbot to tool-using coding agent.

We have seen that change in our own revenue as people use AI to bypass the framework. It is not only Hummingbot’s problem; much of open-source software risks being disintermediated in the same way. The question for us is what to build when generating a first version of the software becomes cheap.

02

Tests turn a chatbot answer into a working loop

To me, the breakthrough is the coding-agent loop. Its tools do four things really well. First, the agent takes a prompt and figures out what you are trying to do: it determines your intent. Second, it reads the files and accesses other context. Third, it edits those files. Fourth, it tests the changes. Those steps turn a chatbot response into a process that can act on an existing system and use feedback instead of stopping after one plausible answer.

For me, testing is essential because a unit test or browser check tells the agent whether its change worked. If it did not, the agent returns to the loop. Trading needs an equivalent test, not merely plausible strategy text.

“That fourth step is very critical because when running unit tests, by verifying what they did in Playwright, they can know whether the change they made actually solved what they’re trying to do.”

— Michael Feng
Coding-agent feedback loop connecting determine intent, read files, edit files, and test changes back into earlier stages.
slide 06Intent, context, edits, and tests form a verified coding loop.
03

A profit goal must become a testable specification

The first step is to define something you can actually test. If the user simply says to make money, the agent should ask whether that means a directional strategy, an arbitrage strategy, or a market-making strategy. What is the goal? What is the time frame? What metrics will evaluate it? Those choices define the target that data collection, backtesting, and live evaluation will later test.

Next, the agent defines the strategy logic and what it must do when its conditions are met. It separates parameters that can change—such as trade amounts and spreads—from the parts that cannot. That gives the later backtest a specific strategy to evaluate instead of an instruction that changes with every result.

Finally, the same specification needs guardrails: the risk limit and the conditions under which the agent must stop trading. At the end of this first step, I want a Markdown strategy file plus configuration. The loop now has an artifact it can test and revise rather than an intention trapped inside a chat.

“Define Strategy” slide listing objectives, execution logic, adjustable parameters, and risk/shutdown guardrails.
slide 09A testable strategy fixes objectives, logic, parameters, and risk guardrails.
04

The hypothesis decides which data the loop must collect

The second step is to collect whatever data is driving the hypothesis: candles, liquidations, open interest, or another market signal. The loop has to make sure it can access that data, sample and convert the raw observations into signals, clean and deduplicate the records, and verify that the result is usable. It also has to keep collecting the data over time rather than stop at one convenient snapshot.

“Collect Data” slide listing access, conversion, cleaning, and accumulation steps for backtesting inputs.
slide 10Data collection covers access, conversion, cleaning, and continuous accumulation.

Backtesting then runs the specification through history. The loop splits in-sample and out-of-sample periods, executes the strategy logic, checks the guardrails, measures the chosen metric, and sweeps parameters without letting the search simply overfit the data it already saw.

“Backtest Strategy” slide listing in-sample versus out-of-sample splits, process guardrails, metrics, and overfitting prevention.
slide 11Backtests separate samples, inspect guardrails, measure results, and resist overfitting.
05

Paper trades test assumptions that history cannot

Promotion begins with a paper trade and then a small amount of capital. The loop monitors fills, P&L, and other real data points, compares them with the backtest, and asks whether the strategy assumptions were actually validated. Historical execution cannot reproduce every live condition. The staged rollout supplies the next test: scale what works and kill the strategy when its assumptions do not hold.

“Promote to Live Trading” slide sequencing paper tests, monitoring, backtest comparison, and careful scaling in real markets.
slide 12Live promotion begins on paper, then scales capital cautiously.

This has to be a loop because the first version usually fails. A live failure may send the process back to the strategy, the data, or the backtest. Deployment is another source of feedback, not the end of the process.

Complete trading-agent feedback loop connecting define strategy, collect data, backtest strategy, and promote to live trading.
slide 13Failures route the four-stage trading loop back toward revision.

Quantitative hedge funds already run this process by putting researchers, engineers, data scientists, and traders around it. That would turn one sequential workflow into a portfolio-scale research process. The immediate question is how much of that loop Claude can actually handle.

“Ideally, what you want is a harness that can help you do all these steps in isolation, and then do that in parallel across different strategies.”

— Michael Feng
06

Autonomous trading creates a private-key problem

In my experience, Claude does not run this whole loop very well. It does not really have the domain expertise to help define a proper strategy, and a serious loop can burn through an entire token budget in half an hour. How much data is available to it? Can it run over a long period of time autonomously? Can it actually execute trades? Each gap can interrupt the feedback loop before it reaches live operation.

Question about running the loop in Claude Code above six requirements: domain expertise, token efficiency, data availability, autonomy, execution, and security.
slide 14Trading agents need expertise, efficiency, data, autonomy, execution, and security.

Security is the most important gap. If the server signs transactions automatically, how do we keep its private key from being compromised? A model that proposes a trade still needs a safe path to execution before this loop can control real capital.

Condor project logo and the URL condor.hummingbot.org on a dark textured background.
slide 15Condor is introduced as the open-source trading-agent harness.

Those questions are why we built Condor. It is a generic harness that uses Hummingbot as the execution layer and is meant to supply the missing environment around a trading agent. The goal is to let people exercise the loop, encounter the operational gaps, and tell us what the harness still needs.

07

Condor is the experiment, not the finished answer

Condor is open source and available to try, but I warn users that it remains experimental and ask them to expect issues. The release is an invitation to test the architecture and give us feedback, not evidence that autonomous trading has already been solved.

“It’s very much a work in progress though, so don’t be surprised if you have any issues.”

— Michael Feng
Agent Builders Cup announcement with prize amount, hackathon and competition dates, exchange-team tiles, and botcamp.xyz.
slide 16A builder competition turns live agents into harness feedback.

We are also running a builder competition with exchange partners. It takes place over a one-month period, during which participants build agents for the participating exchanges. Afterwards, we work with the exchanges to select the top agents for a live trading competition. This is our way to get feedback on Condor, see what people build, and use what they encounter to make a better harness.

That competition is part of the same test cycle as the trading-agent loop. Condor is still a work in progress; putting it in builders’ hands is how we expose what the harness can and cannot yet support.

Glossary

agentic workflow — A tool-using process in which some steps are predefined while an agent dynamically chooses later actions from environmental feedback, checks intermediate results, and deliberately revises its path when verification fails.[7]

backtest — A simulation that applies a specified strategy to historical data. Its validity depends on repeatable and realistic execution, clean inputs, held-out evaluation, faithful performance metrics, and active resistance to overfitting.[4]

paper trading — A live-market rehearsal that records hypothetical orders without risking capital. It tests timing, data, and operations before a strategy receives small real positions under close monitoring and careful scaling.[4]

execution isolation — A boundary separating probabilistic model reasoning from deterministic order submission and risk controls, so generated decisions cannot directly bypass capital, venue, position, signing-key, or other operational safeguards.[6]

References

  1. [01]Flashbots at SBC 2026 — Flashbots CollectiveFlashbots’ event recap lists the Agentic MEV agenda, speakers, and recordings.
  2. [02]fengtality — Michael FengMichael Feng’s GitHub profile and public software repositories.
  3. [03]From Hedge Fund to Market Making Bot: The Hummingbot Origin Story — HummingbotFeng recounts Hummingbot’s evolution into open-source trading software.
  4. [04]Hummingbot Documentation — HummingbotHummingbot is an open-source framework for automated market making and algorithmic trading.
  5. [05]Introduction — Condor / HummingbotCondor is an open-source harness for managing fleets of AI trading agents.
  6. [06]Trading Agents Overview — Condor / HummingbotCondor separates LLM reasoning from deterministic execution and isolates agent positions.
  7. [07]Building effective agents — AnthropicAnthropic distinguishes predefined LLM workflows from agents that direct their own tools.