Dry Run Order
postAccountsAccountNumberOrdersDryRun/accounts/{account_number}/orders/dry-runMoney-movingMoney-moving. Dry-run first, send an ext-client-order-id, and confirm before submitting. See Idempotency & retries.
Base URL: https://api.cert.tastyworks.com (Sandbox) · https://api.tastyworks.com (Production)
Runs the full preflight checks for an order without routing it, returning warnings, the buying-power effect, and an estimated fee calculation. A warning here means the order would be rejected if actually submitted. When ready, post the identical body to `POST /accounts/{account_number}/orders`.
Code samples
curl -X POST 'https://api.cert.tastyworks.com/accounts/5WX01234/orders/dry-run' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'User-Agent: tastytrade-docs-example/1.0' \
-H 'Content-Type: application/json' \
-d '{
"gtc-date": "2024-01-15",
"order-type": "Limit",
"time-in-force": "Day",
"stop-trigger": "string",
"price": "150.25",
"price-effect": "Debit",
"value": "100.00",
"value-effect": "Credit",
"automated-source": true,
"external-identifier": "string",
"max-value-per-liquidity-allocation-fill": "100.00",
"partition-key": "string",
"preflight-id": "abc123",
"source": "string",
"legs": [
{
"action": "Allocate",
"instrument-type": "Cryptocurrency",
"quantity": "1",
"symbol": "AAPL"
}
],
"rules": {
"cancel-at": "2024-01-15T14:30:00.000Z",
"conditions": [
{
"action": "cancel",
"instrument-type": "Equity",
"symbol": "AAPL",
"comparator": "gte",
"indicator": "last",
"threshold": "string",
"price-components": [
{
"instrument-type": "Bond",
"quantity": "1",
"quantity-direction": "Long",
"symbol": "AAPL"
}
]
}
],
"route-after": "2024-01-15T14:30:00.000Z"
},
"advanced-instructions": {
"strict-position-effect-validation": true
}
}'import requests
import json
url = "https://api.cert.tastyworks.com/accounts/5WX01234/orders/dry-run"
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"User-Agent": "tastytrade-docs-example/1.0",
}
payload = json.loads("""
{
"gtc-date": "2024-01-15",
"order-type": "Limit",
"time-in-force": "Day",
"stop-trigger": "string",
"price": "150.25",
"price-effect": "Debit",
"value": "100.00",
"value-effect": "Credit",
"automated-source": true,
"external-identifier": "string",
"max-value-per-liquidity-allocation-fill": "100.00",
"partition-key": "string",
"preflight-id": "abc123",
"source": "string",
"legs": [
{
"action": "Allocate",
"instrument-type": "Cryptocurrency",
"quantity": "1",
"symbol": "AAPL"
}
],
"rules": {
"cancel-at": "2024-01-15T14:30:00.000Z",
"conditions": [
{
"action": "cancel",
"instrument-type": "Equity",
"symbol": "AAPL",
"comparator": "gte",
"indicator": "last",
"threshold": "string",
"price-components": [
{
"instrument-type": "Bond",
"quantity": "1",
"quantity-direction": "Long",
"symbol": "AAPL"
}
]
}
],
"route-after": "2024-01-15T14:30:00.000Z"
},
"advanced-instructions": {
"strict-position-effect-validation": true
}
}
""")
resp = requests.post(url, headers=headers, json=payload)
print(resp.status_code, resp.json())const resp = await fetch("https://api.cert.tastyworks.com/accounts/5WX01234/orders/dry-run", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"User-Agent": "tastytrade-docs-example/1.0",
"Content-Type": "application/json",
},
body: JSON.stringify({
"gtc-date": "2024-01-15",
"order-type": "Limit",
"time-in-force": "Day",
"stop-trigger": "string",
"price": "150.25",
"price-effect": "Debit",
"value": "100.00",
"value-effect": "Credit",
"automated-source": true,
"external-identifier": "string",
"max-value-per-liquidity-allocation-fill": "100.00",
"partition-key": "string",
"preflight-id": "abc123",
"source": "string",
"legs": [
{
"action": "Allocate",
"instrument-type": "Cryptocurrency",
"quantity": "1",
"symbol": "AAPL"
}
],
"rules": {
"cancel-at": "2024-01-15T14:30:00.000Z",
"conditions": [
{
"action": "cancel",
"instrument-type": "Equity",
"symbol": "AAPL",
"comparator": "gte",
"indicator": "last",
"threshold": "string",
"price-components": [
{
"instrument-type": "Bond",
"quantity": "1",
"quantity-direction": "Long",
"symbol": "AAPL"
}
]
}
],
"route-after": "2024-01-15T14:30:00.000Z"
},
"advanced-instructions": {
"strict-position-effect-validation": true
}
}),
})
const data = await resp.json()
console.log(resp.status, data)package main
import (
"net/http"
"io"
"fmt"
"strings"
)
func main() {
body := strings.NewReader(`{
"gtc-date": "2024-01-15",
"order-type": "Limit",
"time-in-force": "Day",
"stop-trigger": "string",
"price": "150.25",
"price-effect": "Debit",
"value": "100.00",
"value-effect": "Credit",
"automated-source": true,
"external-identifier": "string",
"max-value-per-liquidity-allocation-fill": "100.00",
"partition-key": "string",
"preflight-id": "abc123",
"source": "string",
"legs": [
{
"action": "Allocate",
"instrument-type": "Cryptocurrency",
"quantity": "1",
"symbol": "AAPL"
}
],
"rules": {
"cancel-at": "2024-01-15T14:30:00.000Z",
"conditions": [
{
"action": "cancel",
"instrument-type": "Equity",
"symbol": "AAPL",
"comparator": "gte",
"indicator": "last",
"threshold": "string",
"price-components": [
{
"instrument-type": "Bond",
"quantity": "1",
"quantity-direction": "Long",
"symbol": "AAPL"
}
]
}
],
"route-after": "2024-01-15T14:30:00.000Z"
},
"advanced-instructions": {
"strict-position-effect-validation": true
}
}`)
req, _ := http.NewRequest("POST", "https://api.cert.tastyworks.com/accounts/5WX01234/orders/dry-run", body)
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
req.Header.Set("User-Agent", "tastytrade-docs-example/1.0")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(resp.Status, string(out))
}import java.net.URI;
import java.net.http.*;
HttpClient client = HttpClient.newHttpClient();
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.cert.tastyworks.com/accounts/5WX01234/orders/dry-run"))
.header("Authorization", "Bearer YOUR_ACCESS_TOKEN")
.header("User-Agent", "tastytrade-docs-example/1.0")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("""
{
"gtc-date": "2024-01-15",
"order-type": "Limit",
"time-in-force": "Day",
"stop-trigger": "string",
"price": "150.25",
"price-effect": "Debit",
"value": "100.00",
"value-effect": "Credit",
"automated-source": true,
"external-identifier": "string",
"max-value-per-liquidity-allocation-fill": "100.00",
"partition-key": "string",
"preflight-id": "abc123",
"source": "string",
"legs": [
{
"action": "Allocate",
"instrument-type": "Cryptocurrency",
"quantity": "1",
"symbol": "AAPL"
}
],
"rules": {
"cancel-at": "2024-01-15T14:30:00.000Z",
"conditions": [
{
"action": "cancel",
"instrument-type": "Equity",
"symbol": "AAPL",
"comparator": "gte",
"indicator": "last",
"threshold": "string",
"price-components": [
{
"instrument-type": "Bond",
"quantity": "1",
"quantity-direction": "Long",
"symbol": "AAPL"
}
]
}
],
"route-after": "2024-01-15T14:30:00.000Z"
},
"advanced-instructions": {
"strict-position-effect-validation": true
}
}
"""))
.build();
HttpResponse<String> resp = client.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.statusCode() + " " + resp.body());Parameters
| Name | In | Type | Description |
|---|---|---|---|
| account_number* | path | string | e.g. "5WX01234" |
Request bodyrequiredapplication/json
Example
{
"gtc-date": "2024-01-15",
"order-type": "Limit",
"time-in-force": "Day",
"stop-trigger": "string",
"price": "150.25",
"price-effect": "Debit",
"value": "100.00",
"value-effect": "Credit",
"automated-source": true,
"external-identifier": "string",
"max-value-per-liquidity-allocation-fill": "100.00",
"partition-key": "string",
"preflight-id": "abc123",
"source": "string",
"legs": [
{
"action": "Allocate",
"instrument-type": "Cryptocurrency",
"quantity": "1",
"symbol": "AAPL"
}
],
"rules": {
"cancel-at": "2024-01-15T14:30:00.000Z",
"conditions": [
{
"action": "cancel",
"instrument-type": "Equity",
"symbol": "AAPL",
"comparator": "gte",
"indicator": "last",
"threshold": "string",
"price-components": [
{
"instrument-type": "Bond",
"quantity": "1",
"quantity-direction": "Long",
"symbol": "AAPL"
}
]
}
],
"route-after": "2024-01-15T14:30:00.000Z"
},
"advanced-instructions": {
"strict-position-effect-validation": true
}
}Schema
gtc-datestring <date>The date in which a GTD order will expire. Can only be provided if time-in-force is GTD.
order-typerequiredstringThe type of order in regards to the price. i.e. `Limit`, `Liquidity Allocation`, `Market`, `Marketable Limit`, `Notional Market`, `Stop` or `Stop Limit`
enum: Limit, Liquidity Allocation, Market, Marketable Limit, Notional Market, Stop, Stop Limit
example:
"Limit"time-in-forcerequiredstringThe length in time before the order expires. i.e. `Day`, `Ext`, `Ext Overnight`, `GTC`, `GTC Ext`, `GTC Ext Overnight`, `GTD` or `IOC`
enum: Day, Ext, Ext Overnight, GTC, GTC Ext, GTC Ext Overnight, GTD, IOC
example:
"Day"stop-triggerstring <decimal>The price trigger at which a stop or stop-limit order becomes valid. Decimal value serialized as a JSON string (e.g. "150.25").
pricestring <decimal>The price of the Order. Required for limit and stop-limit orders. Decimal value serialized as a JSON string (e.g. "150.25").
example:
"150.25"price-effectstringIf pay or receive payment for placing the order. i.e. `Credit` or `Debit`
enum: Credit, Debit
example:
"Debit"valuestring <decimal>The notional value of the Order, required for notional market orders. Decimal value serialized as a JSON string (e.g. "150.25").
value-effectstringIf pay or receive payment for placing the notional market order. i.e. `Credit` or `Debit`
enum: Credit, Debit
automated-sourcebooleanIf the order was placed from an automated source
external-identifierstringExternal identifier for the order
max-value-per-liquidity-allocation-fillstring <decimal>Max value per liquidity allocation fill Decimal value serialized as a JSON string (e.g. "150.25").
partition-keystringAccount partition key
preflight-idstringTransient order identifier used for matching preflight errors to an individual order
sourcestringThe source the order is coming from
legsrequiredarray<object>actionrequiredstringThe directional action of the leg. i.e. `Allocate`, `Buy`, `Buy to Close`, `Buy to Open`, `Sell`, `Sell to Close` or `Sell to Open`. Note: `Buy` and `Sell` are only applicable to Futures orders.
enum: Allocate, Buy, Buy to Close, Buy to Open, Sell, Sell to Close, Sell to Open
instrument-typerequiredstringThe type of Instrument. i.e. `Cryptocurrency`, `Equity`, `Equity Offering`, `Equity Option`, `Fixed Income Security`, `Future`, `Future Option` or `Liquidity Pool`
enum: Cryptocurrency, Equity, Equity Offering, Equity Option, Fixed Income Security, Future, Future Option, Liquidity Pool
quantitystring <decimal>The size of the contract. Required for all orders but notional market. Decimal value serialized as a JSON string (e.g. "150.25").
symbolrequiredstringThe Stock Ticker Symbol `AAPL`, OCC Option Symbol `AAPL 191004P00275000`, \ TW Future Symbol `/ESZ9`, or TW Future Option Symbol `./ESZ9 EW4U9 190927P2975`
rulesobjectcancel-atstring <date-time>Latest time an order should be canceled at
conditionsarray<object>{7 fields}route-afterstring <date-time>Earliest time an order should route at
advanced-instructionsobjectstrict-position-effect-validationbooleanIf the order should be rejected the open/close position effect is not valid
Responses
Example response
{
"data": {
"buying-power-effect": {
"change-in-margin-requirement": "300.0",
"change-in-margin-requirement-effect": "Debit",
"change-in-buying-power": "102.302",
"change-in-buying-power-effect": "Debit",
"current-buying-power": "8995981.2613",
"current-buying-power-effect": "Credit",
"new-buying-power": "8995878.9593",
"new-buying-power-effect": "Credit",
"isolated-order-margin-requirement": "300.0",
"isolated-order-margin-requirement-effect": "Debit",
"is-spread": true,
"impact": "102.302",
"effect": "Debit"
},
"closing-fee-calculation": "string",
"complex-order": {
"id": "abc123",
"account-number": "5WX01234",
"ratio-price-comparator": "100.00",
"ratio-price-is-threshold-based-on-notional": true,
"ratio-price-threshold": "100.00",
"terminal-at": "2024-01-15T14:30:00.000Z",
"type": "string",
"related-orders": [
{
"id": "abc123",
"complex-order-id": "abc123",
"complex-order-tag": "string",
"replaces-order-id": "abc123",
"replacing-order-id": "abc123",
"status": "string"
}
],
"orders": [
{
"id": "abc123",
"account-number": "5WX01234",
"cancel-user-id": "abc123",
"cancel-username": "string",
"cancellable": true,
"cancelled-at": "2024-01-15T14:30:00.000Z",
"complex-order-id": "abc123",
"complex-order-tag": "string",
"confirmation-status": "string",
"contingent-status": "string",
"editable": true,
"edited": true,
"external-identifier": "string",
"global-request-id": "abc123",
"gtc-date": "2024-01-15",
"in-flight-at": "2024-01-15T14:30:00.000Z",
"liquidity-pool-instrument-type": "Equity",
"live-at": "2024-01-15T14:30:00.000Z",
"max-value-per-liquidity-allocation-fill": "100.00",
"order-type": "string",
"preflight-id": "abc123",
"price": "100.00",
"price-effect": "100.00",
"received-at": "2024-01-15T14:30:00.000Z",
"reject-reason": "string",
"replaces-order-id": "abc123",
"replacing-order-id": "abc123",
"size": "string",
"source": "string",
"status": "string",
"stop-trigger": "string",
"terminal-at": "2024-01-15T14:30:00.000Z",
"time-in-force": "string",
"underlying-instrument-type": "Equity",
"underlying-symbol": "AAPL",
"updated-at": "2024-01-15T14:30:00.000Z",
"user-id": "abc123",
"username": "string",
"value": "100.00",
"value-effect": "100.00",
"legs": [
{}
],
"order-rule": {
"cancel-at": "2024-01-15T14:30:00.000Z",
"cancelled-at": "2024-01-15T14:30:00.000Z",
"route-after": "2024-01-15T14:30:00.000Z",
"routed-at": "2024-01-15T14:30:00.000Z",
"order-conditions": []
}
}
],
"trigger-order": {
"id": "abc123",
"account-number": "5WX01234",
"cancel-user-id": "abc123",
"cancel-username": "string",
"cancellable": true,
"cancelled-at": "2024-01-15T14:30:00.000Z",
"complex-order-id": "abc123",
"complex-order-tag": "string",
"confirmation-status": "string",
"contingent-status": "string",
"editable": true,
"edited": true,
"external-identifier": "string",
"global-request-id": "abc123",
"gtc-date": "2024-01-15",
"in-flight-at": "2024-01-15T14:30:00.000Z",
"liquidity-pool-instrument-type": "Equity",
"live-at": "2024-01-15T14:30:00.000Z",
"max-value-per-liquidity-allocation-fill": "100.00",
"order-type": "string",
"preflight-id": "abc123",
"price": "100.00",
"price-effect": "100.00",
"received-at": "2024-01-15T14:30:00.000Z",
"reject-reason": "string",
"replaces-order-id": "abc123",
"replacing-order-id": "abc123",
"size": "string",
"source": "string",
"status": "string",
"stop-trigger": "string",
"terminal-at": "2024-01-15T14:30:00.000Z",
"time-in-force": "string",
"underlying-instrument-type": "Equity",
"underlying-symbol": "AAPL",
"updated-at": "2024-01-15T14:30:00.000Z",
"user-id": "abc123",
"username": "string",
"value": "100.00",
"value-effect": "100.00",
"legs": [
{
"action": "string",
"instrument-type": "Equity",
"quantity": "1",
"remaining-quantity": "1",
"symbol": "AAPL",
"fills": []
}
],
"order-rule": {
"cancel-at": "2024-01-15T14:30:00.000Z",
"cancelled-at": "2024-01-15T14:30:00.000Z",
"route-after": "2024-01-15T14:30:00.000Z",
"routed-at": "2024-01-15T14:30:00.000Z",
"order-conditions": [
{}
]
}
}
},
"errors": [
{
"code": "string",
"message": "string",
"preflight-id": "abc123"
}
],
"fee-calculation": {
"regulatory-fees": "0.102",
"regulatory-fees-effect": "Debit",
"clearing-fees": "0.2",
"clearing-fees-effect": "Debit",
"commission": "2.0",
"commission-effect": "Debit",
"proprietary-index-option-fees": "0.0",
"proprietary-index-option-fees-effect": "Debit",
"total-fees": "2.302",
"total-fees-effect": "Debit"
},
"notes": [
{
"code": "string",
"message": "string",
"preflight-id": "abc123",
"url": "string"
}
],
"order": {
"id": "abc123",
"account-number": "5WX01234",
"cancel-user-id": "abc123",
"cancel-username": "string",
"cancellable": true,
"cancelled-at": "2024-01-15T14:30:00.000Z",
"complex-order-id": "abc123",
"complex-order-tag": "string",
"confirmation-status": "string",
"contingent-status": "string",
"editable": true,
"edited": true,
"external-identifier": "string",
"global-request-id": "abc123",
"gtc-date": "2024-01-15",
"in-flight-at": "2024-01-15T14:30:00.000Z",
"liquidity-pool-instrument-type": "Equity",
"live-at": "2024-01-15T14:30:00.000Z",
"max-value-per-liquidity-allocation-fill": "100.00",
"order-type": "string",
"preflight-id": "abc123",
"price": "100.00",
"price-effect": "100.00",
"received-at": "2024-01-15T14:30:00.000Z",
"reject-reason": "string",
"replaces-order-id": "abc123",
"replacing-order-id": "abc123",
"size": "string",
"source": "string",
"status": "string",
"stop-trigger": "string",
"terminal-at": "2024-01-15T14:30:00.000Z",
"time-in-force": "string",
"underlying-instrument-type": "Equity",
"underlying-symbol": "AAPL",
"updated-at": "2024-01-15T14:30:00.000Z",
"user-id": "abc123",
"username": "string",
"value": "100.00",
"value-effect": "100.00",
"legs": [
{
"action": "string",
"instrument-type": "Equity",
"quantity": "1",
"remaining-quantity": "1",
"symbol": "AAPL",
"fills": [
{}
]
}
],
"order-rule": {
"cancel-at": "2024-01-15T14:30:00.000Z",
"cancelled-at": "2024-01-15T14:30:00.000Z",
"route-after": "2024-01-15T14:30:00.000Z",
"routed-at": "2024-01-15T14:30:00.000Z",
"order-conditions": [
{
"id": "abc123",
"action": "string",
"comparator": "string",
"indicator": "string",
"instrument-type": "Equity",
"is-threshold-based-on-notional": true,
"symbol": "AAPL",
"threshold": "string",
"triggered-at": "2024-01-15T14:30:00.000Z",
"triggered-value": "100.00",
"price-components": []
}
]
}
},
"warnings": [
{
"code": "string",
"message": "string",
"preflight-id": "abc123"
}
]
},
"context": "/accounts/{account_number}/orders/dry-run"
}Schema
datarequiredobject (PlacedOrderResponse)The response returned when placing, editing, or dry-running an order or complex order. Contains the resulting `order` (or `complex-order`), the `buying-power-effect`, the `fee-calculation`, and any `warnings`, `errors`, or `notes` produced by the preflight checks.
buying-power-effectobject{13 fields}Details of the order's impact on the account's buying power, including the change in buying power and its direction. A JSON object (upstream types this field as a string; attested responses return this object, with decimal values serialized as JSON strings).
closing-fee-calculationstringAn estimate of the fees to expect when later closing the position this order would open. Provided as a convenience; not applied to this order.
complex-orderobject{10 fields}errorsarray<object>{3 fields}Preflight errors explaining why the order failed validation, each with a `code`, `message`, and `preflight-id`.
fee-calculationobject{10 fields}An estimate of the fees the order would incur if filled, broken into regulatory, clearing, commission, and other categories and totaled at the end. A JSON object (upstream types this field as a string; attested responses return this object, with decimal values serialized as JSON strings).
notesarray<object>{4 fields}Informational notes about the order, each optionally including a `url` for more detail.
orderobject{42 fields}warningsarray<object>{3 fields}Informational warnings produced by a dry-run or submission. A warning may indicate the order would be rejected if routed, or that the market is closed.
contextrequiredstringexample:
"/accounts/{account_number}/orders/dry-run"
Example response
{
"error": {
"code": "unauthorized",
"message": "No valid access token was provided; access tokens expire after 15 minutes."
}
}Schema
errorrequiredobjectcoderequiredstringMachine-readable error code (see the Error reference).
messagerequiredstringHuman-readable explanation.
errorsarray<object>{3 fields}Present for multi-error / validation failures; one entry per problem.
Example response
{
"error": {
"code": "not_permitted",
"message": "User not permitted access"
}
}Schema
errorrequiredobjectcoderequiredstringMachine-readable error code (see the Error reference).
messagerequiredstringHuman-readable explanation.
errorsarray<object>{3 fields}Present for multi-error / validation failures; one entry per problem.
Example response
{
"error": {
"code": "string",
"message": "string",
"errors": [
{
"code": "string",
"message": "string",
"domain": "string"
}
]
}
}Schema
errorrequiredobjectcoderequiredstringMachine-readable error code (see the Error reference).
messagerequiredstringHuman-readable explanation.
errorsarray<object>{3 fields}Present for multi-error / validation failures; one entry per problem.
Example response
{
"error": {
"code": "preflight_check_failure",
"message": "One or more preflight checks failed",
"errors": [
{
"code": "preflight_check_failure",
"message": "A specific validation failed for this order."
}
]
}
}Schema
errorrequiredobjectcoderequiredstringMachine-readable error code (see the Error reference).
messagerequiredstringHuman-readable explanation.
errorsarray<object>{3 fields}Present for multi-error / validation failures; one entry per problem.
Example response
{
"error": {
"code": "string",
"message": "string",
"errors": [
{
"code": "string",
"message": "string",
"domain": "string"
}
]
}
}Schema
errorrequiredobjectcoderequiredstringMachine-readable error code (see the Error reference).
messagerequiredstringHuman-readable explanation.
errorsarray<object>{3 fields}Present for multi-error / validation failures; one entry per problem.
Related
- Rate-limit class:
destructive· not idempotent — Rate limits & backoff - Idempotency & retries — safe retries for order placement
- Error reference — codes, causes, and fixes
Agents: this page is also Markdown (with the embedded OpenAPI definition) — append .md or send Accept: text/markdown. Index at /llms.txt.