Building and Verifying AI Trading Agents in LumiBot
Summary
This documentation entry directs coding agents to start from complete LumiBot examples for either AI-based or ordinary Python strategies. It describes the strategy lifecycle at a high level: create agents during initialization and invoke them during each trading iteration. It distinguishes coding agents that write strategy files, in-strategy agents that use tools during execution, and external MCP clients that operate in a hosted workspace. It also notes that directly running the cited example starts a historical backtest, while paper or live trading requires a separate broker runner.
The guidance emphasizes checking execution evidence rather than relying on process completion or agent summaries. It calls for inspecting order identifiers, statuses, fills, positions, and trace artifacts, and reconciling unresolved orders before retrying. For historical research it recommends using the strategy clock, reporting missing data, and recording model, dates, data source, source revision, replay state, costs, and results. The page points to further API and observability documentation but provides no performance evidence.
Key ideas
- Start from a complete LumiBot strategy example and follow its documented execution API.
- Agents can write strategy code, participate within a strategy lifecycle, or access a hosted workspace through MCP.
- Running the cited example directly performs a historical backtest; paper and live use needs a broker runner.
- Verify fills and positions from order records and trace artifacts instead of treating process completion as proof of execution.
- Record data, model, dates, costs, source revision, and replay state when reporting historical research.
Tags
Full text
# agent start here LumiBot for coding agents ========================= .. meta:: :description: Exact starting points for coding agents using LumiBot: install, complete Strategy examples, AI model credentials, backtest artifacts, and supported tools. Start from a complete example ----------------------------- Use :doc:`agents_quickstart` for an AI strategy or :doc:`getting_started` 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 <https://github.com/Lumiwealth/lumibot/blob/version/4.6.3/lumibot/example_strategies/ai_researcher_trader.py>`_. It uses ``openai/gpt-6-luna`` on medium reasoning, ``OPENAI_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. Direct execution of that file starts a historical backtest only. Keep the strategy class when adapting it, but supply a separate broker runner for paper/live execution. See :doc:`strategy_run_modes` for the full AI example inventory and the exact startup distinction. 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 :doc:`BotSpot MCP <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 :doc:`agents_observability`. For integrations in an existing Python project, see :doc:`standalone_components`. For additional tools and signatures, see :doc:`agents_builtin_tools` and :doc:`strategy_api_overview`. The generated ``llms.txt`` index points to the same documentation; it is not a separate API contract.
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.