Skip to main content
Glama

run_backtest

Executes a FLOX trading strategy on a CSV dataset in a resource-limited sandbox, returning backtest statistics and stdout. Use to validate strategy code on historical data.

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?

No annotations exist, so the description fully discloses behavior: sandbox limits (CPU, memory, output, timeout), lack of filesystem/network isolation, and dispatch routing based on strategy hooks. This is highly transparent.

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 efficiently structured: main purpose, use case, security warning, return value, then dispatch details. Every sentence adds information without redundancy.

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?

Given no output schema, the description adequately specifies the return format (backtest stats dict as JSON plus stdout). It covers input behavior, limitations, and routing logic, making it fully complete for an agent.

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?

Schema coverage is 100%, but the description adds value by explaining each parameter beyond the schema: e.g., strategy_code accepts a top-level STRATEGY assignment, dataset_path is capped at 64 MiB, symbol and wall_timeout_s have defaults. This enriches parameter understanding.

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 clearly states the tool runs a Python FLOX strategy against a CSV dataset in a sandboxed subprocess, with specific verb and resource. It distinguishes from siblings by focusing on backtesting, unlike validation or computation tools.

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

Usage Guidelines5/5

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

Explicitly provides when to use ('try this strategy', 'does this code work') and includes a critical security warning about not using for untrusted code outside a developer's machine.

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