One-Agent AI Trading Bot Demos¶
These are the smallest AI trading bots in LumiBot. Each one is a single AI agent with a few sentences of plain English, about 30 lines in all. The agent uses LumiBot’s built-in tools on its own: prices, news, Federal Reserve data, and more. You never write a tool or name one in the prompt.
What BotSpot MCP adds
Use Claude, ChatGPT, Codex, Cursor, VS Code or another MCP-compatible assistant? Connect the free BotSpot MCP for:
Skills: build LumiBot strategies.
Free data: news, economics and SEC filings.
Backtests: run tests and read charts.
Cloud hosting: low-cost scheduled bots.
Community: share bots and discuss trades.
Marketplace: discover and publish strategies.
Broker linking: connect accounts through BotSpot.
For bigger bots with several agents, see AI Trading Bot Examples.
The demos¶
Make Me Money (
agent_discretionary.py): the whole prompt is “Make as much money as you possibly can.” LumiBot’s built-in rules handle risk, sizing, and look-ahead safety.Market News (
agent_alpaca_news_builtin.py): reads the day’s market news, opens the most important story, and holds SPY, QQQ, or SHV.News Sentiment (
agent_news_sentiment.py): buys the 2 to 4 well-known stocks with the strongest good news, or SHV when the news is weak.Trend (
agent_macro_risk.py): holds TQQQ while it trends up and SHV while it trends down.Momentum and News (
agent_momentum_allocator.py): holds TQQQ when the trend is up and the news is not bad, otherwise SHV.M2 Liquidity (
agent_m2_liquidity.py): holds TQQQ when the money supply is growing and SHV when it is shrinking, using the Federal Reserve’s M2 data. The_openai,_anthropic, and_grokfilenames remain compatible, but all these copies now default to GPT-6 Luna.
Example: M2 Liquidity¶
"""M2 Liquidity AI Trading Bot.
Holds TQQQ when the money supply (M2) is growing and SHV, a short-term Treasury
fund, when it is shrinking. One AI agent reads the Federal Reserve's M2 data each
day and trades.
"""
from lumibot.strategies import Strategy
class M2LiquidityStrategy(Strategy):
def initialize(self):
self.sleeptime = "1D"
self.agents.create(
name="trader",
allow_trading=True,
system_prompt=(
"Hold either TQQQ or SHV with the whole account. Each day, check whether the M2 money supply "
"is growing compared with 3 to 6 months ago, using official Federal Reserve data. If it is "
"growing, hold TQQQ. If it is flat or shrinking, hold SHV. Sell one before buying the other."
),
)
def on_trading_iteration(self):
self.agents["trader"].run(task_prompt="Check M2 and hold TQQQ or SHV.")
if __name__ == "__main__":
from lumibot.credentials import IS_BACKTESTING
if IS_BACKTESTING:
from lumibot.backtesting import YahooDataBacktesting
M2LiquidityStrategy.backtest(YahooDataBacktesting)
else:
M2LiquidityStrategy().run_live()
To run a demo on another AI model, add model="anthropic/claude-sonnet-4-6"
(or another model) to self.agents.create(...) and put that provider’s key in
your .env file.
Run a demo¶
Put OPENAI_API_KEY in your .env file. The M2 bot also needs a free
FRED_API_KEY, and the news bots need free Alpaca keys (ALPACA_API_KEY and
ALPACA_API_SECRET).
python -m lumibot.example_strategies.agent_m2_liquidity
Every demo ends with the same block as a BotSpot main.py: with
IS_BACKTESTING=true it backtests (set BACKTESTING_START and
BACKTESTING_END for the dates), otherwise it trades with the broker in your
.env file. See Backtest, paper, or live: choose the runner.
Backtest tear sheets¶
GPT-6 Luna, January 5 to 16, 2026, Yahoo daily prices, $100,000 start. SPY rose about 1% over the same days. A two-week backtest shows each bot works as written; it is not a promise of future returns.
Demo |
What it did |
Tear sheet |
|---|---|---|
M2 Liquidity |
Read the Federal Reserve’s M2 data, saw it growing, and held TQQQ. Ended at $101,096 (+1.1%). |
|
Trend |
Switched between TQQQ and SHV with the trend. Ended at $101,413 (+1.4%). One switch left cash $751 below zero for a moment. |
|
Momentum and News |
Held TQQQ while momentum was up, then SHV. Ended at $99,512 (-0.5%). One switch left cash $751 below zero for a moment. |
|
News Sentiment |
Bought stocks with strong news, such as AMZN, BAC, JPM, TMO, and UNH. Ended at $100,884 (+0.9%). |
|
Market News |
Read the market news, judged it weak, and held SHV. Ended at $100,063 (+0.1%). |
|
Make Me Money |
Chose the chip ETF SMH on its own and held it. Ended at $100,782 (+0.8%). |
What to look at after a run¶
The tear sheet and its comparison with SPY
trades.csv: every order and fill*_agent_detail.parquet: every AI call, the tools it used, and why it traded
See AI Agent Observability for how to read them.
Frequently asked questions¶
What is the simplest AI trading bot in LumiBot?¶
The demos on this page. Each one is a single AI agent with a few sentences of plain English, about 30 lines of Python in all. The agent uses LumiBot’s built-in tools on its own.
Do I need to write tools for the agent?¶
No. The demos use LumiBot’s built-in tools for prices, news, Federal Reserve data and more. You never write a tool or name one in the prompt. See Agent Built-In Tools.
What API keys do the demos need?¶
Put OPENAI_API_KEY in your .env file. The M2 Liquidity bot also needs a
free FRED_API_KEY. The news bots need free Alpaca keys, ALPACA_API_KEY
and ALPACA_API_SECRET.
How do I run a demo?¶
Run it as a module, for example
python -m lumibot.example_strategies.agent_m2_liquidity. With
IS_BACKTESTING=true it runs a backtest, and you set the dates with
BACKTESTING_START and BACKTESTING_END. Otherwise it trades with the
broker in your .env file. See Backtest, paper, or live: choose the runner.
Can I run a demo with Claude or another AI model?¶
Yes. Add model="anthropic/claude-sonnet-4-6", or another model id, to
self.agents.create(...). Then put that provider’s API key in your .env
file.
Where can I see why the agent made a trade?¶
Open *_agent_detail.parquet after a run. It records every AI call, the tools
the agent used and why it traded. trades.csv lists every order and fill. See
AI Agent Observability.
Do the tear sheet results mean these bots will make money?¶
No. The tear sheets cover a two-week backtest. They show that each bot works as written. They are not a promise of future returns.
Where can I find bigger AI trading bots with several agents?¶
See AI Trading Bot Examples for multi-agent AI trading bots.