0:00
/
Generate transcript
A transcript unlocks clips, previews, and editing.

IRan 82 AI-Built CME Trading Bots in Python. Most Failed. Here’s Why 3 Printed Money.

The brutal math of Micro Futures, why autonomous agents will burn your API budget to the ground, and the 90-minute rule that keeps quants from bleeding out.

Most retail algorithmic traders spend six months building a single “masterpiece” algorithm, optimize it until it fits historic curve noise like a glove, fund it with real capital, and watch it bleed out in three weeks.

Institutions don’t operate like that.

They don’t bet on single bots; they deploy fleets. They test across multiple instruments simultaneously, track order flow, cut the losers without emotional attachment, and keep the select few that ride current market volatility.

Over the past few weeks, I’ve been running an experiment running upwards of 82 automated CME futures trading bots simultaneously in Python, streaming live market data through Rithmic.

The aggregate win rate across the entire fleet was a mediocre 46%.

If you ran all 82 together, you’d slowly grind your account into the dirt. But when you dissect the distribution, something fascinating emerges: while the majority chopped sideways or took steady hits, a small cluster—specifically targeting Micro E-mini S&P (MES) and Micro Bitcoin (MBT)—logged 100% win sessions.

Here is the unvarnished breakdown of what works, what completely breaks, the architecture holding it together, and why your bot is probably giving back all its profits every day at 11:30 AM.


1. Stop Trading Full Contracts (And Stop Trading Tick Data)

If you’re deploying retail algorithms on CME full-size Bitcoin (BTC) or E-mini (ES) contracts, your position sizing is likely broken before your script even runs line one.

Full-size contracts carry margin requirements that force retail accounts to overleverage. Institutional desks know this; all the actionable retail and intraday momentum volume has concentrated inside the Micro contracts (MES, MBT, 6J).

The second mistake is compute vanity: sub-second tick execution.

Beginners obsess over raw tick data. Unless you have co-located hardware sitting inside the Aurora, Illinois data center running proprietary C++ bridges, processing every market tick is pure overhead. It adds compute lag, desynchronizes state, and introduces execution noise.

Every single bot in this fleet strips out tick parsing. We execute strictly on closed-bar event triggers.

If a strategy requires tick-level micro-arbitrage to be profitable, you aren’t trading an edge—you’re just subsidizing your broker’s clearing fees.


2. The $19,000 AI Agent Trap

Almost everyone using AI to code trading bots is doing it wrong.

Last week, an engineer made waves in dev communities after running autonomous multi-agent developer frameworks overnight without hard spend throttles. He woke up to an API bill exceeding $19,000.

Why? Because when you tell open-ended autonomous agents to “build a trading bot,” they fall into infinite recursive clarification loops, generate massive state dumps, and burn hundreds of thousands of input/output tokens rewriting the same boilerplate logic.

xl

THE REALITY OF LLM TRADING CODE:

Bad: "Autonomous Agent Swarm" -> Infinite loops -> Hallucinated API calls -> $19,000 bill
Good: Modular prompts -> Deterministic Python functions -> Pennies per script

You do not need heavy frontier models or unconstrained agent loops to generate institutional-grade logic.

For 95% of quant execution code:

  • Avoid models that interrogate you: If a model insists on asking 15 clarifying questions before writing a single function, ditch it.

  • Use low-cost, fast token throughput models: High-speed, high-context-efficiency models like Claude Haiku or calibrated open-weights like Qwen 2.5/3.5 can write complete, bug-free dynamic ATR trailing stops, Redis message parsers, or risk-reward classes for pennies.

  • Keep generation atomic: Don’t ask an LLM to build the bot, the backend, the database, and the risk engine in one prompt. Have it generate discrete, modular classes that fit into your existing, battle-tested chassis.


3. The Architecture: Redis Pub/Sub

When you run 80+ algorithms, you cannot let each bot open its own independent websocket or broker API stream. You will get rate-limited, your memory will spike, and your execution latency will compound.

The spine of this entire setup is built on an open-source Redis Publisher/Subscriber (Pub/Sub) pattern:

json

 [ CME Market Feed (Rithmic/IBKR) ]
                 │
                 ▼
      [ Ingestion Engine ]
                 │
                 ▼ (Publish to Channel)
      ┌─────────────────────┐
      │   Redis Message Bus  │
      └─────────────────────┘
         │         │         │ (Subscribers)
         ▼         ▼         ▼
    [ Bot 1: MES ] [ Bot 2: MBT ] [ Bot 3: 6J ]
  1. One Ingestion Engine: A single dedicated Python service connects to the broker API and handles the raw market feed.

  2. The Message Bus: Inbound closed bars are formatted as clean JSON payloads and published to internal Redis message channels.

  3. The Fleet (Subscribers): Each bot subscribes only to the instrument it trades (cme.mes.bars, cme.mbt.bars).

The bot contains zero broker dependencies. It receives a bar, runs its mathematical evaluation, and if a trade condition triggers, emits an order payload back to an execution queue.

Because the trading logic is decoupled from broker APIs, you can swap your clearing broker from Rithmic to Interactive Brokers (IBKR) or NinjaTrader without changing a single line of your core trading strategy.


4. The 11:30 AM “Amateur Hour” Phenomenon

Look at the cumulative PnL of failing trading algorithms, and you will almost always see the same intraday curve:

  1. 9:30 AM – 11:00 AM: Strong, sharp upward equity momentum.

  2. 11:30 AM – 1:30 PM: Steady, choppy, bleeding drawdown that wipes out the morning gains.

  3. 2:00 PM – 4:00 PM: Erratic, revenge-driven whipsaws into market close.

There is a mechanical reason for this.

The first 90 minutes of the US market open are dominated by institutional order flow, index rebalancing, and true liquidity expansion. Momentum models feast here because price actually follows through.

Between 11:30 AM and 1:30 PM EST, institutional block desks step away for lunch. Volume drops. Liquidity thins out. Floor traders refer to this window as “Amateur Hour.” The market turns into a low-volume, mean-reverting chop shop designed to trigger stops on retail trend-followers.

If your bot runs 24/7 without session controls, you are handing your money right back to the market makers.

The Fix: Code a hard-target daily circuit breaker.

If your fleet hits a combined 1% to 2% portfolio equity target during the morning session: kill the bots. Shut down execution. Lock in the realized PnL.

Rule #1 of trading: Don’t lose money. Rule #2: Remember Rule #1.


5. Inspecting the Real-Time Winners

When we let real market data filter the fleet, the losers reveal themselves quickly (e.g., rigid moving-average cross strategies in low-volatility regimes). But the outliers stood out immediately:

  • Micro Bitcoin (MBT) Volatility Breakout: Caught news-catalyst momentum swings driven by regulatory headlines and Fed interest rate expectations. Managed entirely via dynamic ATR risk boundaries instead of static dollar stops. (4 trades, 4 wins).

  • Micro E-mini (MES) Momentum: Capitalized strictly on the 9:30–10:30 AM volume surges, targeting high-probability liquidity sweeps. (4 trades, 4 wins).

  • 10-Year Treasury Note (ZN): Exploited rate volatility with zero overnight carry risk.

The objective isn’t to fix a bot that took 5 trades and lost 4. You discard it.

By industrializing strategy creation using modular Python, you let market survival dictate what stays in your portfolio. You promote the 100% win-rate performers to paper-trading validation, then to micro-sized live capital, and eventually to full-sized institutional contracts.


Download the Source Code (Free)

Rather than keeping this theoretical, I’ve open-sourced the complete, self-contained Python source code for three of these bots:

  1. CME Micro Bitcoin (MBT) News & Momentum Bot

  2. Japanese Yen (6J) EMA Volatility Strategy

  3. Nasdaq 100 (NQ) Short-Selling Algorithm

Each script is over 500 lines of type-hinted, fully commented Python 3.10+ code featuring dynamic ATR multipliers, draw-down controls, and decoupled execution placeholders.

You can download all three files completely free at HFTCode.com.

Inspect the code, test the logic against your own data feeds, and reverse-engineer the Redis framework.


What CME contracts are you currently running algorithms on? Have you noticed your bots bleeding out during the midday lunch chop? Let’s talk in the comments below.

Discussion about this video

User's avatar

Ready for more?