Build deterministic trading strategies, AI trading agents, and AI trading teams for stocks, options, crypto, futures, forex, SEC filings, FRED macro data, technical indicators, and real brokers. Backtest, paper trade, or run live with the same Python code.
Full docs: lumibot.lumiwealth.com · Managed cloud: BotSpot.trade · MCP: BotSpot for AI coding agents
- Deterministic strategies: normal Python logic, indicators, if statements, scheduled rules, position sizing, and risk controls.
- AI-agent strategies: one or more agents that reason through evidence, call tools, write memory, and optionally place orders.
- Backtests: replay historical data and simulated orders with artifacts you can inspect.
- Paper or live trading: reuse the same strategy code with real broker state and real order routing.
Start with the open-source docs, then deploy when you are ready: Lumibot documentation · Try a sample Lumibot strategy on BotSpot
BotSpot is the managed cloud built around Lumibot. It makes Lumibot easier and cheaper to run because the data, backtesting workers, broker connections, scheduling, monitoring, logs, alerts, and kill switches are already wired together.
BotSpot is not a generic chatbot bolted onto a broker account. Its AI workflows, prompts, MCP tools, backtest setup, broker paths, and deployment flow are built for Lumibot.
- Backtesting data included. Use hosted stock, futures, options, FRED macro, SEC filing, and other supported data without wrangling every feed and API key yourself. Some data is included; premium data can be much cheaper than buying direct subscriptions for occasional experiments.
- Cheaper deployment at scale. Scheduled and periodic bots should not need a full always-on server per strategy. BotSpot runs Lumibot bots on managed infrastructure built for this workflow, with monitoring and controls included.
- Lumibot-tuned AI. Generic coding tools can write Python, but BotSpot is tuned for Lumibot strategy structure, broker setup, backtests, artifacts, and deployment.
- MCP for coding agents. Connect BotSpot to Codex, Claude Code, Cursor, and other MCP clients so your coding agent can run backtests, inspect artifacts, compare results, and prepare deployment instead of only generating code.
- Work from anywhere. Use the same strategy workspace from the web, your phone, Telegram, Discord, Claude, ChatGPT, and coding tools. Start in one place and continue in another.
- Marketplace and strategy library. Browse existing strategy code, clone and adapt strategies, run strategies where available, and publish your own strategies when you are ready.
- Observability and control. Inspect why a bot bought or sold, review charts, logs, decisions, orders, notifications, audit history, and kill-switch controls in one place.
pip install lumibotfrom datetime import datetime
from lumibot.strategies import Strategy
from lumibot.backtesting import YahooDataBacktesting
class MyStrategy(Strategy):
def on_trading_iteration(self):
if self.first_iteration:
aapl = self.create_order("AAPL", 10, "buy")
self.submit_order(aapl)
MyStrategy.backtest(
YahooDataBacktesting,
datetime(2023, 1, 1),
datetime(2024, 1, 1),
)python my_strategy.pyThat same strategy code works with live brokers. Just swap the broker class.
For full setup guides, broker tutorials, AI-agent docs, examples, and deployment notes, use the Lumibot documentation.
Lumibot now includes a built-in AI agent runtime for financial research, reasoning, debate, risk review, and trade execution. Agents can inspect market data, read filings, query indicators, search memory, compare macro context, and submit orders through the same Lumibot strategy loop used by normal backtests and live trading.
Classic Python strategies are still first-class. Lumibot lets you choose the right level of intelligence: fixed rules, AI agents, or a hybrid where Python handles the hard gates and agents reason through evidence.
Built-in AI agent tools include market/account state, order inspection, DuckDB queries, documentation search, Alpaca news when credentials exist, technical indicators, SEC fundamentals and filings, FRED macro data, local memory, and Telegram notifications.
An AI trading team is just a group of agents with different jobs inside the same Lumibot strategy. You can build a single-agent strategy, a specialist research flow, bull/bear/neutral teams, model-vs-model debates, deterministic execution gates, or agent reviewers layered on top of normal Python logic.
Here is one example pattern: a researcher gathers evidence, bull and bear agents debate the trade, and a trader agent decides what to buy or sell.
In this pattern, each agent has a job:
- Research Agent: builds the evidence pack from market data, filings, fundamentals, news, macro data, and indicators.
- Bull Agent: turns that evidence into the strongest long thesis.
- Bear Agent: challenges the thesis, looks for risk, and argues for avoiding, delaying, or reducing the trade.
- Trader / Portfolio Manager Agent: checks cash, positions, open orders, and risk limits, then decides whether to trade.
The copy-paste example below implements that exact team. It uses Gemini Flash Lite because it is fast and inexpensive for experiments. Set GEMINI_API_KEY first:
export GEMINI_API_KEY='your-key-here'Then save this as ai_trading_team.py and run python ai_trading_team.py. If the key is missing or invalid, Lumibot stops the backtest and prints a clear GEMINI_API_KEY error with a link to create a key.
from datetime import datetime
from lumibot.strategies.strategy import Strategy
class AITradingTeamStrategy(Strategy):
parameters = {
"universe": ["TQQQ", "SQQQ", "SOXL", "SOXS", "UPRO", "SPXU", "TECL", "TECS"],
}
def initialize(self):
self.sleeptime = "1D"
# The first three agents are read-only. They can reason, but cannot trade.
self.agents.create(
name="researcher",
model="gemini-3.1-flash-lite",
allow_trading=False,
system_prompt="Rank the ETFs by upside. Be direct.",
)
self.agents.create(
name="bull",
model="gemini-3.1-flash-lite",
allow_trading=False,
system_prompt="Argue for the strongest money-making trade.",
)
self.agents.create(
name="bear",
model="gemini-3.1-flash-lite",
allow_trading=False,
system_prompt="Point out the biggest risk, briefly.",
)
# Only this final agent can submit orders through Lumibot.
self.agents.create(
name="trader",
model="gemini-3.1-flash-lite",
allow_trading=True,
system_prompt="Buy one ETF from the universe aggressively. Use nearly all cash.",
)
def on_trading_iteration(self):
# Each trading day, pass the same market context through the team.
context = {
"date": self.get_datetime().date().isoformat(),
"universe": self.parameters["universe"],
}
research = self.agents["researcher"].run(
task_prompt="Pick the strongest ETF.",
context=context,
)
bull = self.agents["bull"].run(
task_prompt="Make the bull case.",
context={**context, "research": research.summary},
)
bear = self.agents["bear"].run(
task_prompt="Make the bear case.",
context={**context, "research": research.summary, "bull": bull.summary},
)
self.agents["trader"].run(
task_prompt="Sell anything that is not the pick, then buy the best ETF with nearly all available cash.",
context={**context, "research": research.summary, "bull": bull.summary, "bear": bear.summary},
)
if __name__ == "__main__":
from lumibot.backtesting import YahooDataBacktesting
AITradingTeamStrategy.backtest(
YahooDataBacktesting,
datetime(2026, 4, 7),
datetime(2026, 5, 22),
)Example backtest artifact from this sample strategy:
Backtests are not expected future performance. The point is that the full AI trading team runs inside Lumibot's normal backtest loop, so the decisions, orders, and artifacts are inspectable before you connect a broker.
To run the same strategy in paper trading or live trading, keep the strategy class and replace the if __name__ == "__main__": block with a broker runner:
if __name__ == "__main__":
from lumibot.brokers import Alpaca
from lumibot.traders import Trader
ALPACA_CONFIG = {
"API_KEY": "YOUR_ALPACA_API_KEY",
"API_SECRET": "YOUR_ALPACA_SECRET",
"PAPER": True,
}
broker = Alpaca(ALPACA_CONFIG)
strategy = AITradingTeamStrategy(broker=broker)
trader = Trader()
trader.add_strategy(strategy)
trader.run_all()| Feature | Lumibot | Backtrader | Freqtrade | Zipline | Backtesting.py | Jesse |
|---|---|---|---|---|---|---|
| Same code: backtest + live | Yes | Yes | Yes (crypto) | No | No | Yes (paid) |
| Stocks | Yes | Yes | No | Yes | Yes | No |
| Options | Yes | No | No | No | No | No |
| Crypto | Yes | Limited | Yes | No | Yes | Yes |
| Futures | Yes | Limited | Crypto only | Partial | Yes | Crypto only |
| Forex | Yes | Outdated | No | No | Yes | No |
| AI agent runtime | Built-in | No | FreqAI (ML) | No | No | ML pipeline |
| Brokers | Alpaca, IBKR, Tradier, Schwab, Tradovate, TopstepX (via ProjectX), Bitunix, plus selected CCXT crypto paths | IB only (outdated) | 10+ crypto exchanges | None | None | 8+ crypto (paid) |
| Actively maintained | Yes (2026) | No (since 2023) | Yes | Minimal | Moderate | Yes |
| License | MIT | GPL-3.0 | GPL-3.0 | Apache-2.0 | AGPL-3.0 | MIT |
Switching from Backtrader? See our migration guide for a side-by-side comparison with code examples.
BotSpot is the managed path for taking a Lumibot strategy from idea to backtest to paper or live trading. It handles the expensive and fragile parts around the strategy: hosted data setup for supported backtests, parallel backtest runs, broker connections, scheduling, logs, alerts, monitoring, audit history, and kill-switch controls.
This is especially useful when your strategy only needs to run daily or periodically. You get the same Lumibot code path without paying for always-on infrastructure, maintaining a scheduler, hand-wiring broker secrets, or building your own log and alerting stack.
Run Lumibot on your own machine with any supported broker:
from lumibot.brokers import Alpaca
from lumibot.traders import Trader
ALPACA_CONFIG = {
"API_KEY": "your-key",
"API_SECRET": "your-secret",
"PAPER": True,
}
broker = Alpaca(ALPACA_CONFIG)
strategy = MyStrategy(broker=broker)
trader = Trader()
trader.add_strategy(strategy)
trader.run_all()Lumibot supports stocks, options, crypto, futures, forex, and indexes across several broker integrations:
- Alpaca
- Interactive Brokers and Interactive Brokers REST
- Tradier
- Schwab
- Tradovate
- TopstepX futures (via ProjectX)
- Bitunix
- Selected CCXT crypto paths. Coinbase, Kraken, and WEEX have auto-detected credential paths; KuCoin, Binance, and BitMEX have documented manual CCXT setup paths; Kraken, Binance, KuCoin, BitMEX, Bybit, and OKX have documented backtesting examples. Lumibot does not claim blanket support for every CCXT exchange.
Lumibot can backtest from free daily data, broker data, premium market data, and your own files:
- Yahoo Finance
- Alpaca
- Interactive Brokers REST
- ThetaData
- Polygon/Massive
- DataBento
- Tradier
- Schwab
- CCXT backtesting examples: Kraken, Binance, KuCoin, BitMEX, Bybit, and OKX
- Pandas/CSV dataframes
For the deepest historical coverage (stocks, options, futures, indexes), we recommend ThetaData. Use promo code BotSpot10 for 10% off your first order.
Lumibot includes a built-in AI trading agent runtime. Build agents that run identically in backtests and live trading.
- Create agents with
self.agents.create(...) - Use a different model per agent with
model="openai/gpt-5.5"or any LiteLLM/ADK-supported provider string - Make research agents read-only with
allow_trading=False - Give agents built-in SEC fundamentals, filings, FRED macro data, indicators, memory, and notifications
- Use DuckDB for time-series analysis instead of dumping raw bars into prompts
- Mount external MCP servers for news, macro data, filings, or any domain-specific tools
- Replay identical agent decisions in backtests without paying for another model call
Use BotSpot MCP when you want an AI coding agent to generate Lumibot strategies, launch backtests, inspect artifacts, and iterate without leaving your editor.
Start here:
- Agent Documentation
- AI Trading Team Flow Design
- AI Trading Team Example
- Standalone AI Committee Demo
- Discretionary Agent Example
- News Sentiment Agent Example
- Full Guide
AI strategies can record decisions, lessons, open theses, tool calls, and run artifacts as local files. This makes an AI backtest reviewable instead of a black box: you can inspect why the agent traded, which tools it used, and what it remembered for later iterations.
Browse and contribute open-source strategies: lumibot-strategies. For hosted strategy discovery with performance, descriptions, visuals, and deploy flows, use the BotSpot marketplace.
Lumibot includes 25+ example strategies covering stocks, options, crypto, futures, and forex:
# Run a simple buy-and-hold backtest
python -m lumibot.example_strategies.stock_buy_and_hold
# Or explore all examples
ls lumibot/example_strategies/Browse all examples: example_strategies/
External example repo: stock_example_algo shows a minimal strategy repository you can run yourself or adapt inside BotSpot.
Select a data source via environment variable (overrides code):
export BACKTESTING_DATA_SOURCE=thetadata # or yahoo, ibkr, polygonMulti-provider routing by asset type:
export BACKTESTING_DATA_SOURCE='{"default":"thetadata","option":"thetadata","crypto":"ibkr","crypto_future":"ibkr","future":"ibkr","cont_future":"ibkr"}'Crypto futures/perpetual backtests can route Asset.AssetType.CRYPTO_FUTURE through spot crypto history. USDT symbols such as BTCUSDT, ETHUSDT, and SOLUSDT use the matching USD spot proxy for prices.
| Data Source | OHLCV | Split Adjusted | Dividends | Dividend Adjusted Returns |
|---|---|---|---|---|
| Yahoo | Yes | Yes | Yes | Yes |
| Alpaca | Yes | Yes | No | No |
| Polygon | Yes | Yes | No | No |
| Tradier | Yes | Yes | No | No |
| Pandas* | Yes | Yes | Yes | Yes |
*Pandas loads CSV files in Yahoo dataframe format, which can contain dividends.
- Documentation: lumibot.lumiwealth.com
- Blog: lumiwealth.com/blog
- AI strategy builder and hosted deployment: BotSpot.trade
- BotSpot MCP for AI coding agents: botspot.trade/agents
- Strategy marketplace: botspot.trade/marketplace
- YouTube strategy builds: Lumiwealth on YouTube
Learn to build, backtest, and deploy trading strategies using AI. Join 2,400+ traders.
We welcome contributions! Here's a video to help you get started: Watch The Video
Steps:
- Clone the repository
- Create a new branch:
git switch -c my-feature - Install dev dependencies:
pip install -r requirements_dev.txt && pip install -e . - Make your changes
- Run tests:
pytest - Create a pull request
pytest # Run all tests
pytest tests/test_asset.py # Run a specific test file
coverage run; coverage report # Show code coverageLumibot can mirror its local parquet caches to AWS S3. See docs/remote_cache.md for configuration.
- Backtesting Architecture - Data flow diagrams for Yahoo, ThetaData, Polygon
- Acceptance Backtests - End-to-end acceptance suite
- Environment Variables - All configurable env vars
- Changelog - Release notes
- AI Assistant Guide - Instructions for AI coding assistants
- Production Safety - ThetaData and production rules
This software is provided for educational and informational purposes only. It is not financial advice and does not constitute a recommendation to buy or sell any security. Lumibot and BotSpot are not registered broker-dealers or financial advisors. Algorithmic trading involves substantial risk of loss, including the possibility of losses greater than your initial investment. Software bugs and errors can lead to rapid financial losses. Past backtest performance does not guarantee future results. Use this software at your own risk. You are solely responsible for compliance with all applicable laws and regulations regarding the assets you choose to trade.
Affiliate disclosure: some provider links or promo codes, including ThetaData, may support continued Lumibot development.
MIT License - View License







