top of page

Get auto trading tips and tricks from our experts. Join our newsletter now

Thanks for submitting!

How I Built an AI Trading Bot Python for Options Chain with Claude Code Architecture Breakdown



Discover how to build dynamic AI trading bot Python that analyze CME futures options chains in real-time using Claude Opus 4.6, Python automation, and Rithmic market data -- the institutional-grade approach retail traders are missing.




Introduction: Why Options on Futures Are the Real Edge in 2026


If you have been trading only equities, ETFs, or even spot crypto, you are operating in a fraction of the market that actually moves prices. The real institutional activity -- the kind that drives the price of Bitcoin, gold, oil, and the S&P 500 -- happens in the options on futures market. And in 2026, the only practical way to keep up with that complexity is to build AI trading bots that can dynamically generate strategies from live news, discover option chains in real time, and manage concurrency across a fleet of autonomous Python trading bots.



This article breaks down exactly how I built a system that does all of that: an AI-powered options chain trading system running on CME market data via the Rithmic API, orchestrated by Claude Code in VS Code, and generating institutional-level analysis that would normally require an entire quant desk. Whether you are a retail quant looking to level up, a developer exploring vibe coding for finance, or someone trying to understand what institutional options trading actually looks like in practice, this is the architecture walkthrough you have been waiting for.



The Problem: Why Most Retail Traders Get Destroyed in Options on Futures


Let me be direct about something most trading educators will not tell you. If you are a retail trader in Bitcoin, Ethereum, gold, or oil and you do not understand what institutions are doing at the options level, you are guessing. You can use all the charts you want. You can consume all the news feeds available. It will not help you, because you are not seeing what actually drives price.


Here is what I mean. When you look at the CME volume distribution on any given trading day, the E-mini S&P 500 (ES) dominates both the options and futures space by volume. Then you get into instruments like the Euro FX (6E), Bitcoin (BTC), and gold (GC). The more volume an instrument has, the higher the probability of tradeable waves. But here is the critical insight: a massive proportion of that volume is now driven by the options market, not the futures market alone.



The types of instruments being actively traded right now include energy options, crypto options, equity index options, FX metals options, interest rate and SOFR options, and volatility products. All of these create a web of institutional positioning that retail traders simply cannot see from a standard charting platform.


This is why I spent 10 days debugging and building out the most complicated asset class integration I have ever attempted: options on futures. Not options on stocks -- options on CME futures contracts. The difference in data complexity, concurrency requirements, and analytical depth is enormous.




The Architecture: How AI Trading Bot Python Get Dynamically Generated from News


News-Driven Bot Generation with Python and LLMs


The core concept of the system is deceptively simple but extraordinarily difficult to implement at scale. A master Python script goes out, captures financial news from institutional-grade sources, and then an AI model analyzes that news to dynamically generate trading bot strategies. Each bot is a complete Python script -- typically 800 to 1,600 lines of code -- containing a full trading strategy designed around a specific news-driven market thesis.


For example, on a single run, the system generated the following bots based on that day's news:


  • Gold Future Call Spread with Risk Reversal: A long gold call spread financed by a short put risk reversal to capture geopolitical tail hedging demand while reducing premium outlay.

  • Brent Crude Calendar Spread: Exploiting geopolitical risk premium fluctuations in front-month versus second-month Brent crude futures.

  • Bitcoin-Ethereum Futures Beta Justice Spread: Capturing the institutional flow dynamics between BTC and ETH futures on CME.

  • SOFR Future Curve Steepener with Option Overlay: Trading the overnight rate curve with conditional options protection.

  • E-mini S&P Put-Call Spread Collar: Standard institutional hedging structure.

  • CME Bitcoin Option Condor with Dynamic Delta Hedge: Capturing volatility premium while maintaining delta neutrality.

  • Euro-USD FX Future Risk Reversal with Option Overlay: Directional macro positioning with defined risk.

  • VIX Futures Call Overlay for Equity Gap Risk: Tail risk hedging through volatility options.


Each of these bots is not hand-coded. They are dynamically created by AI based entirely on the news analysis. The AI designs the strategy, determines the optimal instrument, selects the strike prices, and generates the complete executable Python code. This is what I mean when I say hand coding is dead. If you want to get a solution done faster, this is how you do it.


The 22-Page Institutional Analysis Report


Before the bots get created, the system produces a comprehensive institutional analysis report -- typically 22 pages or more -- covering four major classifications:


  1. Crypto Futures and Options Institutional Read-Through: This analyzes the relationship between Bitcoin and Ethereum, spot ETF complex flows (IBIT and others), derivative narratives including whale positioning, option interest clustering around strike prices, and the three-exchange dynamic between CME, Binance perpetuals, and Bybit.

  2. Commodities Impact Analysis: Oil, gold, silver, and agricultural futures with full options chain analysis, including tanker booking impacts, refining crack spreads, and OECD demand implications.


  3. FX and Rate Futures with Options Overlay: Euro, yen, dollar index, SOFR curve, and sovereign spread analysis with institutional positioning data.

  4. Equity Index and Volatility: Micro S&P, NASDAQ, Russell, and VIX futures with gamma dynamics and institutional hedging flows.


This report is what drives the bot generation. It is the equivalent of having a portfolio manager, five trading desks, and a quant research team compressed into an automated pipeline that runs in about an hour.



Why Claude Code in VS Code Is the Only Way I Develop Now


The Efficiency of AI-First Development


I want to be clear about my development workflow because it is fundamentally different from what most developers are doing. I use Claude Code exclusively through the VS Code extension. I do not use the CLI version. The VS Code integration is roughly 100 times more precise for the type of work I do because it can scan the entire project -- every single file across all subdirectories and the root folder.


Here is why that matters. During the 10-day debugging marathon, I encountered a runtime logic error in a JavaScript dashboard file. These types of errors are notoriously difficult to diagnose because the symptom appears in one place while the root cause lives somewhere entirely different.


When I prompted Claude Opus 4.6 with simply "fix the analysis error in this HTML file," it did something remarkable. It read the HTML, identified what was creating the data source, traced the data pipeline back into the Python scripts that generate the data, and discovered that the actual root cause was a Windows path handling issue in a glob pattern within a completely different Python module. It then corrected everything across multiple Python files -- the static file load operation, the try-exception validation, the news context fallback, and the sentiment analysis graceful degradation.


One error in JavaScript. The AI reverse-engineered the entire data pipeline and fixed four Python files. This is why you need the most advanced LLM available for debugging, and why the VS Code integration matters -- it gives the AI visibility across the entire project, which in my case is roughly a gigabyte of code, logs, and data.


Model Selection and Cost Considerations


Let me talk about the practical economics of AI-assisted trading development. I have doubled my monthly AI budget because of how serious this work has become. Most of that budget goes to Claude-related models.

In the Claude Code VS Code extension, you have access to three model tiers:


  • Claude 3.5 Haiku: One generation behind, the cheapest option, comparable to a Codex-class model. Fine for simple tasks.

  • Claude Sonnet 4.6: More capable but noticeably more expensive. When I was using Sonnet for bot generation, the output code was roughly double the size (1,600 lines versus 800) and significantly more sophisticated in its strategy modeling and algorithmic analysis.

  • Claude Opus 4.6: The most expensive and the most capable model on the planet as of April 2026. This is what I use for debugging, architecture decisions, and complex analysis where precision matters more than cost.


The trade-off is real: you are either spending time or spending money. If you are trying to save money, you will spend more time getting to a solution. I chose to spend the money to cut down the development time, and that decision has paid for itself many times over in the sophistication of the system I have been able to build.




The Options Chain Discovery Problem: Why Concurrency Nearly Broke Everything


Understanding the Technical Challenge


Here is where the architecture gets genuinely difficult, and where I think most vibe coders would get stuck. When a dynamically generated trading bot needs to trade options on a futures contract, it cannot just grab a price quote. It has to perform what the AI calls an "options chain discovery."


For any given futures contract -- say ES for May or June -- there are potentially 10 to 20 associated option chains with different expirations, strike prices, and volume profiles. The bot has to analyze which option chain gives the optimal strike price, the best liquidity, and the most appropriate risk-reward profile for the specific strategy it was designed to execute.


This discovery process requires downloading a significant amount of data from the market data provider. Now multiply that by 10 to 12 bots, all running simultaneously, all competing for the same single Rithmic API connection.


The Concurrency Nightmare


With futures-only trading, the system was stable. The volume of requests to Rithmic was lower and more manageable. But once I added options chain discovery and live option chain data downloads for every bot request, the system collapsed under concurrency pressure.


The numbers tell the story. In a single three-hour session, the system processed over 143,000 events across 10 bots. The ES futures contract alone was generating 250-plus ticks per minute. Now add options chain discovery requests on top of that, with 12 bots competing for a single gateway connection to Rithmic's servers.


The result was multi-threaded concurrency failures, connection timeouts, data gaps, and cascading errors that were extraordinarily difficult to diagnose because they were intermittent and load-dependent.


The Solution: Architectural Pragmatism Over Technical Purity


This is where experience matters more than AI capability. Claude Opus 4.6 -- the most advanced AI model available -- told me directly: "This is not physically possible to implement as designed." It gave me two options: either abandon options trading entirely or get a second dedicated Rithmic data feed exclusively for options.


But even with a dedicated feed, the AI predicted ongoing concurrency problems. So here is where 40 years of coding experience made the difference. I understood the constraints, I understood the architecture, and I came up with a middle-ground solution that the AI had not suggested.


Instead of downloading live option chains for every request from every bot, I configured the system to capture one option chain snapshot at startup and use that cached data for all option chain analysis throughout the bot's lifetime. Since these dynamically created bots typically only last for a day, the option chain data remains sufficiently fresh for strategy execution.


Is it ideal? No. But without spending significantly more money on infrastructure, it was the best middle ground between functionality and feasibility. This is the kind of architectural decision that separates experienced quant developers from beginners relying purely on AI assistance.




What Institutional Options Trading Actually Looks Like: The Bitcoin Example


Why Retail Crypto Traders Are Flying Blind


If you are a retail trader in Bitcoin or Ethereum, I need to tell you something important. The three exchanges that now drive Bitcoin pricing are:


  1. CME: Institutional-grade regulated futures and options. Volume is now comparable to the offshore exchanges.

  2. Binance: Perpetual futures and options, primarily Asian trading hours overnight.

  3. Bybit: Smaller but significant perpetual and options volume.


When institutional players position in Bitcoin, they are not just going long or short on spot. They are building complex options structures: risk reversals, call spreads financed by puts, condors with dynamic delta hedging, and calendar carries that exploit the basis between CME futures and offshore perpetuals.


The Basis-Carry Dynamic


The institutional report breaks this down precisely. Three dynamics push the overall price of Bitcoin:


  1. CME versus offshore perpetual basis: When the basis between CME futures and Binance perpetuals compresses or expands, it signals institutional positioning changes.

  2. ETF demand flow: Inflows and outflows from products like IBIT (BlackRock's Bitcoin ETF) create direct price pressure.

  3. Options positioning: Whale activity clustering around specific strike prices creates gravitational zones that influence price behavior.


If the basis collapses faster than perceived realized volatility, institutions reverse their cash-and-carry expressions or reduce long basis inventory. If panic dissipates and the basis steepens, macro funds re-enter through calendar carry options -- long deferred, short near, or vice versa depending on the curve shape.


This is what drives Bitcoin's price. Not Twitter sentiment. Not YouTube analysis. Not chart patterns. If you are not analyzing options flow on CME alongside ETF positioning and offshore perpetual dynamics, you are trading with incomplete information.


The Volatility Regime Analysis


The system also generates a volatility regime assessment for every instrument. For crypto specifically:


  • Short-dated implied volatility: Elevated around geopolitical and regulatory headlines.

  • Wing demand analysis: Both upside call options (breakout narrative) and downside put options (whale shorting narrative plus ETF outflow persistence).

  • Skew and squeeze dynamics: When the options skew is mispriced relative to the catalyst path, risk reversals become the institutional play of choice.

  • Greek analysis: Long gamma, short vega positions; call spreads financed with put spreads (seagull structures); and over-the-counter treasury desks warehousing crypto risk.


This level of analysis is what institutions produce every single day. The fact that I can generate it automatically with AI is what makes this system valuable.




The Oil and Gold Connection: How Options Drive Commodity Prices


Crude Oil: Beyond the Headlines


The same institutional options analysis applies to energy markets. The system analyzes Brent crude, WTI, crack spreads, and even tanker booking data to understand freight optionality in the listed futures and options space.


When you hear about oil price movements in the news, what is actually happening underneath involves:


  • Calendar spread positioning: Front-month versus deferred crude futures with options overlays.

  • Crack spread collars: Refiners hedging their margins through options on the gasoline-to-crude and heating-oil-to-crude spreads.

  • Geopolitical risk premium analysis: When discretionary macro and commodity funds reduce emerging market long beta while keeping optional upside for renewed disruption.


If you want to understand gasoline pricing, heating oil costs, jet fuel impacts on airlines, or diesel price trends, you need to understand what is happening in the crude oil options market weeks before those price movements hit the retail level.


Gold: The Convexity Trade


Gold is currently being driven by what the report calls "convexity retained as geopolitical portfolio insurance." The YouTube commentators and Twitter analysts who say "buy gold" are not wrong in their conclusion, but they have no idea why gold moves the way it does.


The institutional positioning involves:


  • Long gold call spreads financed by short put risk reversals.

  • 25-delta risk reversal structures that define downside exposure.

  • Tail hedging demand driven by geopolitical event risk.

  • Premium outlay optimization through multi-leg options structures.


When gold goes flat or declines despite bullish consensus, it is because of these underlying options dynamics -- not because the fundamental thesis is wrong. Understanding the options market gives you weeks of lead time on these movements.




The Forex Blind Spot: What MetaTrader Chartists Do Not Understand


For those of you trading forex on MetaTrader with technical analysis, I have difficult news. The price of EUR/USD, USD/JPY, and every other major pair is driven by options positioning that you cannot see on a retail charting platform.


The system generates institutional-level FX analysis covering:


  • Euro rate future options sensitivity to European energy policy and election dynamics.

  • Yen volatility surfaces driven by Bank of Japan intervention risk and carry trade unwinds.

  • Dollar index options positioning around FOMC expectations and trade policy shifts.


All of these create the price movements that technical analysts try to pattern-match after the fact. The options market is the cause; the chart pattern is the effect.




Debugging at Scale: How Claude Opus Handles 143,000 Events


Log Analysis as Conversation


One of the most powerful capabilities of Claude Code in the VS Code environment is its ability to perform intelligent log analysis across dynamically generated bot logs. With 10 bots running simultaneously, each generating its own log file, manual debugging is not feasible.


Here is how it works in practice. I simply ask Claude: "Are the trading bots collecting data properly since the fix?" The AI then:


  1. Scans all log files across all bot directories.

  2. Performs comparative timestamp analysis from the moment the query was started -- no need to delete logs and start over.

  3. Searches for specific keywords: warnings, connection errors, heartbeat failures, API timeouts.

  4. Generates a comprehensive status summary across all bots.


The results are remarkably intelligent. For example, when two bots showed no incoming data, Claude did not flag them as errors. Instead, it identified that the SOFR curve steepener and VIX futures contracts had legitimately low volume on those exchanges at that time of day. It said: "This is really not a problem because there is just low volume on this contract."


That is the equivalent of having an expert trading desk analyst who understands both the technology and the market microstructure. It can differentiate between a system failure and normal market behavior, which is exactly the kind of intelligence you need when running a fleet of autonomous trading bots.


The Anthropic API Disruption: A Real-World Lesson


During the 10-day development period, something unexpected happened. News broke that Anthropic might cut off third-party harnesses from using Claude models. For several hours, the system stopped collecting news data because the Claude API connection failed silently -- no error message, just no data.


This forced an architectural pivot. I had to switch from using Claude Sonnet for news analysis and bot generation to using Codex 5.3 as a fallback. The impact was measurable: Codex-generated bots were about half the size (800 lines versus 1,600) and the strategy complexity was noticeably reduced.


This is an important lesson for anyone building AI-dependent trading systems: always have a fallback model, and understand the capability differences between your primary and secondary AI providers. The system now uses Codex for news-driven bot generation while reserving Claude Opus for debugging, architecture decisions, and complex analytical tasks where its superior reasoning capability is essential.




The Retail Trader Exodus: Why Institutional Matters More Than Ever


According to recent reporting from the Kobeissi Letter, millions of retail traders have dropped out of the futures and options markets. Volumes are lower across the board, which means the remaining market activity is predominantly institutional.


This has two implications for anyone still in the game:


  1. You must think institutionally: The bots and strategies I have described are all designed around institutional trading paradigms -- risk reversals, calendar spreads, condors, collars, and delta-hedged options positions. Retail-style directional betting does not work in a market dominated by institutional flow.


  1. Options literacy is no longer optional: If you are trading any instrument -- stocks, futures, crypto, forex -- without understanding the options market for that instrument, you are operating with incomplete information. The options market reveals institutional positioning, risk appetite, and directional bias weeks before it shows up in price charts.




Building Your Own System: Key Architectural Takeaways


For developers and quant traders who want to build something similar, here are the essential architectural considerations:


Infrastructure Requirements


  • Market data provider: Rithmic API for CME futures and options data. Expect significant data volumes -- 143,000+ events in three hours across 10 bots.

  • Data pipeline: Redis for real-time data distribution between bots and the gateway server.

  • AI integration: Claude Code via VS Code extension for development and debugging; Codex or equivalent for runtime bot generation.

  • Logging: Comprehensive per-bot logging with timestamp-based analysis capability.


Concurrency Management


  • Single gateway connection must be carefully managed when multiple bots request market data simultaneously.

  • Options chain discovery is the most data-intensive operation -- consider caching strategies.

  • Heartbeat monitoring between your gateway and the market data provider is essential for detecting connection issues before they cascade.


Bot Lifecycle


  • Bots are ephemeral: generated from news, run for approximately one trading session, then retired.

  • Each bot is a complete, self-contained Python script with its own strategy logic, risk management, and position management.

  • The master orchestration script handles bot creation, launch, monitoring, and shutdown.




Conclusion: The Future of AI-Powered Quant Trading


What I have described here is not theoretical. This system runs 8 to 9 hours per day on live CME market data, generating institutional-grade analysis and executing through a fleet of dynamically created trading bots. The complexity has grown roughly five to ten times since adding options chain integration, and it continues to evolve.


The key insight I want to leave you with is this: the combination of AI-first development (using Claude Code), automated news analysis, dynamic strategy generation, and options chain integration creates a capability that would have required an entire hedge fund team just a few years ago. One person with the right architecture, the right AI tools, and enough domain expertise can now operate at an institutional level.


But let me be equally honest about the limitations. You need real experience to make architectural decisions that the AI cannot make for you. You need to understand concurrency, market microstructure, options theory, and risk management at a deep level. AI is an extraordinary accelerator, but it is not a replacement for domain expertise. I have been coding for over 40 years, and that experience was essential when Claude Opus itself told me the original architecture was not physically possible to implement.


The future belongs to those who can combine deep domain knowledge with AI-powered development. The options on futures market is where the institutional action is. And the tools to participate at that level are now accessible to anyone willing to invest the time, the money, and the intellectual effort to build systems like this one.




This article is based on a live development session at QuantLabsNet.com. All trading described is simulated. Options and futures trading involves substantial risk of loss and is not suitable for all investors. The AI-generated strategies and analysis described are for educational purposes only.




Related Reading:



Comments


bottom of page