Fast Decision-Model 24/7 Crypto and Futures Bot¶
Full multi-turn agent loops are ideal for deep research, but fast intraday crypto and futures trading needs millisecond classification without waiting through multi-step tool calls. This 24/7 bot combines deterministic Python market features with LumiBot’s ultra-fast self.agents.decide() interface using OpenAI openai/gpt-6-luna or Google google/gemini-decision-1 to trade Alpaca Crypto (BTC/USD) or TopstepX Micro Nasdaq futures (MNQ).
How it works¶
Every five minutes, deterministic Python computes clean price features and hands them to a single sub-second agent decision call:
Feature builder and decision agent fetches the last 30 one-minute bars, calculates 5-bar and 20-bar simple moving averages plus 5-minute and 20-minute returns, and calls
self.agents.decide()with structured evidence and two typed questions: a discreteactionchoice (BUY,HOLD, orEXIT) and a calibratedhigh_convictionprobability predicate.Execution layer inspects the returned choice and probability score. When the decision agent selects
BUYwithconviction >= 0.65and the strategy is flat, Python submits a sized buy order (percentage of cash for 24/7 crypto on Alpaca, or 1 contract forMNQcontinuous futures on TopstepX); when it selectsEXITwhile long, Python closes the position immediately.
Switch between 24/7 Bitcoin and TopstepX Micro Nasdaq futures by changing symbol and asset_type in parameters ("crypto" or "cont_future"), and swap decision_model between openai/gpt-6-luna and google/gemini-decision-1.
Run it on BotSpot¶
Explore ready-to-run bots and deploy 24/7 strategies in the cloud on BotSpot Marketplace. BotSpot hosts LumiBot strategies continuously, runs historical backtests, and connects directly to Alpaca, TopstepX, and other supported brokers.
Building custom fast-decision strategies with Claude, ChatGPT, Codex, or Cursor? Connect the free BotSpot MCP for LumiBot skills, cloud backtesting, and logs. Want guided training on low-latency AI trading bots? Explore BotSpot Courses or join the free AI Trading Challenge.
The code¶
The complete hybrid strategy is under 100 lines of Python and demonstrates typed choice and predicate probability outputs from self.agents.decide().
"""Fast Decision-Model 24/7 Crypto and Futures Bot.
Uses LumiBot's low-latency self.agents.decide(...) interface with OpenAI
"openai/gpt-6-luna" or Google "google/gemini-decision-1" to classify real-time
momentum and volatility into BUY, HOLD, or EXIT in milliseconds without
multi-turn loops. Trades 24/7 on Alpaca Crypto (BTC/USD) or US futures
sessions on TopstepX (MNQ).
"""
from lumibot.entities import Asset
from lumibot.strategies import Strategy
class FastDecisionCryptoFuturesBot(Strategy):
parameters = {
"symbol": "BTC",
"asset_type": "crypto", # "crypto" (Alpaca 24/7) or "cont_future" (TopstepX MNQ)
"decision_model": "openai/gpt-6-luna", # or "google/gemini-decision-1"
"allocation_pct": 0.25,
}
def initialize(self):
self.sleeptime = "5M"
self.market = "24/7" if self.parameters["asset_type"] == "crypto" else "us_futures"
def _target_asset(self):
if self.parameters["asset_type"] == "cont_future":
return Asset(self.parameters["symbol"], Asset.AssetType.CONT_FUTURE)
return Asset(self.parameters["symbol"], Asset.AssetType.CRYPTO)
def on_trading_iteration(self):
asset = self._target_asset()
quote = Asset("USD", Asset.AssetType.FOREX)
bars = self.get_historical_prices(asset, 30, "minute", quote=quote)
if bars is None or len(bars.df) < 20:
return
close = bars.df["close"]
last = float(close.iloc[-1])
sma5 = float(close.tail(5).mean())
sma20 = float(close.tail(20).mean())
ret5 = round((last / float(close.iloc[-6]) - 1.0) * 100.0, 3)
ret20 = round((last / float(close.iloc[-20]) - 1.0) * 100.0, 3)
pos = self.get_position(asset)
held_qty = float(pos.quantity) if pos else 0.0
decision = self.agents.decide(
model=self.parameters["decision_model"],
evidence={
"symbol": asset.symbol,
"price": round(last, 2),
"sma5": round(sma5, 2),
"sma20": round(sma20, 2),
"ret_5m_pct": ret5,
"ret_20m_pct": ret20,
"currently_long": held_qty > 0,
},
questions=[
{
"name": "action",
"type": "choice",
"instructions": "Pick the highest-expectancy action for the next 5 to 15 minutes.",
"choices": ["BUY", "HOLD", "EXIT"],
},
{
"name": "high_conviction",
"type": "predicate",
"instructions": "Is there a clean, high-conviction short-term edge supporting the chosen action?",
},
],
)
action = decision.choice("action")
conviction = float(decision.probability("high_conviction"))
self.log_message(
f"Decision {asset.symbol}: action={action} conviction={conviction:.2f} price={last:.2f}"
)
if action == "BUY" and conviction >= 0.65 and held_qty <= 0:
if asset.asset_type == Asset.AssetType.CONT_FUTURE:
self.submit_order(self.create_order(asset, 1, "buy"))
else:
qty = round((self.cash * float(self.parameters["allocation_pct"])) / last, 5)
if qty > 0:
self.submit_order(self.create_order(asset, qty, "buy", quote=quote))
elif action == "EXIT" and held_qty > 0:
self.submit_order(self.create_order(asset, held_qty, "sell", quote=quote))
if __name__ == "__main__":
from lumibot.credentials import IS_BACKTESTING
from lumibot.entities import TradingFee
quote_asset = Asset("USD", Asset.AssetType.FOREX)
if IS_BACKTESTING:
from lumibot.backtesting import AlpacaBacktesting
fee = TradingFee(percent_fee=0.001)
FastDecisionCryptoFuturesBot.backtest(
AlpacaBacktesting,
buy_trading_fees=[fee],
sell_trading_fees=[fee],
quote_asset=quote_asset,
)
else:
FastDecisionCryptoFuturesBot(quote_asset=quote_asset).run_live()
Run it yourself¶
pip install lumibot
python -m lumibot.example_strategies.ai_fast_decision_crypto_futures_bot
Add the model key matching decision_model plus your broker credentials to your .env file:
OPENAI_API_KEYforopenai/gpt-6-luna(default) orGEMINI_API_KEYforgoogle/gemini-decision-1ALPACA_API_KEY,ALPACA_API_SECRET, andALPACA_IS_PAPER=truefor 24/7 Alpaca Crypto (BTC/USD)Or your TopstepX credentials when switching
symbol="MNQ"andasset_type="cont_future"
Set IS_BACKTESTING=true with BACKTESTING_START and BACKTESTING_END to run a historical backtest with simulated 0.1% trading fees, or IS_BACKTESTING=false to run live against your configured broker.
Good to know¶
self.agents.decide()requires a LumiBot runtime version that includes the decision-model API. Confirm your installed version and provider credentials before running live.Running every five minutes around the clock triggers up to 288 decision calls per day; test a short historical window (one to two days) first to verify fill behavior, trading fees, and decision latency.
Crypto and leveraged futures carry rapid price swings and fee drag on high-frequency entries and exits. Backtests verify mechanics and fee accounting, not profitability.
See AI Trading Bot Examples for more AI trading bots and Backtest, paper, or live: choose the runner for backtest and live runners.