run_strategySubmit one historical strategy experiment to the user's private workspace.
Area
Backtesting & Validation
Group
Backtests
Access
Write
Risk
Destructive
▸Details
Full description
Details
Submit one historical strategy experiment to the user's private workspace.
Backtest limit: 50,000 total bar-rows per job, summed across symbols, including warmup. Before submitting a backtest, tell the user the limit and rough runtime guidance: 10,000 bars about 20–40 seconds; 25,000 about 35–70 seconds; 50,000 about 1–2 minutes. Estimates exclude queue time; strategy complexity and diagnostics can add time. Never silently truncate. Do not promise that a request fits from its primary timeframe alone: planned history, execution minutes and benchmarks also count.
mode selects one of two fully declared analysis methods: backtest simulates the strategy's entries, exits, sizing and trading costs; event_study measures forward returns after entries, without simulated trades or position context. Use event_study to investigate an entry idea before adding exits or sizing. On timeout, shorten the window or use fewer symbols. Splitting a universe changes cross-sectional entries (rank/percentile/z-score/sibling); for those, shorten the window instead. Neither mode starts paper trading, places live orders, or buys securities. Submission persists strategy/revision and run records and consumes the user's research quota. Relative lookbacks can shift earlier to preserve a project's holdout; explicit overlapping dates record contamination, so that window is no longer untouched validation data. The receipt identifies the captured strategy/version/revision, selected mode and run_ids. Read each handle with get_run using the same mode as kind; report pending or failed runs accurately rather than inventing results. Read warnings and window disclosures before interpreting any result. For timed strategy rules, report the rendered decision time, read basis and fill even when the run fails. Rule writes expose readiness.timing. If this receipt has no timing, read get_strategy with the returned strategy_id and include=["readiness"]; use the returned readiness.compiler_admission.timing. This describes the saved plan; say what actually executed only from recorded run evidence, and state when none is available.
An inline source saves the strategy and runs it in one call; a refused inline source saves nothing, so correct the document and resubmit it. Fix a failed run on the returned strategy (edit_strategy / add_rule) and rerun a saved source; do not resubmit a copy inline. builder_discover(action="quickstart") covers saved-source authoring, formula signatures, configuration shapes, value scales and timing.
Event study: omit study for horizons [1,5,10,20] bars; an omitted outcome_mode uses signed_return and min_occurrences uses 0. A duration horizon uses the strategy timeframe; an integer counts bars. cash, fee_pct and slippage_pct are recorded experiment settings; they do not size positions or adjust the forward-return measurements. An event study returns its result in the receipt.
Spend a project's reserved holdout once, after development: mode="backtest", source={"kind":"saved","strategy_id":id,"expected_version":version}, settings={"window":"holdout"} and no other setting. It replays the strategy's latest completed development backtest (same version, cash, costs, benchmark) on the reserved window and consumes the holdout at submission, whatever the run's outcome; a refused request consumes nothing. One claim per project holdout: the same strategy asking again receives its run, another strategy in the project is refused. Once that run has expired with result retention, the same strategy asking again runs the holdout again as a new run (new run_id, charged once, replaying its then-latest development backtest); the holdout is not consumed a second time. A request that reuses the idempotency_key of an earlier holdout request gets that key's stored receipt, which still names the expired run: to run it again pass a new key or none. get_run on the run returns holdout_validation with the training-versus-holdout comparison.
Every run option goes inside settings, never at the top level. Settings differ by mode: wait_for_completion, detail and collect_diagnostics are backtest-only; study is event_study-only.
Sources: inline creates a project strategy (in project_id, or a new project named after it when omitted); saved fences its version; revision pins history; run replays a backtest's recorded experiment. Backtests also accept portfolio_id instead of source for a saved portfolio. Both strategy modes accept document assignments and axes through settings.grid. Each grid candidate is one job of at most 50,000 estimated bar-rows (bars x symbols); a grid's summed candidates may not exceed 500,000. Over either, VALIDATION_ERROR names the estimate: use fewer combinations, a shorter window, a coarser timeframe or fewer symbols.
Reuse idempotency_key for retries of the same request. Changing content under an existing key returns IDEMPOTENCY_CONFLICT. A pending request returns REQUEST_IN_PROGRESS with retry_after_seconds while its lease is live. Expired leases allow one retry to resume before execution admission or return the recorded runs afterward, without another charge or dispatch. An interrupted admission with missing run rows returns REQUEST_INTERRUPTED for reconciliation.
Dates you found (e.g. FDA decisions from the web) are studied in one call: mode="event_study", events={"name":"FDA decisions","dates":["2024-03-15",...], "sources":["https://www.fda.gov/..."]} with source={"kind":"inline", "document":{"instruments":["XBI"],"timeframe":"1d"}}. The dates are saved as your custom event type (id: the name in kebab case) and the entry fires on each date's bar. A date means the end of that day's bar: the US market close for equities, 24:00 UTC for crypto, so the instruments must share one asset class. The same name with other dates is refused with EVENT_TYPE_DUPLICATE. With no lookback or dates in settings, the study spans the dates (a week before the first to 60 days after the last). events is refused with mode=backtest or portfolio_id. Needs custom events on the user's plan; at most 5,000 dates per call.
Capabilities
Bounded options and operating modes surfaced above the full JSON schema.
Mode options
mode
backtestevent_studyRequired Inputs
modeenum: backtest, event_studybacktest simulates the full strategy with trades; event_study measures whether entries predict returns, without trades.Optional Inputs
eventsobjectmode=event_study only. Dates to study instead of authored entries, saved as a custom event type; the source must be inline and list only instruments (and optionally name, timeframe).idempotency_keyanyOf (2 variants)Reuse for retries of the same request.portfolio_idanyOf (2 variants)Saved portfolio to backtest, instead of source. mode=backtest only.settingsanyOf (2 variants)Run options for the selected mode: BacktestSettings for backtest, EventStudyRunSettings for event_study. Omit for defaults. Backtests are limited to 50,000 total bar-rows per job, summed across symbols and including warmup. Before submitting, tell the user the limit and rough runtime guidance: 10,000 bars about 20–40 seconds; 25,000 about 35–70 seconds; 50,000 about 1–2 minutes. These are rough estimates, not deadlines; queue time, strategy complexity and diagnostics can add time. Shorten the window, use a coarser timeframe or fewer symbols to fit; never silently truncate a request. Backtest windows are capped per plan (as short as 1,826 days, about 5 years); a longer request is refused with the earliest allowed start date.sourceanyOf (2 variants)Strategy to run, selected by kind. Required for event_study. A backtest takes exactly one of source or portfolio_id.