redditalpha logoredditalpha
← Back to dashboard
Share
1100%
r/optionsr/options· u/saffystaffie· 1d ago 0

I used ChatGPT and Codex to build and backtest SPY + QQQ 0DTE trading bots

Investor summaryNeutral

Author shares Python bot logic and backtest parameters for trading SPY and QQQ 0DTE options via opening range breakouts.

Post body

I used ChatGPT and Codex to develop and refine these strategies, then used Codex to build the automated bot in Python. I launch, configure and manage it through PowerShell.

My broker is Interactive Brokers, and the bot connects to Trader Workstation (TWS) running on my desktop to receive market data and place/manage orders.

I downloaded 5-minute SPY/QQQ data from TradingView and backtested Jan 1–Jun 25, 2026: 120 trading days. Targets and stops measure movement in the underlying, not the option premium.

SPY

  • 9:30–10:30 ET opening range using 5-minute candles.
  • Trigger: $1 above or below the range.
  • Enter a same-day expiry call/put after a completed 5-minute candle closes beyond the trigger.
  • Max 20% available cash; one setup per day.
  • Exit 25% at +$1.50, 25% at +$2.25 and 25% at +$3.00.
  • The final 25% is the runner, targeting +$5.50.
  • Hard stop: −$3.
  • If TP1 has not hit within 60 minutes and SPY is below +$0.50, exit.
  • Force-close at 3:30 ET.

The SPY runner is only allocated if the opening range is at least $4.50 wide and at least four contracts were filled. At TP2, it must pass three of four conditions: TP2 within 30 minutes; SPY moved at least +$1.50 within 30 minutes; pullback before TP2 was no more than $0.50; and no completed 5-minute candle closed back through the trigger. Pass = keep the runner open for +$5.50. Fail = sell the runner around TP2. The SPY runner does not move to breakeven.

QQQ

  • 9:30–10:00 ET opening range.
  • Only trade if the range is $4.28$5.14 wide.
  • Trigger: $0.75 above or below the range; no confirmation candle.
  • Max 20% available cash; one setup per day.
  • Exit 40% at +$1, 40% at +$2 and keep 20% as a runner targeting +$5.50.
  • Hard stop: −$5.
  • After TP2, move the runner stop to breakeven.
  • Force-close at 4:00 ET.

Entry execution

The bot submits a buy limit order at the current option ask, then raises it by $0.02 every 0.5 seconds for up to three seconds. It cancels the unfilled quantity if the underlying moves more than $0.25 beyond the trigger. Partial fills are kept and there is no retry.

IBKR/TWS pacing protection

Interactive Brokers counts new orders, modifications and cancellations as order operations. Before every place/change/cancel action through Trader Workstation, the bot checks its pacing limiter and stays below six operations per two seconds and 60 per ten minutes. If it is near the limit, it waits rather than spamming TWS. This protects entries, profit targets, hard stops, stale exits and forced closes.

Backtest results

SPY: 38 trades, 32 wins/6 losses, +57.37 points, +1.51 average.

QQQ: 27 trades, 25 wins/2 losses, +34.10 points, +1.26 average.

Combined: active on 58/120 days (48%), 50 winning days/8 losing days, +91.47 points and +1.58 per active day.

SPY only: 31 days. QQQ only: 20 days. Both: seven days.

Whenever both triggered, they were always in the same direction, so QQQ is not a hedge—it mainly adds more opportunities. Running both at full size produced +91.47 points. Splitting allocation when both triggered would have produced approximately +79.01 points with less correlated exposure.

Monthly combined: Jan +7.99, Feb +16.60, Mar +22.06, Apr +13.34, May +11.46, Jun +20.02.

This is a six-month chart-data backtest, not proof of future profitability. The next step is paper trading through Interactive Brokers TWS and measuring real fills, spreads, slippage and live option execution.

Discussion · top comments15 selected
u/options-ModTeam 1· 15h ago

Removed for RULE: No spam, no cross-posts, no copy/paste of posts.

We incorporate the existing site-wide anti-spam rules explicitly. We consider cross-posting of all types and/or copy/pasting of posts as spam. Posts to this sub are expected to be unique and custom tailored to our community.

u/Professional_Dr_77 1· 15h ago

“…because I can’t be bothered to write it all…”

Everything after that is irrelevant. Thanks.

u/saffystaffie 1· 15h ago

Thank you Dr Professional

u/Eves98 1· 18h ago

Backtesting only helps refine a strategy some. Even paper trading is going to help so much. In both cases you're not having to deal with the fact that sometimes options are just not assigned at your limit price. And that potentially ruins the whole scenario.

u/saffystaffie 1· 18h ago

Yeah 100%. I can see how people get an account from $2000 to $200,000, and then back down to $2000 again! Scary stuff haha

u/Miamiconnectionexo 1· 20h ago

the bit about "downloaded 5-minute SPY/QQQ data from TradingView" stands out — TradingView's 5m bars aren't clean for 0DTE backtesting because they include pre-market and after-hours prints that don't align with 9:30-4:00 SPY options settlement. you might be getting phantom signals from 4:05am or 8:00pm candles that flat out don't exist in live 0DTE trading. worth checking if your backtest filters to regular session only, or if those extra candles are inflating your win rate.

u/saffystaffie 1· 19h ago

Thanks for your reply- so the candles start when the market opens and stop when the market opens, USA time, if that makes sense. One thing that is really bugging me, is that when I tested the same strategy for the second half of last year (after the advice I got from Reddit) June through to December, albeit with 10 min timeframe, the strategy, whilst being in profit, doesn’t hold up nearly as well. And you could say that that’s because you are using a 10 min timeframe, but when I use that for the Jan- June 2026 data, I get more or less the same results as the 5 min timeframe, so I don’t think I can blame it entirely on that. And when just looking at the price movement of 2025, I can see what someone meant by the ‘bullish market’ comment. I am new to all this and only really looked into this after seeing people’s gains on Reddit with spy and 0dte trades, and everyone has to start somewhere right? But to be honest it has kinda motivated me to educate myself further about how you can use further data and patterns to know how the market might react. Obviously ChatGPT and codex and other ai tools are a good way to sift through data quickly, but ultimately you need to make the decision about what data to use. But I guess if it were that easy to just have a simple strategy and have a computer program essentially printing money for you, everyone would be doing it right?! Sorry for the long reply haha

u/live4failure 1· 1d ago

Underlying shouldnt be used to estimate options.. every there are so many other factors than underlying price or volume. If you want to use price action backtesting then try something like TQQQ

u/saffystaffie 1· 1d ago

Thanks very much for the advice, I will definitely look into that!

u/live4failure 1· 1d ago

For sure. Keep grinding. A lot of strategies can make money but not losing money is harder. Made 10k my first month of 0DTE trading and gave it all back already, but now I know what is possible!

u/gapupandfade 1· 1d ago

I have Amibroker and 10+ years of tick data compiled and would most likely run it on a 1 min timeframe if you want me to run it for you

u/saffystaffie 1· 1d ago

That would be really helpful, thank you- I am very new to this, and I realise now that I may have jumped the gun quite a bit when thinking that I might have something special here haha. After using 10 min timeframe for the last six months for last year, I didn’t have nearly the same results as I did this year. Still profitable, but far less so. Is there a way you could possibly send me that tick data please?

u/BitterAd6419 1· 1d ago

Hang on a min so all these trades were on paper trading ?

I was interested till I read that part :) paper trading ain’t live trading, the fills are not real. The live options market on moves really fast and you often don’t get filled because of a sudden move

Run it on live and report back, I bet the results are way different

u/dad-jokes-about-you 1· 1d ago

Hey guys, I used AI to back test and I’m still poor. If this actually worked I probably wouldn’t be posting here and I would be silently stacking money

u/Inevitable-Tea5772 1· 1d ago

Does it go short also?