0DTE Options AI Trading Bot

Research agent checks SPY every 15 minutes, trading agent sells today's call spread, then the trade that expires the same day

This bot trades 0DTE options: options that expire the same day. It sells a bear call spread on SPY, the S&P 500 ETF, and keeps the premium if SPY stays below the short strike by the close. 0DTE is now the biggest part of the index options market: in August 2025 it was a record 62.4% of all SPX options trading (Cboe).

How it works

  1. Research agent checks SPY and the calls that expire today every 15 minutes. It finds the call near 0.20 delta and the call 5 points higher, with their prices.

  2. Trading agent sells that spread once a day, risking about 1% of the account.

  3. The trading agent keeps watching and closes the spread early when you have kept half the credit, when closing costs twice the credit, or when SPY rises above the short strike. It never opens a new spread in the last 30 minutes of the day.

Change symbol to "SPX" to trade S&P 500 index options, if your broker offers them.

Run it on BotSpot

Run this bot on BotSpot without installing anything. BotSpot runs LumiBot in the cloud, backtests it, and connects it to your broker.

Backtest tear sheet

GPT-6 Luna, January 5 to 6, 2026, Alpaca option prices, $100,000 start. Each morning the bot sold a 2-contract SPY bear call spread that expired that day, for about $0.27 a share. Both days SPY rallied into the short strike, and the bot closed the spread early at its loss limit, near 2 to 3 times the credit because it checks every 15 minutes. It ended at $99,826 (-0.2%). A losing window, shown as it happened.

Backtest tear sheet for the 0DTE Options AI Trading Bot

Open the full tear sheet. A short backtest shows the bot works as written. It is not a promise of future returns.

The code

The whole bot is one short file. The prompts are plain English, and they are the strategy.

"""0DTE Options AI Trading Bot.

Sells a same-day (0DTE) bear call spread on SPY, the S&P 500 ETF, and lets it
expire worthless when SPY stays below the short strike. A research agent checks
SPY and today's expiring calls every 15 minutes. A trading agent opens one spread
a day and closes it early when the trade goes wrong.
"""

from lumibot.strategies import Strategy


class ZeroDTEOptionsTradingBot(Strategy):
    parameters = {"symbol": "SPY"}

    def initialize(self):
        self.sleeptime = "15M"
        self.agents.create(
            name="researcher",
            allow_trading=False,
            system_prompt=(
                "Look at the symbol's price and the calls that expire today. Find a bear call spread: sell "
                "the call near 0.20 delta and buy the call 5 points higher. Report the two contracts and the "
                "credit, and any spread we already hold with its cost to close. Do not trade."
            ),
        )
        self.agents.create(
            name="trader",
            allow_trading=True,
            system_prompt=(
                "Sell one bear call spread that expires today, once a day. Risk about 1% of the account. "
                "Close it early when we have kept half the credit, when closing costs twice the credit, or "
                "when the price rises above the short strike. Do not open a new spread in the last 30 minutes "
                "of the day."
            ),
        )

    def on_trading_iteration(self):
        facts = {"symbol": self.parameters["symbol"]}
        research = self.agents["researcher"].run(task_prompt="Check today's 0DTE call spread.", context=facts)
        self.agents["trader"].run(
            task_prompt="Manage or open today's spread.", context={**facts, "research": research.summary}
        )


if __name__ == "__main__":
    from lumibot.credentials import IS_BACKTESTING

    if IS_BACKTESTING:
        from lumibot.backtesting import AlpacaBacktesting

        ZeroDTEOptionsTradingBot.backtest(AlpacaBacktesting)
    else:
        ZeroDTEOptionsTradingBot().run_live()

Run it yourself

pip install lumibot
python -m lumibot.example_strategies.ai_0dte_options_trading_bot

Put these in your .env file: OPENAI_API_KEY, and your broker keys (for example ALPACA_API_KEY, ALPACA_API_SECRET, and ALPACA_IS_PAPER=true for paper trading). With IS_BACKTESTING=false the bot trades. With IS_BACKTESTING=true it backtests instead; set BACKTESTING_START and BACKTESTING_END to pick the dates, and start with a week or two, because every AI call costs a little. Option and minute-bar backtests use Alpaca’s free history, so paper Alpaca keys are enough.

Good to know

  • 0DTE options move very fast. Paper trade first.

  • The bot checks every 15 minutes, so it makes a lot of AI calls per day.

See AI Trading Bot Examples for more AI trading bots and Backtest, paper, or live: choose the runner for backtest and live runs.