LumiBot for coding agents¶
Start from a complete example¶
Use Run your first AI backtest for an AI strategy or Start with LumiBot for
ordinary Python rules. Both use from lumibot.strategies import Strategy.
Create agents in initialize and invoke them in on_trading_iteration.
Do not invent an alternative execution API.
The canonical two-agent source is
ai_researcher_trader.py.
It uses gemini-3.5-flash-lite, GEMINI_API_KEY, and Yahoo daily prices.
Read its full source before changing it. Copy the complete file and execute it
in the same Python environment where LumiBot is installed.
Three ways agents participate¶
A coding agent writes and tests Python strategy files using LumiBot.
An in-strategy agent reasons and calls tools during the strategy lifecycle. Research agents are read-only; the final trader has explicit trading permission.
An external MCP client uses BotSpot MCP to work in the hosted workspace. Hosted execution has its own account and approval requirements.
Verify evidence, not prose¶
Inspect exact order identifiers, statuses, filled quantities, positions, and
trace artifacts. A successful process, an agent summary, and a submitted order
are different from a filled order. An unresolved order must be reconciled before
retrying. orders_wait_for_terminal is bounded and may advance simulated time.
Use the strategy’s clock in historical research. Report missing data explicitly; do not silently replace a requested source. Record the model, dates, data, source revision, replay state, cost, and results. See AI Agent Observability.
For integrations in an existing Python project, see Use LumiBot in another Python project.
For additional tools and signatures, see Agent Built-In Tools and
Strategy API Overview. The generated llms.txt index points to the same
documentation; it is not a separate API contract.