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
| Name | Required | Description | Default |
|---|---|---|---|
| strategy_code | Yes | Python source defining a `flox.Strategy` subclass at module level. The worker also accepts a top-level `STRATEGY = MyStrategy` assignment as the entry point. | |
| dataset_path | Yes | Absolute path to a CSV dataset on disk. Capped at 64 MiB. | |
| symbol | No | Symbol name to register before the run. Default: BTCUSDT. | |
| wall_timeout_s | No | Wall-clock timeout in seconds. Default 60. |