Skip to main content
Glama

run_backtest

Execute a FLOX strategy on a CSV dataset in a resource-limited sandbox to validate it works and return backtest stats as JSON.

Instructions

Run a Python FLOX strategy against a CSV dataset in a sandboxed subprocess (rlimits on CPU / memory / output size + a wall-clock timeout). Use this when the user asks 'try this strategy on my data' or 'does this code actually work'. Treat as MVP sandbox: it caps resources but does NOT isolate the filesystem or network — never aim it at untrusted code outside a developer's own machine. Returns the backtest stats dict as JSON plus any stdout the strategy printed.

Dispatch routing: the worker introspects the strategy class. If on_bar is overridden the dataset is dispatched as real BarEvents through run_bars (CSV columns: ts,open,high,low,close,volume); otherwise the rows are synthesised into trades for on_trade via run_csv. A strategy that overrides neither hook fails loudly.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolNoSymbol name to register before the run. Default: BTCUSDT.
dataset_pathYesAbsolute path to a CSV dataset on disk. Capped at 64 MiB.
strategy_codeYesPython source defining a `flox.Strategy` subclass at module level. The worker also accepts a top-level `STRATEGY = MyStrategy` assignment as the entry point.
wall_timeout_sNoWall-clock timeout in seconds. Default 60, capped at 600.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.10.0
    • changedInput schema / properties / wall_timeout_s / description
      Previous value: -"Wall-clock timeout in seconds. Default 60."New value: +"Wall-clock timeout in seconds. Default 60, capped at 600."
    • addedInput schema / properties / wall_timeout_s / maximum
      Added value: +600
    • addedInput schema / properties / wall_timeout_s / minimum
      Added value: +1
  2. First observedv0.6.3

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so thoroughly. It discloses resource limits, filesystem/network non-isolation, return payload shape, dispatch routing based on on_bar/on_trade, and the failure mode for strategies overriding neither hook.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is dense but front-loaded: purpose first, then usage triggers, safety caveat, return value, and finally dispatch mechanics. Every sentence adds operational value, with no filler or repetition of schema content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex execution tool with no output schema and no annotations, the description is remarkably complete. It covers return format, sandbox limitations, routing behavior, and failure behavior, leaving little an agent must guess to call it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds meaning beyond the schema: the module-level STRATEGY assignment entry point, the CSV column expectations, and the on_bar vs on_trade dispatch implication for strategy_code. This enrichment justifies a 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific action — running a Python FLOX strategy against a CSV dataset in a sandboxed subprocess — and gives concrete user-intent triggers like 'try this strategy on my data'. This clearly distinguishes it from validation and explanation siblings by focusing on execution.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides explicit when-to-use triggers and a clear when-not-to-use boundary: never aim it at untrusted code outside the developer's machine. It does not explicitly name an alternative like validate_strategy for static checks, but the context and exclusions are otherwise clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.