tastytrade orders API

Allows an API client to view, filter, create, cancel and replace orders.

OpenAPI Specification

tastytrade-orders-api-openapi.yml Raw ↑
swagger: '2.0'
info:
  title: Account Status accounts orders API
  version: 7.1.0
  description: Operations about accounts
host: api.tastyworks.com
produces:
- application/json
tags:
- name: orders
  description: Allows an API client to view, filter, create, cancel and replace orders.
paths:
  /accounts/{account_number}/orders:
    get:
      description: "Returns a paginated list of the customer's orders (as identified by the provided authentication token)\n      based on sort param. If no sort is passed in, it defaults to descending order."
      produces:
      - application/json
      parameters:
      - in: path
        name: account_number
        type: integer
        format: int32
        required: true
      - in: query
        name: page-offset
        type: integer
        format: int32
        default: 0
        required: false
      - in: query
        name: per-page
        type: integer
        format: int32
        default: 100
        minimum: 1
        maximum: 200
        required: false
      - in: query
        name: end-at
        description: DateTime end range for filtering orders in full date-time
        type: string
        format: date-time
        required: false
      - in: query
        name: end-date
        type: string
        format: date
        required: false
      - in: query
        name: futures-symbol
        description: Used to fetch both futures and futures options orders
        type: string
        required: false
      - in: query
        name: sort
        description: The order to sort results in. Accepts `Desc` or `Asc`. Defaults to `Desc`
        type: string
        default: Desc
        enum:
        - Desc
        - Asc
        required: false
      - in: query
        name: start-at
        description: DateTime start rage for filtering orders in full date-time. Required if start-date param not provided
        type: string
        format: date-time
        required: false
      - in: query
        name: start-date
        type: string
        format: date
        required: false
      - in: query
        name: status
        description: ' (example: status[]={value1}&status[]={value2})'
        type: array
        items:
          type: string
        required: false
      - in: query
        name: underlying-instrument-type
        description: Underlying instrument type
        type: string
        required: false
      - in: query
        name: underlying-symbol
        type: string
        required: false
      responses:
        '200':
          description: "Returns a paginated list of the customer's orders (as identified by the provided authentication token)\n      based on sort param. If no sort is passed in, it defaults to descending order."
          schema:
            type: array
            items:
              $ref: '#/definitions/Order'
      tags:
      - orders
      operationId: getAccountsAccountNumberOrders
    post:
      description: Accepts a json document containing parameters to create an order for the client.
      produces:
      - application/json
      consumes:
      - application/json
      parameters:
      - in: path
        name: account_number
        type: integer
        format: int32
        required: true
      - name: postAccountsAccountNumberOrders
        in: body
        required: true
        schema:
          $ref: '#/definitions/postAccountsAccountNumberOrders'
      responses:
        '201':
          description: Accepts a json document containing parameters to create an order for the client.
          schema:
            $ref: '#/definitions/PlacedOrderResponse'
      tags:
      - orders
      operationId: postAccountsAccountNumberOrders
  /accounts/{account_number}/orders/dry-run:
    post:
      description: "Accepts a json document containing parameters to create an order and \\\n          then runs the prefights without placing the order."
      produces:
      - application/json
      consumes:
      - application/json
      parameters:
      - in: path
        name: account_number
        type: integer
        format: int32
        required: true
      - name: postAccountsAccountNumberOrdersDryRun
        in: body
        required: true
        schema:
          $ref: '#/definitions/postAccountsAccountNumberOrdersDryRun'
      responses:
        '201':
          description: "Accepts a json document containing parameters to create an order and \\\n          then runs the prefights without placing the order."
          schema:
            $ref: '#/definitions/PlacedOrderResponse'
      tags:
      - orders
      operationId: postAccountsAccountNumberOrdersDryRun
  /accounts/{account_number}/orders/live:
    get:
      description: Returns a list of orders from the current trading day. Includes all statuses, not only Live.
      produces:
      - application/json
      parameters:
      - in: path
        name: account_number
        type: integer
        format: int32
        required: true
      - in: query
        name: page-offset
        type: integer
        format: int32
        default: 0
        required: false
      - in: query
        name: per-page
        type: integer
        format: int32
        default: 100
        minimum: 1
        maximum: 200
        required: false
      responses:
        '200':
          description: Returns a list of orders from the current trading day. Includes all statuses, not only Live.
          schema:
            type: array
            items:
              $ref: '#/definitions/Order'
      tags:
      - orders
      operationId: getAccountsAccountNumberOrdersLive
  /accounts/{account_number}/orders/{id}:
    get:
      description: Returns a single order based on the id
      produces:
      - application/json
      parameters:
      - in: path
        name: account_number
        type: integer
        format: int32
        required: true
      - in: path
        name: id
        type: integer
        format: int32
        required: true
      responses:
        '200':
          description: Returns a single order based on the id
          schema:
            $ref: '#/definitions/Order'
      tags:
      - orders
      operationId: getAccountsAccountNumberOrdersId
    put:
      description: Replaces a live order with a new one. Subsequent fills of the original order will abort the replacement.
      produces:
      - application/json
      consumes:
      - application/json
      parameters:
      - in: path
        name: account_number
        type: integer
        format: int32
        required: true
      - in: path
        name: id
        type: integer
        format: int32
        required: true
      - name: putAccountsAccountNumberOrdersId
        in: body
        required: true
        schema:
          $ref: '#/definitions/putAccountsAccountNumberOrdersId'
      responses:
        '200':
          description: Replaces a live order with a new one. Subsequent fills of the original order will abort the replacement.
          schema:
            $ref: '#/definitions/Order'
      tags:
      - orders
      operationId: putAccountsAccountNumberOrdersId
    patch:
      description: "Edit price and execution properties of a live order by replacement. Subsequent fills of the original order\n      will abort the replacement."
      produces:
      - application/json
      consumes:
      - application/json
      parameters:
      - in: path
        name: account_number
        type: integer
        format: int32
        required: true
      - in: path
        name: id
        type: integer
        format: int32
        required: true
      - name: patchAccountsAccountNumberOrdersId
        in: body
        required: true
        schema:
          $ref: '#/definitions/patchAccountsAccountNumberOrdersId'
      responses:
        '200':
          description: "Edit price and execution properties of a live order by replacement. Subsequent fills of the original order\n      will abort the replacement."
          schema:
            $ref: '#/definitions/Order'
      tags:
      - orders
      operationId: patchAccountsAccountNumberOrdersId
    delete:
      description: Requests order cancellation
      produces:
      - application/json
      parameters:
      - in: path
        name: account_number
        type: integer
        format: int32
        required: true
      - in: path
        name: id
        type: integer
        format: int32
        required: true
      responses:
        '200':
          description: Requests order cancellation
          schema:
            $ref: '#/definitions/Order'
      tags:
      - orders
      operationId: deleteAccountsAccountNumberOrdersId
  /accounts/{account_number}/orders/{id}/dry-run:
    post:
      description: Runs through preflights for cancel-replace and edit without routing
      produces:
      - application/json
      consumes:
      - application/json
      parameters:
      - in: path
        name: account_number
        type: integer
        format: int32
        required: true
      - in: path
        name: id
        type: integer
        format: int32
        required: true
      - name: postAccountsAccountNumberOrdersIdDryRun
        in: body
        required: true
        schema:
          $ref: '#/definitions/postAccountsAccountNumberOrdersIdDryRun'
      responses:
        '201':
          description: Runs through preflights for cancel-replace and edit without routing
          schema:
            $ref: '#/definitions/PlacedOrderResponse'
      tags:
      - orders
      operationId: postAccountsAccountNumberOrdersIdDryRun
  /customers/{customer_id}/orders:
    get:
      description: "Returns a paginated list of the customer's orders (as identified by the provided authentication token)\n              based on sort param. If no sort is passed in, it defaults to descending order."
      produces:
      - application/json
      parameters:
      - in: path
        name: customer_id
        type: integer
        format: int32
        required: true
      - in: query
        name: account-numbers
        description: 'The account numbers to use for the lookup (example: account-numbers[]={value1}&account-numbers[]={value2})'
        type: array
        items:
          type: string
        required: true
      - in: query
        name: page-offset
        type: integer
        format: int32
        default: 0
        required: false
      - in: query
        name: per-page
        type: integer
        format: int32
        default: 100
        minimum: 1
        maximum: 200
        required: false
      - in: query
        name: end-at
        description: DateTime end range for filtering orders in full date-time
        type: string
        format: date-time
        required: false
      - in: query
        name: end-date
        type: string
        format: date
        required: false
      - in: query
        name: futures-symbol
        description: Used to fetch both futures and futures options orders
        type: string
        required: false
      - in: query
        name: sort
        description: The order to sort results in. Accepts `Desc` or `Asc`. Defaults to `Desc`
        type: string
        default: Desc
        enum:
        - Desc
        - Asc
        required: false
      - in: query
        name: start-at
        description: DateTime start rage for filtering orders in full date-time. Required if start-date param not provided
        type: string
        format: date-time
        required: false
      - in: query
        name: start-date
        type: string
        format: date
        required: false
      - in: query
        name: status
        description: ' (example: status[]={value1}&status[]={value2})'
        type: array
        items:
          type: string
        required: false
      - in: query
        name: underlying-instrument-type
        description: Underlying instrument type
        type: string
        required: false
      - in: query
        name: underlying-symbol
        type: string
        required: false
      responses:
        '200':
          description: "Returns a paginated list of the customer's orders (as identified by the provided authentication token)\n              based on sort param. If no sort is passed in, it defaults to descending order."
          schema:
            type: array
            items:
              $ref: '#/definitions/Order'
      tags:
      - orders
      operationId: getCustomersCustomerIdOrders
  /customers/{customer_id}/orders/live:
    get:
      description: Returns a list of orders from the current trading day. Includes all statuses, not only Live.
      produces:
      - application/json
      parameters:
      - in: path
        name: customer_id
        type: integer
        format: int32
        required: true
      - in: query
        name: account-numbers
        description: 'The account numbers to use for the lookup (example: account-numbers[]={value1}&account-numbers[]={value2})'
        type: array
        items:
          type: string
        required: true
      - in: query
        name: page-offset
        type: integer
        format: int32
        default: 0
        required: false
      - in: query
        name: per-page
        type: integer
        format: int32
        default: 100
        minimum: 1
        maximum: 200
        required: false
      responses:
        '200':
          description: Returns a list of orders from the current trading day. Includes all statuses, not only Live.
          schema:
            type: array
            items:
              $ref: '#/definitions/Order'
      tags:
      - orders
      operationId: getCustomersCustomerIdOrdersLive
definitions:
  postAccountsAccountNumberOrdersIdDryRun:
    type: object
    properties:
      gtc-date:
        type: string
        format: date
        description: The date in which a GTD order will expire. Can only be provided if time-in-force is GTD.
      order-type:
        type: string
        description: "The type of order in regards to the price. i.e.\n                                    `Limit`, `Market`, `Marketable Limit`, `Notional Market`, `Stop` or `Stop Limit`"
        enum:
        - Limit
        - Market
        - Marketable Limit
        - Notional Market
        - Stop
        - Stop Limit
      stop-trigger:
        type: number
        format: double
        description: The price trigger at which a stop or stop-limit order becomes valid.
      time-in-force:
        type: string
        description: "The length in time before the order expires. i.e.\n                                       `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
      price:
        type: number
        format: double
        description: The price of the Order. Required for limit and stop-limit orders.
      price-effect:
        type: string
        description: If pay or receive payment for placing the order. i.e. `Credit` or `Debit`
        enum:
        - Credit
        - Debit
      value:
        type: number
        format: double
        description: The notional value of the Order, required for notional market orders.
      value-effect:
        type: string
        description: If pay or receive payment for placing the notional market order. i.e. `Credit` or `Debit`
        enum:
        - Credit
        - Debit
      automated-source:
        type: boolean
        description: If the order was placed from an automated source
        default: false
      external-identifier:
        type: string
        description: External identifier for the order
      partition-key:
        type: string
        description: Account partition key
      preflight-id:
        type: string
        description: Transient order identifier used for matching preflight errors to an individual order
      source:
        type: string
        description: The source the order is coming from
      legs:
        type: array
        items:
          type: object
          properties:
            action:
              type: string
              description: TODO
              enum:
              - Allocate
              - Buy
              - Buy to Close
              - Buy to Open
              - Sell
              - Sell to Close
              - Sell to Open
            instrument-type:
              type: string
              description: The type of Instrument.
              enum:
              - Cryptocurrency
              - Equity
              - Equity Option
              - Event Contract
              - Fixed Income Security
              - Future
              - Future Option
              - Liquidity Pool
            quantity:
              type: number
              format: double
              description: TODO
            symbol:
              type: string
              description: "Symbol for stock, specific option symbol in the\n          OCC symbology or specific future symbol. e.g. \"AAPL\", \"AAPL  150515C00120000\", \"/ESM5\""
          required:
          - action
          - instrument-type
          - symbol
    required:
    - order-type
    - stop-trigger
    - time-in-force
    - price-effect
    - value-effect
    description: Runs through preflights for cancel-replace and edit without routing
  PlacedOrderResponse:
    type: object
    properties:
      buying-power-effect:
        description: ''
        type: string
      closing-fee-calculation:
        description: ''
        type: string
      complex-order:
        type: object
        properties:
          id:
            description: ''
            type: string
          account-number:
            description: ''
            type: string
          ratio-price-comparator:
            description: ''
            type: string
          ratio-price-is-threshold-based-on-notional:
            description: ''
            type: boolean
          ratio-price-threshold:
            description: ''
            type: number
            format: double
          terminal-at:
            description: ''
            type: string
          type:
            description: ''
            type: string
          related-orders:
            type: array
            items:
              type: object
              properties:
                id:
                  description: ''
                  type: string
                complex-order-id:
                  description: ''
                  type: string
                complex-order-tag:
                  description: ''
                  type: string
                replaces-order-id:
                  description: ''
                  type: string
                replacing-order-id:
                  description: ''
                  type: string
                status:
                  description: ''
                  type: string
              description: Non-current orders. This includes replaced orders, unfilled orders, and terminal orders.
          orders:
            type: array
            items:
              type: object
              properties:
                id:
                  description: ''
                  type: string
                account-number:
                  description: ''
                  type: string
                cancel-user-id:
                  description: ''
                  type: string
                cancel-username:
                  description: ''
                  type: string
                cancellable:
                  description: ''
                  type: boolean
                cancelled-at:
                  description: ''
                  type: string
                  format: date-time
                cancelled-size:
                  description: ''
                  type: number
                  format: double
                complex-order-id:
                  description: ''
                  type: string
                complex-order-tag:
                  description: ''
                  type: string
                contingent-status:
                  description: ''
                  type: string
                editable:
                  description: ''
                  type: boolean
                edited:
                  description: ''
                  type: boolean
                external-identifier:
                  description: ''
                  type: string
                global-request-id:
                  description: ''
                  type: string
                gtc-date:
                  description: ''
                  type: string
                  format: date
                in-flight-at:
                  description: ''
                  type: string
                  format: date-time
                leg-count:
                  description: ''
                  type: string
                live-at:
                  description: ''
                  type: string
                  format: date-time
                order-type:
                  description: ''
                  type: string
                preflight-id:
                  description: ''
                  type: string
                price:
                  description: ''
                  type: number
                  format: double
                price-effect:
                  description: ''
                  type: string
                received-at:
                  description: ''
                  type: string
                  format: date-time
                reject-reason:
                  description: ''
                  type: string
                replaces-order-id:
                  description: ''
                  type: string
                replacing-order-id:
                  description: ''
                  type: string
                size:
                  description: ''
                  type: string
                source:
                  description: ''
                  type: string
                status:
                  description: ''
                  type: string
                stop-trigger:
                  description: ''
                  type: string
                terminal-at:
                  description: ''
                  type: string
                  format: date-time
                time-in-force:
                  description: ''
                  type: string
                underlying-instrument-type:
                  description: ''
                  type: string
                underlying-symbol:
                  description: ''
                  type: string
                updated-at:
                  description: ''
                  type: string
                user-id:
                  description: ''
                  type: string
                username:
                  description: ''
                  type: string
                value:
                  description: ''
                  type: number
                  format: double
                value-effect:
                  description: ''
                  type: string
                legs:
                  type: array
                  items:
                    type: object
                    properties:
                      action:
                        description: ''
                        type: string
                      instrument-type:
                        description: ''
                        type: string
                      quantity:
                        description: ''
                        type: string
                      remaining-quantity:
                        description: ''
                        type: string
                      symbol:
                        description: ''
                        type: string
                      fills:
                        type: array
                        items:
                          type: object
                          properties:
                            destination-venue:
                              description: ''
                              type: string
                            ext-exec-id:
                              description: ''
                              type: string
                            ext-group-fill-id:
                              description: ''
                              type: string
                            fill-id:
                              description: ''
                              type: string
                            fill-price:
                              description: ''
                              type: number
                              format: double
                            filled-at:
                              description: ''
                              type: string
                              format: date-time
                            quantity:
                              description: ''
                              type: string
                          description: ''
                    description: ''
                order-rule:
                  type: object
                  properties:
                    cancel-at:
                      description: ''
                      type: string
                      format: date-time
                    cancelled-at:
                      description: ''
                      type: string
                      format: date-time
                    route-after:
                      description: ''
                      type: string
                      format: date-time
                    routed-at:
                      description: ''
                      type: string
                      format: date-time
                    order-conditions:
                      type: array
                      items:
                        type: object
                        properties:
                          id:
                            description: ''
                            type: string
                          action:
                            description: ''
                            type: string
                          comparator:
                            description: ''
                            type: string
                          indicator:
                            description: ''
                            type: string
                          instrument-type:
                            description: ''
                            type: string
                          is-threshold-based-on-notional:
                            description: ''
                            type: boolean
                          symbol:
                            description: ''
                            type: string
                          threshold:
                            description: ''
                            type: number
                            format: double
                          triggered-at:
                            description: ''
                            type: string
                            format: date-time
                          triggered-value:
                            description: ''
                            type: number
                            format: double
                          price-components:
                            type: array
                            items:
                              type: object
                              properties:
                                instrument-type:
                                  description: ''
                                  type: string
                                quantity:
                                  description: ''
                                  type: string
                                quantity-direction:
                                  description: ''
                                  type: string
                                symbol:
                                  description: ''
                                  type: string
                              description: ''
                        description: ''
                  description: ''
              description: 'Orders with complex-order-tag: ''<type>::order''. For example, ''OTO::order'' for OTO complex orders.'
          trigger-order:
            type: object
            properties:
              id:
                description: ''
                type: string
              account-number:
                description: ''
                type: string
              cancel-user-id:
                description: ''
                type: string
              cancel-username:
                description: ''
                type: string
              cancellable:
                description: ''
                type: boolean
              cancelled-at:
                description: ''
                type: string
                format: date-time
              cancelled-size:
                description: ''
                type: number
                format: double
              complex-order-id:
                description: ''
                type: string
              complex-order-tag:
                description: ''
                type: string
              contingent-status:
                description: ''
                type: string
              editable:
                description: ''
                type: boolean
              edited:
                description: ''
                type: boolean
              external-identifier:
                description: ''
                type: string
              global-request-id:
                description: ''
                type: string
              gtc-date:
                description: ''
                type: string
                format: date
              in-flight-at:
                description: ''
                type: string
                format: date-time
              leg-count:
                description: ''
                type: string
              live-at:
                description: ''
                type: string
                format: date-time
              order-type:
                description: ''
                type: string
              preflight-id:
                description: ''
                type: string
              price:
                description: ''
                type: number
                format: double
              price-effect:
                description: ''
                type: string
              received-at:
                description: ''
                type: string
                format: date-time
              reject-reason:
                description: ''
                type: string
              replaces-order-id:
                description: ''
                type: string
              replacing-order-id:
                description: ''
                type: string
              size:
                description: ''
                type: string
              source:
                description: ''
                type: string
              status:
                description: ''
                type: string
              stop-trigger:
                description: ''
                type: string
              terminal-at:
                description: ''
                type: string
                format: date-time
              time-in-force:
                description: ''
                type: string
              underlying-instrument-type:
                description: ''
                type: string
              underlying-symbol:
                description: ''
                type: string
              updated-at:
                description: ''
                type: string
              user-id:
                description: ''
                type: string
              username:
                description: ''
                type: string
              value:
                description: ''
                type: number
                format: double
              value-effect:
                description: ''
                type: string
              legs:
                type: array
                items:
                  type: object
                  properties:
                    action:
                      description: ''
                      type: string
                    instrument-type:
                      description: ''
                      type: string
                    quantity:
                      description: ''
            

# --- truncated at 32 KB (82 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/tastytrade/refs/heads/main/openapi/tastytrade-orders-api-openapi.yml