Skip to content
All library documents

Bull and Bear Agents for Leveraged ETF Portfolio Rebalancing

Article Lumibot

Summary

This example describes an AI trading workflow for leveraged long and inverse ETFs. A researcher ranks the available funds, separate bull and bear agents present competing cases, and an interpreter turns their views into target account weights. A trading agent then rebalances toward those weights, sells positions that are no longer wanted, respects available cash, and avoids holding an ETF alongside its inverse for the same index. The paired instruments include funds tied to major US equity indexes.

The document reports one short simulation using daily Yahoo prices and a simulated account. It says the portfolio moved among UPRO and TQQQ, avoided their inverse funds, kept cash positive, and ended with a gain over the stated period. This is a single illustrative run, not evidence of durable performance or a forecast. The description also explains that the example can be run with a broker in paper mode or backtested; it does not provide enough detail here to assess signal quality, transaction costs, or performance across market regimes.

Key ideas

  • Separate research, bullish analysis, bearish challenge, allocation decisions, and order placement across agents.
  • The interpreter converts competing arguments into target weights for the account.
  • The trader avoids simultaneous long and inverse exposure to the same index and limits purchases to available cash.
  • The reported result comes from one brief simulation and should not be treated as a forecast.

Tags

Full text
# agents example bull bear leveraged etf


Bull/Bear Leveraged ETF AI Trading Team
=======================================

.. meta::
   :description: This is a fast, dramatic AI trading team demo. It gives the agents a universe of leveraged long and inverse ETFs, turns a bull and bear debate into account weights.

.. image:: ../docs/assets/ai-trading-team-workflows/bull-bear-leveraged-etf.png
   :alt: AI trading team workflow for bull/bear leveraged ETFs
   :width: 100%

This is a fast, dramatic AI trading team demo. It gives the agents a universe
of leveraged long and inverse ETFs, turns a bull and bear debate into account
weights, and asks a dedicated trading-and-risk agent to rebalance to them. The
purpose is to show the full loop clearly: research, upside case, risk
challenge, risk-controlled execution.

Because the universe includes both bull and bear instruments, the team can
choose risk-on or risk-off exposure. That makes the decision trail easy to
audit: you can inspect why the agents liked a sector, why the bear agent
objected, and why the final trader still bought or sold.

How the team works
------------------

* ``researcher`` ranks the leveraged ETF universe.
* ``bull`` argues for the strongest money-making trade.
* ``bear`` points out the biggest risk.
* ``interpreter`` weighs both cases and returns target weights for the account.
* ``trader`` is the only agent that can place orders. It holds one direction per index (never TQQQ with SQQQ, or UPRO with SPXU), sells what the weights dropped, and never buys more than its cash.
* The universe pairs leveraged funds that move more than the index, such as TQQQ against SQQQ and UPRO against SPXU.

Latest run
----------

A check with ``openai/gpt-6-luna`` on high reasoning, Yahoo daily prices, a
$100,000 simulated account, and a TQQQ, SQQQ, UPRO, and SPXU universe ran from
January 5 to 15, 2026. It bought 841 UPRO on the first session, later split the
book between UPRO and TQQQ, and never held an ETF with its inverse. Cash stayed
positive the whole run; the lowest balance was $189. The account ended at
$101,466, up 1.47%. This is one short simulation, not a forecast.

Run it with a broker
--------------------

The file defaults to broker-connected execution. With Alpaca, it runs in paper
mode unless you set ``ALPACA_IS_PAPER=false``.

.. code-block:: bash

   export OPENAI_API_KEY='your-key-here'
   export ALPACA_API_KEY='your-alpaca-key'
   export ALPACA_API_SECRET='your-alpaca-secret'
   export ALPACA_IS_PAPER=true
   python lumibot/example_strategies/ai_trading_team_bull_bear_leveraged_etf.py

Backtest it
-----------

Use the same strategy class and change ``IS_BACKTESTING = False`` to ``IS_BACKTESTING = True`` in the runner:

.. code-block:: bash

   export OPENAI_API_KEY='your-key-here'
   python lumibot/example_strategies/ai_trading_team_bull_bear_leveraged_etf.py

Example code
------------

.. literalinclude:: ../lumibot/example_strategies/ai_trading_team_bull_bear_leveraged_etf.py
   :language: python

Shown 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.