Skip to main content
Glama

run_backtest

Run a Python FLOX strategy on a CSV dataset in a sandboxed subprocess to produce backtest statistics 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
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.
dataset_pathYesAbsolute path to a CSV dataset on disk. Capped at 64 MiB.
symbolNoSymbol name to register before the run. Default: BTCUSDT.
wall_timeout_sNoWall-clock timeout in seconds. Default 60.
Behavior5/5

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

Discloses resource limits (CPU, memory, output size, wall-clock timeout), lack of filesystem/network isolation, return format (JSON plus stdout), and internal dispatch routing based on strategy hooks. No annotations provided; description fully covers behavioral traits.

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?

Concise at ~150 words, front-loaded with core action, every sentence adds value: purpose, usage, safety, return, routing. No redundancy or fluff.

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?

Covers purpose, usage, safety, return behavior, internal routing, and parameter constraints. Despite lacking output schema, it describes the return structure. Suitable for the complexity of running arbitrary code.

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

Parameters5/5

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

Adds defaults (symbol BTCUSDT, wall_timeout_s 60), constraints (dataset_path capped at 64 MiB), and explains strategy_code expects a flox.Strategy subclass or STRATEGY variable. Describes dispatch logic tied to parameter use. All 4 parameters have schema descriptions, but description enriches them.

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?

Description clearly states it runs a Python FLOX strategy against a CSV dataset in a sandboxed subprocess, specifying verb, resource, and environment. It distinguishes from sibling tools like validate_strategy by emphasizing its purpose for testing strategies on data.

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?

Explicitly tells when to use: 'when the user asks try this strategy on my data or does this code actually work'. Includes a strong warning against untrusted code, but does not directly mention alternatives among siblings.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/FLOX-Foundation/flox'

If you have feedback or need assistance with the MCP directory API, please join our Discord server