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
Type
Raised by
Typical cause
SyntaxError
AST parse
Invalid Python. Includes line and column.
ContractError
Contract check
make_on_day missing or not callable.
ValueError
Validation and run
Blocked import, non-whitelisted symbol, empty ASSETS, over 15 symbols, oversized source, async syntax, signal never ready, history too short.
ImportError
Restricted __import__
A blocked module reached at runtime.
RuntimeError
load_daily_prices
No price data loaded for any symbol.
TypeError, KeyError, NameError, …
Your code
Ordinary Python bugs, reported with your line number.
BadPayload
Runner entry
Malformed JSON on stdin (only when scripting directly).
Contract failures
Message
Cause
Fix
*Define ASSETS = ['SPY', ...] at module level…*
ASSETS missing, or nested inside a function
Move it to the top level of the file
*Missing make_on_day(prices)…*
Function absent, misspelled, or shadowed by a variable
Define def make_on_day(prices): at module level
TypeError: cannot unpack non-sequence
make_on_day returned only on_day
return on_day, ready
*Signal never ready — check lookbacks / ASSETS history.*
ready is None or NaT
Shorten the lookback, or drop the short-history symbol
*Equity curve too short — strategy may never trade.*
Fewer than 20 marked days
Check that on_day reaches set_target_weights
Data and universe failures
Message
Cause
Fix
*Symbol 'X' is not in the Quant Buffet whitelist.*
Single stock, or an unsupported ETF such as UUP
Substitute a whitelisted proxy from Universes
*Too many symbols (max 15).*
ASSETS too long after de-duplication
Slice the book, e.g. COUNTRY_DM[:12]
*ASSETS is empty after validation.*
Empty list, or only blank strings
Provide at least one valid ticker
*Not enough price history for the selected assets/start date.*
Fewer than 30 rows loaded
Move start earlier, or remove the newest symbol
*No price data loaded. Errors: …*
Every symbol failed to download
Check connectivity; try symbols already in data_cache/
Sandbox restriction failures
Message
Fix
*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 defined
Use series.any() — any / all are not injected
Runtime bugs in your own code
Error
Usual cause
Fix
KeyError: Timestamp(...)
Indexing a series with no row for dt
series.reindex(prices.index).ffill(), or test dt in series.index
KeyError: 'XLC'
Assuming every ASSETS entry became a column
cols = [c for c in ASSETS if c in prices.columns]
*truth value of a Series is ambiguous*
and / or / if on a pandas object
Use the elementwise operators with .any() / .all()
ZeroDivisionError
Dividing by len(picks) when picks is empty
Guard with if not picks: return
ValueError: cannot convert float NaN to integer
int() on a NaN indicator
Check pd.notna(x) first
Run never finishes
Recomputing indicators inside on_day
Move the computation into make_on_day
A debugging sequence that works
Read the line number in the gutter — it points at your source, not at pandas.
Confirm the contract: module-level ASSETS, and make_on_day returning (on_day, ready).
Click Ask AI for syntax for an explanation plus a patch.
Cut the problem down: two symbols in ASSETS and a later start isolates data issues fast.
print() is available and its output reaches the run log — print ready and one dt row when a signal looks wrong.
Compare against the Examples page; most bugs are a deviation from one of those shapes.