Python framework for algorithmic trading: backtesting and live deployment for stocks, options, crypto, futures, and forex. Same code for backtest and live trading.
Project description
Lumibot: Algorithmic Trading for Stocks, Options, Crypto, Futures & Forex
The same code runs your backtest and your live trading. The only open-source Python trading library with full options support, built-in AI trading agents, and 5+ broker integrations.
If you find Lumibot useful, a star helps others discover it.
Use Lumibot Your Way
| Path | Description |
|---|---|
| Open source | Build, backtest, and self-host trading strategies with Python. Free forever. |
| BotSpot | Deploy strategies to the cloud with AI assistance, monitoring, and scheduling. No code required. |
| Data providers | Multiple supported. Yahoo Finance is free. ThetaData, Polygon, DataBento, and others available. |
Introducing BotSpot: No-Code AI Trading Bots
BotSpot is our platform built on top of Lumibot that lets you build, backtest, and deploy trading strategies without writing any code. Just describe what you want in plain English and BotSpot's AI handles the rest.
- Build strategies using natural language -- the AI writes production-ready Lumibot code for you
- Backtest against years of historical data with a single click
- Deploy to live trading with real brokers (Alpaca, Interactive Brokers, and more)
- Browse a marketplace of proven, community-built strategies you can run immediately
Quick Start
pip install lumibot
from 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.py
That same strategy code works with live brokers. Just swap the broker class.
Full documentation: lumibot.lumiwealth.com
Why Lumibot?
| 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 | 5+ (Alpaca, IBKR, Tradier, Schwab, CCXT) | 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.
Deploy Live
Option A: BotSpot (managed cloud)
BotSpot runs your Lumibot strategies on hosted infrastructure with scheduling, monitoring, and live execution. Build strategies with AI, no coding required.
- Create trading bots using natural language
- Backtest with historical data
- Deploy to trade automatically 24/7
- Join a community of algorithmic traders
Option B: Self-hosted (full control)
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()
Supported Brokers & Data Sources
| Brokers (live trading) | Data Sources (backtesting) |
|---|---|
| Alpaca | Yahoo Finance (free) |
| Interactive Brokers | ThetaData |
| Tradier | Polygon |
| Schwab | DataBento |
| CCXT (100+ crypto exchanges) | Interactive Brokers |
| Bitunix | CCXT |
| ProjectX | Alpaca |
Recommended Data Provider
For the deepest historical coverage (stocks, options, futures, indexes), we recommend ThetaData. Use promo code BotSpot10 for 10% off your first order.
Affiliate disclosure: This is a referral link. Using this code supports the continued development of Lumibot as an open-source project.
AI Trading Agents
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 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
Start here:
Community Strategies
Browse and contribute trading strategies: lumibot-strategies (fork, backtest, and share your own)
Example Strategies
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 (deployable to Render or Repl.it)
Backtesting Data Sources
Select a data source via environment variable (overrides code):
export BACKTESTING_DATA_SOURCE=thetadata # or yahoo, ibkr, polygon
Multi-provider routing by asset type:
export BACKTESTING_DATA_SOURCE='{"default":"thetadata","crypto":"coinbase"}'
Data source comparison
| 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.
Learn More
- Documentation: lumibot.lumiwealth.com
- Blog: lumiwealth.com/blog
- AI Strategy Builder: BotSpot.trade
- Discord: Join the community
AI Bootcamp
Learn to build, backtest, and deploy trading strategies using AI. Join 2,400+ traders.
Learn more about the AI Bootcamp
DISCLAIMER
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.
Contributing
We welcome contributions! Here's a video to help you get started: Watch The Video
Steps:
- Clone the repository
- Create a new branch:
git checkout -b my-feature - Install dev dependencies:
pip install -r requirements_dev.txt && pip install -e . - Make your changes
- Run tests:
pytest - Create a pull request
Running Tests
pytest # Run all tests
pytest tests/test_asset.py # Run a specific test file
coverage run; coverage report # Show code coverage
Remote Cache Configuration
Lumibot can mirror its local parquet caches to AWS S3. See docs/remote_cache.md for configuration.
Architecture Documentation
- 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
License
MIT License - View License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lumibot-4.4.62.tar.gz.
File metadata
- Download URL: lumibot-4.4.62.tar.gz
- Upload date:
- Size: 37.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b068795141a94a071e202f51fd474c07a035238233b1b87f51ff48a0a34127d4
|
|
| MD5 |
634299965ea1cd1248b71045d85799ec
|
|
| BLAKE2b-256 |
8f05eb11923b23690c59bca7341a83da75c0058c23cf65332e5f9a5c43b539c5
|
File details
Details for the file lumibot-4.4.62-py3-none-any.whl.
File metadata
- Download URL: lumibot-4.4.62-py3-none-any.whl
- Upload date:
- Size: 37.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
397e08dc98c0a6ec9092698945c3365f9ee901ca5d27659dc66d1280294d4c9d
|
|
| MD5 |
d717936b2d24ad5b29a8200ddad0bf94
|
|
| BLAKE2b-256 |
adc2a7d96de46d2d382370e0a8715e94c0387c23161a14ab7d4e2ca6c486bbbb
|