Single-Agent AI Trading Bots Using News, Trends, and M2
Summary
This guide outlines six compact trading bot demos, each built around a single AI agent using plain-language instructions and built-in data tools. The examples include discretionary stock selection, market news, news sentiment, trend following, a momentum-and-news filter, and a strategy that uses Federal Reserve M2 data. Several switch between leveraged TQQQ and short-term Treasury ETF SHV; the news sentiment example selects stocks or moves to SHV when news is weak. The guide also describes credentials and run modes for backtesting or broker trading.
It reports short backtests using daily prices over a two-week period, with SPY as a comparison, and notes that some position switches briefly produced negative cash. Results varied across demos, and the page cautions that this limited backtest is not a forecast of future returns. It recommends reviewing tear sheets, order records, and agent logs to inspect decisions and fills; the evidence does not establish durable profitability.
Key ideas
- The examples use one AI agent with plain-language prompts and built-in access to price, news, or economic data.
- The strategies cover news selection, trend following, momentum filters, and M2-based allocation.
- Several demos allocate between a leveraged equity ETF and a short-term Treasury ETF.
- The reported backtests span only two weeks and do not imply future performance.
- Trade records and agent logs can be examined to review orders, tool use, and decisions.
Tags
Full text
# agents canonical demos
One-Agent AI Trading Bot Demos
==============================
.. meta::
:description: Short one-agent AI trading bot demos for LumiBot: M2 liquidity, trend, momentum and news, news sentiment, market news, and a make-me-money bot. Each is about 30 lines.
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.
.. include:: _snippets/botspot_mcp_callout.rst
For bigger bots with several agents, see :doc:`agents_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 ``_grok`` filenames remain compatible, but all these copies now default to GPT-6 Luna.
Example: M2 Liquidity
---------------------
.. literalinclude:: ../lumibot/example_strategies/agent_m2_liquidity.py
:language: python
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``).
.. code-block:: bash
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 :doc:`strategy_run_modes`.
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.
.. list-table::
:header-rows: 1
:widths: 22 58 20
* - 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%).
- `Open <tearsheets/m2-liquidity-ai-trading-bot.html>`__
* - 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.
- `Open <tearsheets/trend-ai-trading-bot.html>`__
* - 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.
- `Open <tearsheets/momentum-and-news-ai-trading-bot.html>`__
* - News Sentiment
- Bought stocks with strong news, such as AMZN, BAC, JPM, TMO, and UNH. Ended at $100,884 (+0.9%).
- `Open <tearsheets/news-sentiment-ai-trading-bot.html>`__
* - Market News
- Read the market news, judged it weak, and held SHV. Ended at $100,063 (+0.1%).
- `Open <tearsheets/market-news-ai-trading-bot.html>`__
* - Make Me Money
- Chose the chip ETF SMH on its own and held it. Ended at $100,782 (+0.8%).
- `Open <tearsheets/make-me-money-ai-trading-bot.html>`__
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 :doc:`agents_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
:doc:`agents_builtin_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 :doc:`strategy_run_modes`.
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
:doc:`agents_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 :doc:`agents_examples` for multi-agent AI trading bots.
Related pages
-------------
- :doc:`agents` -- main guide
- :doc:`agents_quickstart` -- build your first agent
- :doc:`agents_examples` -- multi-agent AI trading botsShown in full with attribution under the source's licence. Licence: GPL-3.0
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.