Quant BuffetRelax, Not Over Thinking

Quant Buffet API

Sandbox rules

Allowed imports, builtins, limits, and error types.

Draft-preview and batch lab runs execute your code in `backtest/sandbox_runner.py`. Source is parsed with `ast`, stripped of bootstrap boilerplate, then `exec`'d with a restricted namespace.

Allowed import roots

  • backtest.* — data, engine, metrics, templates, universes
  • numpy / np, pandas / pd
  • math, json, typing, collections, dataclasses
  • functools, itertools, datetime, re, statistics, decimal
  • __future__

Blocked

  • Standard library modules outside the allow-list (os, sys, pathlib, subprocess, …).
  • Third-party packages (requests, sklearn, matplotlib, …).
  • Calls to eval, exec, compile, open, input, breakpoint.
  • async / await syntax.
  • Source files larger than 80 KB.

Safe builtins

A subset of Python builtins is injected: abs, min, max, sum, len, range, enumerate, zip, map, filter, sorted, container types, round, print, isinstance, hasattr, type, and common exceptions.

Runtime limits

LimitValue
Max symbols in ASSETS15
Min price history30 rows after load
Min equity curve length20 points after run
Equity chart points returned90 (downsampled)
Default backtest start (payload)2000-01-01 or lab UI date

Common error types

TypeTypical cause
SyntaxErrorInvalid Python; line number returned when available.
ContractErrorMissing make_on_day or wrong return shape.
ValueErrorBad import, whitelist symbol, empty ASSETS, signal never ready.
ImportErrorBlocked module at runtime.
RuntimeErrorNo price data loaded for any symbol.