Quant Buffet API

Errors & troubleshooting

Every error type the sandbox can return, what actually causes it, and the fix.

The IDE reports a type, a message, and usually a line number. This page maps each one to its real cause. The Ask AI for syntax button produces a paste-ready patch for anything here.

Error types

TypeRaised byTypical cause
SyntaxErrorAST parseInvalid Python. Includes line and column.
ContractErrorContract checkmake_on_day missing or not callable.
ValueErrorValidation and runBlocked import, non-whitelisted symbol, empty ASSETS, over 15 symbols, oversized source, async syntax, signal never ready, history too short.
ImportErrorRestricted __import__A blocked module reached at runtime.
RuntimeErrorload_daily_pricesNo price data loaded for any symbol.
TypeError, KeyError, NameError, …Your codeOrdinary Python bugs, reported with your line number.
BadPayloadRunner entryMalformed JSON on stdin (only when scripting directly).

Contract failures

MessageCauseFix
*Define ASSETS = ['SPY', ...] at module level…*ASSETS missing, or nested inside a functionMove it to the top level of the file
*Missing make_on_day(prices)…*Function absent, misspelled, or shadowed by a variableDefine def make_on_day(prices): at module level
TypeError: cannot unpack non-sequencemake_on_day returned only on_dayreturn on_day, ready
*Signal never ready — check lookbacks / ASSETS history.*ready is None or NaTShorten the lookback, or drop the short-history symbol
*Equity curve too short — strategy may never trade.*Fewer than 20 marked daysCheck that on_day reaches set_target_weights

Data and universe failures

MessageCauseFix
*Symbol 'X' is not in the Quant Buffet whitelist.*Single stock, or an unsupported ETF such as UUPSubstitute a whitelisted proxy from Universes
*Too many symbols (max 15).*ASSETS too long after de-duplicationSlice the book, e.g. COUNTRY_DM[:12]
*ASSETS is empty after validation.*Empty list, or only blank stringsProvide at least one valid ticker
*Not enough price history for the selected assets/start date.*Fewer than 30 rows loadedMove start earlier, or remove the newest symbol
*No price data loaded. Errors: …*Every symbol failed to downloadCheck connectivity; try symbols already in data_cache/

Sandbox restriction failures

MessageFix
*Import blocked: 'os'…*Remove it — file and process access are unavailable by design
*Import blocked: 'from scipy'…*Re-express with numpy / pandas, which cover most needs
*Call to 'open()' is not allowed in the sandbox.*No file I/O; keep parameters as module constants
*Async code is not supported in the sandbox.*Rewrite synchronously
*Code too long (max 80KB).*Trim comments and dead code, or delegate to a template
NameError: name 'any' is not definedUse series.any()any / all are not injected

Runtime bugs in your own code

ErrorUsual causeFix
KeyError: Timestamp(...)Indexing a series with no row for dtseries.reindex(prices.index).ffill(), or test dt in series.index
KeyError: 'XLC'Assuming every ASSETS entry became a columncols = [c for c in ASSETS if c in prices.columns]
*truth value of a Series is ambiguous*and / or / if on a pandas objectUse the elementwise operators with .any() / .all()
ZeroDivisionErrorDividing by len(picks) when picks is emptyGuard with if not picks: return
ValueError: cannot convert float NaN to integerint() on a NaN indicatorCheck pd.notna(x) first
Run never finishesRecomputing indicators inside on_dayMove the computation into make_on_day

A debugging sequence that works

  1. Read the line number in the gutter — it points at your source, not at pandas.
  2. Confirm the contract: module-level ASSETS, and make_on_day returning (on_day, ready).
  3. Click Ask AI for syntax for an explanation plus a patch.
  4. Cut the problem down: two symbols in ASSETS and a later start isolates data issues fast.
  5. print() is available and its output reaches the run log — print ready and one dt row when a signal looks wrong.
  6. Compare against the Examples page; most bugs are a deviation from one of those shapes.