---
title: "Create A Backtest"
method: POST
path: "/backtests"
tags: ["backtesting"]
---

# Create A Backtest

`POST /backtests`

## Request

- Base URL: `https://backtester.vast.tastyworks.com`
- URL: `https://backtester.vast.tastyworks.com/backtests`
- Auth: none declared

Submits a backtest definition (underlying `symbol`, a `startDate`/`endDate` window, and one or more `legs`) and starts the run. A `201` means the backtest is pending and still running; a `200` means it is already completed. Either way the body includes an `id` to poll with `GET /backtests/{id}`.

## Request body

- BacktestPost: The definition of a backtest to run: an underlying `symbol`, a historical `startDate`/`endDate` window, one or more strategy `legs`, and optional `entryConditions`/`exitConditions` controlling when trials open and close.
  - `symbol` string: Underlying symbol the strategy trades. Confirm history exists for your date range via `GET /available-dates`.
  - `startDate` string, date: First date of the historical window to backtest, in ISO 8601 `YYYY-MM-DD` format.
  - `endDate` string, date: Last date of the historical window to backtest, in ISO 8601 `YYYY-MM-DD` format.
  - `legs` Leg[]
    - `type` 'equity' | 'equity-option', required: The instrument type for this leg: `equity` for shares or `equity-option` for an option contract.
    - `direction` 'long' | 'short', required: The position direction: `long` to buy, `short` to sell.
    - `side` 'call' | 'put': The option side, `call` or `put`. Only applicable when `type` is `equity-option`.
    - `quantity` integer, required: Number of contracts or shares (1-10 for options, 1-100 for stocks).
    - `strikeSelection` 'delta' | 'percentageOTM' | 'percentageOTMRelative' | 'currentPriceOffset' | 'currentPriceOffsetRelative' | 'currentPriceExactOffsetRelative' | 'premium', required: How the strike is chosen for this leg. The accompanying value field depends on this: for example `delta` reads `delta`, `premium` reads `premium`.
    - `strikeRelativeLeg` integer: Index of the leg to use as reference when strike selection is relative to another leg.
    - `delta` number: Delta value used when `strikeSelection` is `delta`, expressed as an integer from 1 to 100.
    - `percentageOTM` number: Percentage out-of-the-money when `strikeSelection` is `percentageOTM` or `percentageOTMRelative` (for example 0.1 for 10% OTM, -0.1 for 10% ITM).
    - `currentPriceOffset` number: Offset from current price when `strikeSelection` is a currentPriceOffset variant (max 50000).
    - `premium` number: Target premium when `strikeSelection` is `premium` (max 50000).
    - `daysUntilExpiration` integer, required: Number of days until expiration to target for this leg.
  - `entryConditions` EntryConditions: Optional rules controlling when new trials are opened during the backtest, such as entry frequency, concurrency limits, and VIX bounds.
    - `frequency` 'every day' | 'on specific days of the week' | 'on exact days to expiration match', nullable: How often to open new trials: `every day`, `on specific days of the week`, or `on exact days to expiration match`.
    - `specificDays` integer[], nullable: Days of the week on which to enter, used when `frequency` is `on specific days of the week`.
    - `maximumActiveTrials` integer, nullable: Maximum number of trials allowed open simultaneously.
    - `maximumActiveTrialsBehavior` 'don't enter' | 'close oldest', nullable: What to do when the active-trial limit is reached: `don't enter` to skip the entry, or `close oldest` to free a slot.
    - `minimumVIX` integer, nullable: Only open trials when the VIX is at or above this value.
    - `maximumVIX` integer, nullable: Only open trials when the VIX is at or below this value.
  - `exitConditions` ExitConditions: Optional rules controlling when trials are closed during the backtest, such as profit/loss targets, time in trade, and days to expiration.
    - `takeProfitPercentage` integer, nullable: Profit threshold for closing a trial, expressed as a percentage.
    - `stopLossPercentage` integer, nullable: Loss threshold for closing a trial, expressed as a percentage.
    - `afterDaysInTrade` integer, nullable: Close a trial after it has been open this many days.
    - `atDaysToExpiration` integer, nullable: Close a trial when this many days to expiration remain.
    - `minimumVIX` integer, nullable: VIX threshold used as an exit condition for closing trials.

## Response `200`

Backtest completed and ready to read. The body is a fully populated backtest object.

- BacktestGet: A backtest object returned when creating or polling a backtest. Includes the original definition plus run state (`status`, `progress`, `ETA`) and, once completed, the results in `statistics`, `trials`, `snapshots`, and `notices`.
  - `id` string: Unique identifier for this backtest. Use it with `GET /backtests/{id}` to poll status and read results.
  - `symbol` string: Underlying symbol the strategy trades.
  - `startDate` string, date: First date of the backtested historical window, in ISO 8601 `YYYY-MM-DD` format.
  - `endDate` string, date: Last date of the backtested historical window, in ISO 8601 `YYYY-MM-DD` format.
  - `legs` Leg[]
    - `type` 'equity' | 'equity-option', required: The instrument type for this leg: `equity` for shares or `equity-option` for an option contract.
    - `direction` 'long' | 'short', required: The position direction: `long` to buy, `short` to sell.
    - `side` 'call' | 'put': The option side, `call` or `put`. Only applicable when `type` is `equity-option`.
    - `quantity` integer, required: Number of contracts or shares (1-10 for options, 1-100 for stocks).
    - `strikeSelection` 'delta' | 'percentageOTM' | 'percentageOTMRelative' | 'currentPriceOffset' | 'currentPriceOffsetRelative' | 'currentPriceExactOffsetRelative' | 'premium', required: How the strike is chosen for this leg. The accompanying value field depends on this: for example `delta` reads `delta`, `premium` reads `premium`.
    - `strikeRelativeLeg` integer: Index of the leg to use as reference when strike selection is relative to another leg.
    - `delta` number: Delta value used when `strikeSelection` is `delta`, expressed as an integer from 1 to 100.
    - `percentageOTM` number: Percentage out-of-the-money when `strikeSelection` is `percentageOTM` or `percentageOTMRelative` (for example 0.1 for 10% OTM, -0.1 for 10% ITM).
    - `currentPriceOffset` number: Offset from current price when `strikeSelection` is a currentPriceOffset variant (max 50000).
    - `premium` number: Target premium when `strikeSelection` is `premium` (max 50000).
    - `daysUntilExpiration` integer, required: Number of days until expiration to target for this leg.
  - `entryConditions` EntryConditions: Optional rules controlling when new trials are opened during the backtest, such as entry frequency, concurrency limits, and VIX bounds.
    - `frequency` 'every day' | 'on specific days of the week' | 'on exact days to expiration match', nullable: How often to open new trials: `every day`, `on specific days of the week`, or `on exact days to expiration match`.
    - `specificDays` integer[], nullable: Days of the week on which to enter, used when `frequency` is `on specific days of the week`.
    - `maximumActiveTrials` integer, nullable: Maximum number of trials allowed open simultaneously.
    - `maximumActiveTrialsBehavior` 'don't enter' | 'close oldest', nullable: What to do when the active-trial limit is reached: `don't enter` to skip the entry, or `close oldest` to free a slot.
    - `minimumVIX` integer, nullable: Only open trials when the VIX is at or above this value.
    - `maximumVIX` integer, nullable: Only open trials when the VIX is at or below this value.
  - `exitConditions` ExitConditions: Optional rules controlling when trials are closed during the backtest, such as profit/loss targets, time in trade, and days to expiration.
    - `takeProfitPercentage` integer, nullable: Profit threshold for closing a trial, expressed as a percentage.
    - `stopLossPercentage` integer, nullable: Loss threshold for closing a trial, expressed as a percentage.
    - `afterDaysInTrade` integer, nullable: Close a trial after it has been open this many days.
    - `atDaysToExpiration` integer, nullable: Close a trial when this many days to expiration remain.
    - `minimumVIX` integer, nullable: VIX threshold used as an exit condition for closing trials.
  - `ETA` number: Estimated time remaining until the run completes. Use it to space out polls while the backtest is still running.
  - `progress` number: Completion progress of the run.
  - `status` 'pending' | 'running' | 'completed': Current run state. Moves through `pending`, `running`, and `completed`; read results once it is `completed`.
  - `statistics` object[]: Aggregate performance metrics for the run, populated once the backtest completes.
  - `trials` Trial[]
    - `openDateTime` string: Timestamp the trial opened, in ISO 8601 format.
    - `closeDateTime` string: Timestamp the trial closed, in ISO 8601 format.
    - `profitLoss` number: Realized profit or loss for this trial.
  - `snapshots` Snapshot[]
    - `dateTime` string: Timestamp of this snapshot in ISO 8601 format.
    - `profitLoss` number: Cumulative strategy profit or loss at this point in the run.
    - `underlyingPrice` number: Price of the underlying symbol at this point in the run.
  - `notices` string[]: Conditional annotations appearing if specific conditions are met (for example overlapping ranges due to a stock split).

## Other responses

- `201`: Backtest accepted and still running. Poll `GET /backtests/{id}` and watch `status` until it reaches `completed`.
- `400`: Request included malformed input
- `401`: Unauthorized.
- `404`: Backtest not found
- `429`: Request rate exceeded reasonable thresholds. Back off exponentially before retrying.
- `500`: Failed to process request

---

[API](https://skmtc.dev/tastytrade/apis/backtesting.md) - [All operations](https://skmtc.dev/tastytrade/apis/backtesting/llms.txt) - [OpenAPI document](https://skmtc.dev/tastytrade/apis/backtesting/revisions/482676159080?raw)
