Fast Decision-Model TopstepX Futures Bot (ES / NQ) ================================================== .. meta:: :description: Sub-second Python AI trading bot using LumiBot self.agents.decide() with OpenAI gpt-6-luna or Google gemini-decision-1 for TopstepX regular CME E-mini ES and NQ futures. .. image:: ../docs/assets/ai-agent-workflows/fast-decision-crypto-futures-bot.png :alt: Low-latency decision model classifies live 5-minute TopstepX ES or NQ futures momentum into BUY, SHORT, HOLD, or EXIT in milliseconds :width: 100% Trading full-size CME E-mini S&P 500 (``ES``) and E-mini Nasdaq-100 (``NQ``) futures on TopstepX requires fast, disciplined entries without waiting through multi-turn LLM tool loops. This short strategy pairs deterministic 5-minute futures features with LumiBot's sub-second ``self.agents.decide()`` API (OpenAI ``openai/gpt-6-luna`` or Google ``google/gemini-decision-1``) and strict single-contract Python risk caps. .. admonition:: View or Run on BotSpot Marketplace :class: tip Explore live AI trading bots, cloud backtests, and one-click TopstepX broker connections on BotSpot Marketplace without local setup. .. raw:: html
View / Run on BotSpot Marketplace
How it works ------------ Every five minutes during the ``us_futures`` session, Python computes compact intraday features and invokes a single forward-pass decision call: 1. **Feature builder and decision agent** fetches the last 30 one-minute continuous futures bars (``Asset("ES", Asset.AssetType.CONT_FUTURE)`` or ``NQ``), calculates 5-bar and 20-bar moving averages, 5-minute and 20-minute returns, and 20-minute range location, and calls ``self.agents.decide()`` with three typed questions: a discrete ``action`` choice (``BUY``, ``SHORT``, ``HOLD``, or ``EXIT``), a calibrated ``high_conviction`` predicate probability, and a ``trend_strength`` rubric score (``choppy`` / ``moderate`` / ``strong``, normalized ``0.0`` to ``1.0``). 2. **Execution layer** applies deterministic prop-firm risk guardrails: it flattens open positions immediately on ``EXIT``, and only opens ``max_contracts`` (default ``1`` contract) when flat and both ``conviction >= 0.68`` and ``trend_strength >= 0.65`` are satisfied. Switch between regular E-mini S&P 500 (``ES``, $50/point) and E-mini Nasdaq-100 (``NQ``, $20/point) by changing ``symbol`` in ``parameters``, and swap ``decision_model`` between ``openai/gpt-6-luna`` and ``google/gemini-decision-1``. Run it on BotSpot ----------------- Explore ready-to-run futures bots and deploy continuously in the cloud on `BotSpot Marketplace `_. BotSpot hosts LumiBot strategies continuously, runs historical futures backtests, and connects directly to TopstepX (ProjectX) and other supported brokers. Building custom TopstepX fast-decision bots with Claude, ChatGPT, Codex, or Cursor? Connect the free :doc:`BotSpot MCP ` for LumiBot skills, cloud backtesting, and logs. Want guided training on low-latency AI futures bots? Explore `BotSpot Courses `_ or join the `free AI Trading Challenge `_. The code -------- The complete hybrid futures strategy is under 110 lines of Python and demonstrates all three typed decision question types (``choice``, ``predicate``, and ``score``) on continuous futures. .. literalinclude:: ../lumibot/example_strategies/ai_fast_decision_topstepx_futures_bot.py :language: python Run it yourself --------------- .. code-block:: bash pip install lumibot python -m lumibot.example_strategies.ai_fast_decision_topstepx_futures_bot Add the decision-model key and your TopstepX (ProjectX) credentials to your ``.env`` file: * ``OPENAI_API_KEY`` for ``openai/gpt-6-luna`` (default) or ``GEMINI_API_KEY`` for ``google/gemini-decision-1`` * ``PROJECTX_TOPSTEPX_USERNAME``, ``PROJECTX_TOPSTEPX_API_KEY``, and ``PROJECTX_TOPSTEPX_PREFERRED_ACCOUNT_NAME`` for live or funded TopstepX execution (see :doc:`brokers.projectx`) Set ``IS_BACKTESTING=true`` with ``BACKTESTING_START`` and ``BACKTESTING_END`` to backtest continuous futures with simulated $2.50 per-contract round-turn/side fees, or ``IS_BACKTESTING=false`` to run live on TopstepX. Good to know ------------ * ``ES`` ($50 per point) and ``NQ`` ($20 per point) carry large notional exposure per contract; keep ``max_contracts=1`` while verifying behavior, or test micro equivalents (``MES`` / ``MNQ``) first. * ``AgentReplayCache`` replays cached ``self.agents.decide()`` decisions locally in sub-millisecond time during repeated backtest iterations (measured on local 100-bar benchmark: ``0.111 ms`` p50 / ``0.217 ms`` p95 on replay cache hit; ``0.618 ms`` p50 / ``1.114 ms`` p95 local serialization + cache-write overhead excluding network RTT). * TopstepX accounts enforce daily loss limits and trailing drawdown rules; review your account rules and test on a practice account before enabling live execution. See :doc:`agents_examples` for more AI trading bots, :doc:`agents_decisions` for the Decisions API reference, and :doc:`brokers.projectx` for TopstepX setup.