tastytrade

Account

pydantic model tastytrade.account.Account(*, account_number: str, opened_at: datetime, nickname: str, account_type_name: str, is_closed: bool, day_trader_status: str | bool, is_firm_error: bool, is_firm_proprietary: bool, is_futures_approved: bool, is_test_drive: bool = False, margin_or_cash: str, is_foreign: bool, created_at: datetime, external_id: str | None = None, closed_at: str | None = None, funding_date: date | None = None, investment_objective: str | None = None, liquidity_needs: str | None = None, risk_tolerance: str | None = None, investment_time_horizon: str | None = None, futures_account_purpose: str | None = None, external_fdid: str | None = None, suitable_options_level: str | None = None, submitting_user_id: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass that represents a Tastytrade account object, containing methods for retrieving information about the account, placing orders, and retrieving past transactions.

Show JSON schema
{
   "title": "Account",
   "description": "Dataclass that represents a Tastytrade account object, containing\nmethods for retrieving information about the account, placing orders,\nand retrieving past transactions.",
   "type": "object",
   "properties": {
      "account-number": {
         "title": "Account-Number",
         "type": "string"
      },
      "opened-at": {
         "format": "date-time",
         "title": "Opened-At",
         "type": "string"
      },
      "nickname": {
         "title": "Nickname",
         "type": "string"
      },
      "account-type-name": {
         "title": "Account-Type-Name",
         "type": "string"
      },
      "is-closed": {
         "title": "Is-Closed",
         "type": "boolean"
      },
      "day-trader-status": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "boolean"
            }
         ],
         "title": "Day-Trader-Status"
      },
      "is-firm-error": {
         "title": "Is-Firm-Error",
         "type": "boolean"
      },
      "is-firm-proprietary": {
         "title": "Is-Firm-Proprietary",
         "type": "boolean"
      },
      "is-futures-approved": {
         "title": "Is-Futures-Approved",
         "type": "boolean"
      },
      "is-test-drive": {
         "default": false,
         "title": "Is-Test-Drive",
         "type": "boolean"
      },
      "margin-or-cash": {
         "title": "Margin-Or-Cash",
         "type": "string"
      },
      "is-foreign": {
         "title": "Is-Foreign",
         "type": "boolean"
      },
      "created-at": {
         "format": "date-time",
         "title": "Created-At",
         "type": "string"
      },
      "external-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "External-Id"
      },
      "closed-at": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Closed-At"
      },
      "funding-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Funding-Date"
      },
      "investment-objective": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Investment-Objective"
      },
      "liquidity-needs": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Liquidity-Needs"
      },
      "risk-tolerance": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Risk-Tolerance"
      },
      "investment-time-horizon": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Investment-Time-Horizon"
      },
      "futures-account-purpose": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Futures-Account-Purpose"
      },
      "external-fdid": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "External-Fdid"
      },
      "suitable-options-level": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Suitable-Options-Level"
      },
      "submitting-user-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Submitting-User-Id"
      }
   },
   "required": [
      "account-number",
      "opened-at",
      "nickname",
      "account-type-name",
      "is-closed",
      "day-trader-status",
      "is-firm-error",
      "is-firm-proprietary",
      "is-futures-approved",
      "margin-or-cash",
      "is-foreign",
      "created-at"
   ]
}

Fields:
  • account_number (str)

  • account_type_name (str)

  • closed_at (str | None)

  • created_at (datetime.datetime)

  • day_trader_status (str | bool)

  • external_fdid (str | None)

  • external_id (str | None)

  • funding_date (datetime.date | None)

  • futures_account_purpose (str | None)

  • investment_objective (str | None)

  • investment_time_horizon (str | None)

  • is_closed (bool)

  • is_firm_error (bool)

  • is_firm_proprietary (bool)

  • is_foreign (bool)

  • is_futures_approved (bool)

  • is_test_drive (bool)

  • liquidity_needs (str | None)

  • margin_or_cash (str)

  • nickname (str)

  • opened_at (datetime.datetime)

  • risk_tolerance (str | None)

  • submitting_user_id (str | None)

  • suitable_options_level (str | None)

async a_delete_complex_order(session: Session, order_id: int) None

Delete a complex order by ID.

Parameters:
  • session – the session to use for the request.

  • order_id – the ID of the order to delete.

async a_delete_order(session: Session, order_id: int) None

Delete an order by ID.

Parameters:
  • session – the session to use for the request.

  • order_id – the ID of the order to delete.

async classmethod a_get_account(session: Session, account_number: str) Self

Returns the Tastytrade account associated with the given account ID.

Parameters:
  • session – the session to use for the request.

  • account_number – the account ID to get.

async classmethod a_get_accounts(session: Session, include_closed=False) list[typing_extensions.Self]

Gets all trading accounts associated with the Tastytrade user.

Parameters:
  • session – the session to use for the request.

  • include_closed – whether to include closed accounts in the results (default False)

async a_get_balance_snapshots(session: Session, per_page: int = 250, page_offset: int | None = None, currency: str = 'USD', end_date: date | None = None, start_date: date | None = None, snapshot_date: date | None = None, time_of_day: Literal['BOD', 'EOD'] = 'EOD') list[tastytrade.account.AccountBalanceSnapshot]

Returns a list of balance snapshots. This list will just have a few snapshots if you don’t pass a start date; otherwise, it will be each day’s balances in the given range.

Parameters:
  • session – the session to use for the request.

  • currency – the currency to show balances in.

  • start_date – the starting date of the range.

  • end_date – the ending date of the range.

  • snapshot_date – the date of the snapshot to get.

  • time_of_day – the time of day of the snapshots to get, either ‘EOD’ (End Of Day) or ‘BOD’ (Beginning Of Day).

async a_get_balances(session: Session) AccountBalance

Get the current balances of the account.

Parameters:

session – the session to use for the request.

async a_get_complex_order(session: Session, order_id: int) PlacedComplexOrder

Gets a complex order with the given ID.

Parameters:
  • session – the session to use for the request.

  • order_id – the ID of the order to fetch.

async a_get_complex_order_history(session: Session, per_page: int = 50, page_offset: int | None = None) list[tastytrade.order.PlacedComplexOrder]

Get order history of the account.

Parameters:
  • session – the session to use for the request.

  • per_page – the number of results to return per page.

  • page_offset – provide a specific page to get; if not provided, get all pages

async a_get_effective_margin_requirements(session: Session, symbol: str) MarginRequirement

Get the effective margin requirements for a given symbol.

Parameters:
  • session – the session to use for the request, can’t be certification

  • symbol – the symbol to get margin requirements for.

async a_get_history(session: Session, per_page: int = 250, page_offset: int | None = None, sort: str = 'Desc', type: str | None = None, types: list[str] | None = None, sub_types: list[str] | None = None, start_date: date | None = None, end_date: date | None = None, instrument_type: InstrumentType | None = None, symbol: str | None = None, underlying_symbol: str | None = None, action: str | None = None, partition_key: str | None = None, futures_symbol: str | None = None, start_at: datetime | None = None, end_at: datetime | None = None) list[tastytrade.account.Transaction]

Get transaction history of the account.

Parameters:
  • session – the session to use for the request.

  • per_page – the number of results to return per page.

  • page_offset – provide a specific page to get; if not provided, get all pages

  • sort – the order to sort results in, either ‘Desc’ or ‘Asc’.

  • type – the type of transaction.

  • types – a list of transaction types to filter by.

  • sub_types – an array of transaction subtypes to filter by.

  • start_date – the start date of transactions to query.

  • end_date – the end date of transactions to query.

  • instrument_type – the type of instrument.

  • symbol – a single symbol.

  • underlying_symbol – the underlying symbol.

  • action – the action of the transaction: ‘Sell to Open’, ‘Sell to Close’, ‘Buy to Open’, ‘Buy to Close’, ‘Sell’ or ‘Buy’.

  • partition_key – account partition key.

  • futures_symbol – the full TW Future Symbol, e.g. /ESZ9, /NGZ19.

  • start_at – datetime start range for filtering transactions in full date-time.

  • end_at – datetime end range for filtering transactions in full date-time.

async a_get_live_complex_orders(session: Session) list[tastytrade.order.PlacedComplexOrder]

Get complex orders placed today for the account.

Parameters:

session – the session to use for the request.

async a_get_live_orders(session: Session) list[tastytrade.order.PlacedOrder]

Get orders placed today for the account.

Parameters:

session – the session to use for the request.

async a_get_margin_requirements(session: Session) MarginReport

Get the margin report for the account, with total margin requirements as well as a breakdown per symbol/instrument.

Parameters:

session – the session to use for the request.

async a_get_net_liquidating_value_history(session: Session, time_back: str | None = None, start_time: datetime | None = None) list[tastytrade.account.NetLiqOhlc]

Returns a list of account net liquidating value snapshots over the specified time period.

Parameters:
  • session – the session to use for the request, can’t be certification.

  • time_back – the time period to get net liquidating value snapshots for. This param is required if start_time is not given. Possible values are: ‘1d’, ‘1m’, ‘3m’, ‘6m’, ‘1y’, ‘all’.

  • start_time – the start point for the query. This param is required is time-back is not given. If given, will take precedence over time-back.

async a_get_order(session: Session, order_id: int) PlacedOrder

Gets an order with the given ID.

Parameters:
  • session – the session to use for the request.

  • order_id – the ID of the order to fetch.

async a_get_order_chains(session: Session, symbol: str, start_time: datetime, end_time: datetime) list[tastytrade.order.OrderChain]

Get a list of order chains (open + rolls + close) for given symbol over the given time frame, with total P/L, commissions, etc.

Parameters:
  • session – the session to use for the request.

  • symbol – the underlying symbol for the chains.

  • start_time – the beginning time of the query.

  • end_time – the ending time of the query.

async a_get_order_history(session: Session, per_page: int = 50, page_offset: int | None = None, start_date: date | None = None, end_date: date | None = None, underlying_symbol: str | None = None, statuses: list[tastytrade.order.OrderStatus] | None = None, futures_symbol: str | None = None, underlying_instrument_type: InstrumentType | None = None, sort: str | None = None, start_at: datetime | None = None, end_at: datetime | None = None) list[tastytrade.order.PlacedOrder]

Get order history of the account.

Parameters:
  • session – the session to use for the request.

  • per_page – the number of results to return per page.

  • page_offset – provide a specific page to get; if not provided, get all pages

  • start_date – the start date of orders to query.

  • end_date – the end date of orders to query.

  • underlying_symbol – underlying symbol to filter by.

  • statuses – a list of statuses to filter by.

  • futures_symbol – Tastytrade future symbol for futures and future options.

  • underlying_instrument_type – the type of instrument to filter by

  • sort – the order to sort results in, either ‘Desc’ or ‘Asc’.

  • start_at – datetime start range for filtering transactions in full date-time.

  • end_at – datetime end range for filtering transactions in full date-time.

async a_get_position_limit(session: Session) PositionLimit

Get the maximum order size information for the account.

Parameters:

session – the session to use for the request.

async a_get_positions(session: Session, underlying_symbols: list[str] | None = None, symbol: str | None = None, instrument_type: InstrumentType | None = None, include_closed: bool | None = None, underlying_product_code: str | None = None, partition_keys: list[str] | None = None, net_positions: bool | None = None, include_marks: bool | None = None) list[tastytrade.account.CurrentPosition]

Get the current positions of the account.

Parameters:
  • session – the session to use for the request.

  • underlying_symbols – an array of underlying symbols for positions.

  • symbol – a single symbol.

  • instrument_type – the type of instrument.

  • include_closed – if closed positions should be included in the query.

  • underlying_product_code – the underlying future’s product code.

  • partition_keys – account partition keys.

  • net_positions – returns net positions grouped by instrument type and symbol.

  • include_marks – include current quote mark (note: can decrease performance).

async a_get_total_fees(session: Session, day: date | None = None) FeesInfo

Get the total fees for a given date.

Parameters:
  • session – the session to use for the request.

  • day – the date to get fees for.

async a_get_trading_status(session: Session) TradingStatus

Get the trading status of the account.

Parameters:

session – the session to use for the request.

async a_get_transaction(session: Session, id: int) Transaction

Get a single transaction by ID.

Parameters:
  • session – the session to use for the request.

  • id – the ID of the transaction to fetch.

async a_place_complex_order(session: Session, order: NewComplexOrder, dry_run: bool = True) PlacedComplexOrderResponse

Place the given order.

Parameters:
  • session – the session to use for the request.

  • order – the order to place.

  • dry_run – whether this is a test order or not.

async a_place_order(session: Session, order: NewOrder, dry_run: bool = True) PlacedOrderResponse

Place the given order.

Parameters:
  • session – the session to use for the request.

  • order – the order to place.

  • dry_run – whether this is a test order or not.

async a_replace_order(session: Session, old_order_id: int, new_order: NewOrder) PlacedOrder

Replace an order with a new order with different characteristics (but same legs).

Parameters:
  • session – the session to use for the request.

  • old_order_id – the ID of the order to replace.

  • new_order – the new order to replace the old order with.

delete_complex_order(session: Session, order_id: int) None

Delete a complex order by ID.

Parameters:
  • session – the session to use for the request.

  • order_id – the ID of the order to delete.

delete_order(session: Session, order_id: int) None

Delete an order by ID.

Parameters:
  • session – the session to use for the request.

  • order_id – the ID of the order to delete.

classmethod get_account(session: Session, account_number: str) Self

Returns the Tastytrade account associated with the given account ID.

Parameters:
  • session – the session to use for the request.

  • account_number – the account ID to get.

classmethod get_accounts(session: Session, include_closed=False) list[typing_extensions.Self]

Gets all trading accounts associated with the Tastytrade user.

Parameters:
  • session – the session to use for the request.

  • include_closed – whether to include closed accounts in the results (default False)

get_balance_snapshots(session: Session, per_page: int = 250, page_offset: int | None = None, currency: str = 'USD', end_date: date | None = None, start_date: date | None = None, snapshot_date: date | None = None, time_of_day: Literal['BOD', 'EOD'] = 'EOD') list[tastytrade.account.AccountBalanceSnapshot]

Returns a list of balance snapshots. This list will just have a few snapshots if you don’t pass a start date; otherwise, it will be each day’s balances in the given range.

Parameters:
  • session – the session to use for the request.

  • currency – the currency to show balances in.

  • start_date – the starting date of the range.

  • end_date – the ending date of the range.

  • snapshot_date – the date of the snapshot to get.

  • time_of_day – the time of day of the snapshots to get, either ‘EOD’ (End Of Day) or ‘BOD’ (Beginning Of Day).

get_balances(session: Session) AccountBalance

Get the current balances of the account.

Parameters:

session – the session to use for the request.

get_complex_order(session: Session, order_id: int) PlacedComplexOrder

Gets a complex order with the given ID.

Parameters:
  • session – the session to use for the request.

  • order_id – the ID of the order to fetch.

get_complex_order_history(session: Session, per_page: int = 50, page_offset: int | None = None) list[tastytrade.order.PlacedComplexOrder]

Get order history of the account.

Parameters:
  • session – the session to use for the request.

  • per_page – the number of results to return per page.

  • page_offset – provide a specific page to get; if not provided, get all pages

get_effective_margin_requirements(session: Session, symbol: str) MarginRequirement

Get the effective margin requirements for a given symbol.

Parameters:
  • session – the session to use for the request, can’t be certification

  • symbol – the symbol to get margin requirements for.

get_history(session: Session, per_page: int = 250, page_offset: int | None = None, sort: str = 'Desc', type: str | None = None, types: list[str] | None = None, sub_types: list[str] | None = None, start_date: date | None = None, end_date: date | None = None, instrument_type: InstrumentType | None = None, symbol: str | None = None, underlying_symbol: str | None = None, action: str | None = None, partition_key: str | None = None, futures_symbol: str | None = None, start_at: datetime | None = None, end_at: datetime | None = None) list[tastytrade.account.Transaction]

Get transaction history of the account.

Parameters:
  • session – the session to use for the request.

  • per_page – the number of results to return per page.

  • page_offset – provide a specific page to get; if not provided, get all pages

  • sort – the order to sort results in, either ‘Desc’ or ‘Asc’.

  • type – the type of transaction.

  • types – a list of transaction types to filter by.

  • sub_types – an array of transaction subtypes to filter by.

  • start_date – the start date of transactions to query.

  • end_date – the end date of transactions to query.

  • instrument_type – the type of instrument.

  • symbol – a single symbol.

  • underlying_symbol – the underlying symbol.

  • action – the action of the transaction: ‘Sell to Open’, ‘Sell to Close’, ‘Buy to Open’, ‘Buy to Close’, ‘Sell’ or ‘Buy’.

  • partition_key – account partition key.

  • futures_symbol – the full TW Future Symbol, e.g. /ESZ9, /NGZ19.

  • start_at – datetime start range for filtering transactions in full date-time.

  • end_at – datetime end range for filtering transactions in full date-time.

get_live_complex_orders(session: Session) list[tastytrade.order.PlacedComplexOrder]

Get complex orders placed today for the account.

Parameters:

session – the session to use for the request.

get_live_orders(session: Session) list[tastytrade.order.PlacedOrder]

Get orders placed today for the account.

Parameters:

session – the session to use for the request.

get_margin_requirements(session: Session) MarginReport

Get the margin report for the account, with total margin requirements as well as a breakdown per symbol/instrument.

Parameters:

session – the session to use for the request.

get_net_liquidating_value_history(session: Session, time_back: str | None = None, start_time: datetime | None = None) list[tastytrade.account.NetLiqOhlc]

Returns a list of account net liquidating value snapshots over the specified time period.

Parameters:
  • session – the session to use for the request, can’t be certification.

  • time_back – the time period to get net liquidating value snapshots for. This param is required if start_time is not given. Possible values are: ‘1d’, ‘1m’, ‘3m’, ‘6m’, ‘1y’, ‘all’.

  • start_time – the start point for the query. This param is required is time-back is not given. If given, will take precedence over time-back.

get_order(session: Session, order_id: int) PlacedOrder

Gets an order with the given ID.

Parameters:
  • session – the session to use for the request.

  • order_id – the ID of the order to fetch.

get_order_chains(session: Session, symbol: str, start_time: datetime, end_time: datetime) list[tastytrade.order.OrderChain]

Get a list of order chains (open + rolls + close) for given symbol over the given time frame, with total P/L, commissions, etc.

Parameters:
  • session – the session to use for the request.

  • symbol – the underlying symbol for the chains.

  • start_time – the beginning time of the query.

  • end_time – the ending time of the query.

get_order_history(session: Session, per_page: int = 50, page_offset: int | None = None, start_date: date | None = None, end_date: date | None = None, underlying_symbol: str | None = None, statuses: list[tastytrade.order.OrderStatus] | None = None, futures_symbol: str | None = None, underlying_instrument_type: InstrumentType | None = None, sort: str | None = None, start_at: datetime | None = None, end_at: datetime | None = None) list[tastytrade.order.PlacedOrder]

Get order history of the account.

Parameters:
  • session – the session to use for the request.

  • per_page – the number of results to return per page.

  • page_offset – provide a specific page to get; if not provided, get all pages

  • start_date – the start date of orders to query.

  • end_date – the end date of orders to query.

  • underlying_symbol – underlying symbol to filter by.

  • statuses – a list of statuses to filter by.

  • futures_symbol – Tastytrade future symbol for futures and future options.

  • underlying_instrument_type – the type of instrument to filter by

  • sort – the order to sort results in, either ‘Desc’ or ‘Asc’.

  • start_at – datetime start range for filtering transactions in full date-time.

  • end_at – datetime end range for filtering transactions in full date-time.

get_position_limit(session: Session) PositionLimit

Get the maximum order size information for the account.

Parameters:

session – the session to use for the request.

get_positions(session: Session, underlying_symbols: list[str] | None = None, symbol: str | None = None, instrument_type: InstrumentType | None = None, include_closed: bool | None = None, underlying_product_code: str | None = None, partition_keys: list[str] | None = None, net_positions: bool | None = None, include_marks: bool | None = None) list[tastytrade.account.CurrentPosition]

Get the current positions of the account.

Parameters:
  • session – the session to use for the request.

  • underlying_symbols – an array of underlying symbols for positions.

  • symbol – a single symbol.

  • instrument_type – the type of instrument.

  • include_closed – if closed positions should be included in the query.

  • underlying_product_code – the underlying future’s product code.

  • partition_keys – account partition keys.

  • net_positions – returns net positions grouped by instrument type and symbol.

  • include_marks – include current quote mark (note: can decrease performance).

get_total_fees(session: Session, day: date | None = None) FeesInfo

Get the total fees for a given date.

Parameters:
  • session – the session to use for the request.

  • day – the date to get fees for.

get_trading_status(session: Session) TradingStatus

Get the trading status of the account.

Parameters:

session – the session to use for the request.

get_transaction(session: Session, id: int) Transaction

Get a single transaction by ID.

Parameters:
  • session – the session to use for the request.

  • id – the ID of the transaction to fetch.

place_complex_order(session: Session, order: NewComplexOrder, dry_run: bool = True) PlacedComplexOrderResponse

Place the given order.

Parameters:
  • session – the session to use for the request.

  • order – the order to place.

  • dry_run – whether this is a test order or not.

place_order(session: Session, order: NewOrder, dry_run: bool = True) PlacedOrderResponse

Place the given order.

Parameters:
  • session – the session to use for the request.

  • order – the order to place.

  • dry_run – whether this is a test order or not.

replace_order(session: Session, old_order_id: int, new_order: NewOrder) PlacedOrder

Replace an order with a new order with different characteristics (but same legs).

Parameters:
  • session – the session to use for the request.

  • old_order_id – the ID of the order to replace.

  • new_order – the new order to replace the old order with.

pydantic model tastytrade.account.AccountBalance(*, account_number: str, cash_balance: Decimal, long_equity_value: Decimal, short_equity_value: Decimal, long_derivative_value: Decimal, short_derivative_value: Decimal, long_futures_value: Decimal, short_futures_value: Decimal, long_futures_derivative_value: Decimal, short_futures_derivative_value: Decimal, long_margineable_value: Decimal, short_margineable_value: Decimal, margin_equity: Decimal, equity_buying_power: Decimal, derivative_buying_power: Decimal, day_trading_buying_power: Decimal, futures_margin_requirement: Decimal, available_trading_funds: Decimal, maintenance_requirement: Decimal, maintenance_call_value: Decimal, reg_t_call_value: Decimal, day_trading_call_value: Decimal, day_equity_call_value: Decimal, net_liquidating_value: Decimal, cash_available_to_withdraw: Decimal, day_trade_excess: Decimal, pending_cash: Decimal, long_cryptocurrency_value: Decimal, short_cryptocurrency_value: Decimal, cryptocurrency_margin_requirement: Decimal, unsettled_cryptocurrency_fiat_amount: Decimal, closed_loop_available_balance: Decimal, equity_offering_margin_requirement: Decimal, long_bond_value: Decimal, bond_margin_requirement: Decimal, snapshot_date: date, reg_t_margin_requirement: Decimal, futures_overnight_margin_requirement: Decimal, futures_intraday_margin_requirement: Decimal, maintenance_excess: Decimal, pending_margin_interest: Decimal, effective_cryptocurrency_buying_power: Decimal, updated_at: datetime, apex_starting_day_margin_equity: Decimal | None = None, buying_power_adjustment: Decimal | None = None, time_of_day: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing account balance information.

Show JSON schema
{
   "title": "AccountBalance",
   "description": "Dataclass containing account balance information.",
   "type": "object",
   "properties": {
      "account-number": {
         "title": "Account-Number",
         "type": "string"
      },
      "cash-balance": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Cash-Balance"
      },
      "long-equity-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Long-Equity-Value"
      },
      "short-equity-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Short-Equity-Value"
      },
      "long-derivative-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Long-Derivative-Value"
      },
      "short-derivative-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Short-Derivative-Value"
      },
      "long-futures-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Long-Futures-Value"
      },
      "short-futures-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Short-Futures-Value"
      },
      "long-futures-derivative-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Long-Futures-Derivative-Value"
      },
      "short-futures-derivative-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Short-Futures-Derivative-Value"
      },
      "long-margineable-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Long-Margineable-Value"
      },
      "short-margineable-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Short-Margineable-Value"
      },
      "margin-equity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Margin-Equity"
      },
      "equity-buying-power": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Equity-Buying-Power"
      },
      "derivative-buying-power": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Derivative-Buying-Power"
      },
      "day-trading-buying-power": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Day-Trading-Buying-Power"
      },
      "futures-margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Futures-Margin-Requirement"
      },
      "available-trading-funds": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Available-Trading-Funds"
      },
      "maintenance-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Maintenance-Requirement"
      },
      "maintenance-call-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Maintenance-Call-Value"
      },
      "reg-t-call-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Reg-T-Call-Value"
      },
      "day-trading-call-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Day-Trading-Call-Value"
      },
      "day-equity-call-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Day-Equity-Call-Value"
      },
      "net-liquidating-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Net-Liquidating-Value"
      },
      "cash-available-to-withdraw": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Cash-Available-To-Withdraw"
      },
      "day-trade-excess": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Day-Trade-Excess"
      },
      "pending-cash": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Pending-Cash"
      },
      "long-cryptocurrency-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Long-Cryptocurrency-Value"
      },
      "short-cryptocurrency-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Short-Cryptocurrency-Value"
      },
      "cryptocurrency-margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Cryptocurrency-Margin-Requirement"
      },
      "unsettled-cryptocurrency-fiat-amount": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Unsettled-Cryptocurrency-Fiat-Amount"
      },
      "closed-loop-available-balance": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Closed-Loop-Available-Balance"
      },
      "equity-offering-margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Equity-Offering-Margin-Requirement"
      },
      "long-bond-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Long-Bond-Value"
      },
      "bond-margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Bond-Margin-Requirement"
      },
      "snapshot-date": {
         "format": "date",
         "title": "Snapshot-Date",
         "type": "string"
      },
      "reg-t-margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Reg-T-Margin-Requirement"
      },
      "futures-overnight-margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Futures-Overnight-Margin-Requirement"
      },
      "futures-intraday-margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Futures-Intraday-Margin-Requirement"
      },
      "maintenance-excess": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Maintenance-Excess"
      },
      "pending-margin-interest": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Pending-Margin-Interest"
      },
      "effective-cryptocurrency-buying-power": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Effective-Cryptocurrency-Buying-Power"
      },
      "updated-at": {
         "format": "date-time",
         "title": "Updated-At",
         "type": "string"
      },
      "apex-starting-day-margin-equity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Apex-Starting-Day-Margin-Equity"
      },
      "buying-power-adjustment": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Buying-Power-Adjustment"
      },
      "time-of-day": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Time-Of-Day"
      }
   },
   "required": [
      "account-number",
      "cash-balance",
      "long-equity-value",
      "short-equity-value",
      "long-derivative-value",
      "short-derivative-value",
      "long-futures-value",
      "short-futures-value",
      "long-futures-derivative-value",
      "short-futures-derivative-value",
      "long-margineable-value",
      "short-margineable-value",
      "margin-equity",
      "equity-buying-power",
      "derivative-buying-power",
      "day-trading-buying-power",
      "futures-margin-requirement",
      "available-trading-funds",
      "maintenance-requirement",
      "maintenance-call-value",
      "reg-t-call-value",
      "day-trading-call-value",
      "day-equity-call-value",
      "net-liquidating-value",
      "cash-available-to-withdraw",
      "day-trade-excess",
      "pending-cash",
      "long-cryptocurrency-value",
      "short-cryptocurrency-value",
      "cryptocurrency-margin-requirement",
      "unsettled-cryptocurrency-fiat-amount",
      "closed-loop-available-balance",
      "equity-offering-margin-requirement",
      "long-bond-value",
      "bond-margin-requirement",
      "snapshot-date",
      "reg-t-margin-requirement",
      "futures-overnight-margin-requirement",
      "futures-intraday-margin-requirement",
      "maintenance-excess",
      "pending-margin-interest",
      "effective-cryptocurrency-buying-power",
      "updated-at"
   ]
}

Fields:
  • account_number (str)

  • apex_starting_day_margin_equity (decimal.Decimal | None)

  • available_trading_funds (decimal.Decimal)

  • bond_margin_requirement (decimal.Decimal)

  • buying_power_adjustment (decimal.Decimal | None)

  • cash_available_to_withdraw (decimal.Decimal)

  • cash_balance (decimal.Decimal)

  • closed_loop_available_balance (decimal.Decimal)

  • cryptocurrency_margin_requirement (decimal.Decimal)

  • day_equity_call_value (decimal.Decimal)

  • day_trade_excess (decimal.Decimal)

  • day_trading_buying_power (decimal.Decimal)

  • day_trading_call_value (decimal.Decimal)

  • derivative_buying_power (decimal.Decimal)

  • effective_cryptocurrency_buying_power (decimal.Decimal)

  • equity_buying_power (decimal.Decimal)

  • equity_offering_margin_requirement (decimal.Decimal)

  • futures_intraday_margin_requirement (decimal.Decimal)

  • futures_margin_requirement (decimal.Decimal)

  • futures_overnight_margin_requirement (decimal.Decimal)

  • long_bond_value (decimal.Decimal)

  • long_cryptocurrency_value (decimal.Decimal)

  • long_derivative_value (decimal.Decimal)

  • long_equity_value (decimal.Decimal)

  • long_futures_derivative_value (decimal.Decimal)

  • long_futures_value (decimal.Decimal)

  • long_margineable_value (decimal.Decimal)

  • maintenance_call_value (decimal.Decimal)

  • maintenance_excess (decimal.Decimal)

  • maintenance_requirement (decimal.Decimal)

  • margin_equity (decimal.Decimal)

  • net_liquidating_value (decimal.Decimal)

  • pending_cash (decimal.Decimal)

  • pending_margin_interest (decimal.Decimal)

  • reg_t_call_value (decimal.Decimal)

  • reg_t_margin_requirement (decimal.Decimal)

  • short_cryptocurrency_value (decimal.Decimal)

  • short_derivative_value (decimal.Decimal)

  • short_equity_value (decimal.Decimal)

  • short_futures_derivative_value (decimal.Decimal)

  • short_futures_value (decimal.Decimal)

  • short_margineable_value (decimal.Decimal)

  • snapshot_date (datetime.date)

  • time_of_day (str | None)

  • unsettled_cryptocurrency_fiat_amount (decimal.Decimal)

  • updated_at (datetime.datetime)

Validators:
  • validate_price_effects » all fields

pydantic model tastytrade.account.AccountBalanceSnapshot(*, account_number: str, cash_balance: Decimal, long_equity_value: Decimal, short_equity_value: Decimal, long_derivative_value: Decimal, short_derivative_value: Decimal, long_futures_value: Decimal, short_futures_value: Decimal, long_futures_derivative_value: Decimal, short_futures_derivative_value: Decimal, long_margineable_value: Decimal, short_margineable_value: Decimal, margin_equity: Decimal, equity_buying_power: Decimal, derivative_buying_power: Decimal, day_trading_buying_power: Decimal, futures_margin_requirement: Decimal, available_trading_funds: Decimal, maintenance_requirement: Decimal, maintenance_call_value: Decimal, reg_t_call_value: Decimal, day_trading_call_value: Decimal, day_equity_call_value: Decimal, net_liquidating_value: Decimal, cash_available_to_withdraw: Decimal, day_trade_excess: Decimal, pending_cash: Decimal, snapshot_date: date, time_of_day: str | None = None, long_cryptocurrency_value: Decimal | None = None, short_cryptocurrency_value: Decimal | None = None, cryptocurrency_margin_requirement: Decimal | None = None, unsettled_cryptocurrency_fiat_amount: Decimal | None = None, closed_loop_available_balance: Decimal | None = None, equity_offering_margin_requirement: Decimal | None = None, long_bond_value: Decimal | None = None, bond_margin_requirement: Decimal | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing account balance for a moment in time (snapshot).

Show JSON schema
{
   "title": "AccountBalanceSnapshot",
   "description": "Dataclass containing account balance for a moment in time (snapshot).",
   "type": "object",
   "properties": {
      "account-number": {
         "title": "Account-Number",
         "type": "string"
      },
      "cash-balance": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Cash-Balance"
      },
      "long-equity-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Long-Equity-Value"
      },
      "short-equity-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Short-Equity-Value"
      },
      "long-derivative-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Long-Derivative-Value"
      },
      "short-derivative-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Short-Derivative-Value"
      },
      "long-futures-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Long-Futures-Value"
      },
      "short-futures-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Short-Futures-Value"
      },
      "long-futures-derivative-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Long-Futures-Derivative-Value"
      },
      "short-futures-derivative-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Short-Futures-Derivative-Value"
      },
      "long-margineable-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Long-Margineable-Value"
      },
      "short-margineable-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Short-Margineable-Value"
      },
      "margin-equity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Margin-Equity"
      },
      "equity-buying-power": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Equity-Buying-Power"
      },
      "derivative-buying-power": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Derivative-Buying-Power"
      },
      "day-trading-buying-power": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Day-Trading-Buying-Power"
      },
      "futures-margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Futures-Margin-Requirement"
      },
      "available-trading-funds": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Available-Trading-Funds"
      },
      "maintenance-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Maintenance-Requirement"
      },
      "maintenance-call-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Maintenance-Call-Value"
      },
      "reg-t-call-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Reg-T-Call-Value"
      },
      "day-trading-call-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Day-Trading-Call-Value"
      },
      "day-equity-call-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Day-Equity-Call-Value"
      },
      "net-liquidating-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Net-Liquidating-Value"
      },
      "cash-available-to-withdraw": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Cash-Available-To-Withdraw"
      },
      "day-trade-excess": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Day-Trade-Excess"
      },
      "pending-cash": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Pending-Cash"
      },
      "snapshot-date": {
         "format": "date",
         "title": "Snapshot-Date",
         "type": "string"
      },
      "time-of-day": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Time-Of-Day"
      },
      "long-cryptocurrency-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Long-Cryptocurrency-Value"
      },
      "short-cryptocurrency-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Short-Cryptocurrency-Value"
      },
      "cryptocurrency-margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Cryptocurrency-Margin-Requirement"
      },
      "unsettled-cryptocurrency-fiat-amount": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Unsettled-Cryptocurrency-Fiat-Amount"
      },
      "closed-loop-available-balance": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Closed-Loop-Available-Balance"
      },
      "equity-offering-margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Equity-Offering-Margin-Requirement"
      },
      "long-bond-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Long-Bond-Value"
      },
      "bond-margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Bond-Margin-Requirement"
      }
   },
   "required": [
      "account-number",
      "cash-balance",
      "long-equity-value",
      "short-equity-value",
      "long-derivative-value",
      "short-derivative-value",
      "long-futures-value",
      "short-futures-value",
      "long-futures-derivative-value",
      "short-futures-derivative-value",
      "long-margineable-value",
      "short-margineable-value",
      "margin-equity",
      "equity-buying-power",
      "derivative-buying-power",
      "day-trading-buying-power",
      "futures-margin-requirement",
      "available-trading-funds",
      "maintenance-requirement",
      "maintenance-call-value",
      "reg-t-call-value",
      "day-trading-call-value",
      "day-equity-call-value",
      "net-liquidating-value",
      "cash-available-to-withdraw",
      "day-trade-excess",
      "pending-cash",
      "snapshot-date"
   ]
}

Fields:
  • account_number (str)

  • available_trading_funds (decimal.Decimal)

  • bond_margin_requirement (decimal.Decimal | None)

  • cash_available_to_withdraw (decimal.Decimal)

  • cash_balance (decimal.Decimal)

  • closed_loop_available_balance (decimal.Decimal | None)

  • cryptocurrency_margin_requirement (decimal.Decimal | None)

  • day_equity_call_value (decimal.Decimal)

  • day_trade_excess (decimal.Decimal)

  • day_trading_buying_power (decimal.Decimal)

  • day_trading_call_value (decimal.Decimal)

  • derivative_buying_power (decimal.Decimal)

  • equity_buying_power (decimal.Decimal)

  • equity_offering_margin_requirement (decimal.Decimal | None)

  • futures_margin_requirement (decimal.Decimal)

  • long_bond_value (decimal.Decimal | None)

  • long_cryptocurrency_value (decimal.Decimal | None)

  • long_derivative_value (decimal.Decimal)

  • long_equity_value (decimal.Decimal)

  • long_futures_derivative_value (decimal.Decimal)

  • long_futures_value (decimal.Decimal)

  • long_margineable_value (decimal.Decimal)

  • maintenance_call_value (decimal.Decimal)

  • maintenance_requirement (decimal.Decimal)

  • margin_equity (decimal.Decimal)

  • net_liquidating_value (decimal.Decimal)

  • pending_cash (decimal.Decimal)

  • reg_t_call_value (decimal.Decimal)

  • short_cryptocurrency_value (decimal.Decimal | None)

  • short_derivative_value (decimal.Decimal)

  • short_equity_value (decimal.Decimal)

  • short_futures_derivative_value (decimal.Decimal)

  • short_futures_value (decimal.Decimal)

  • short_margineable_value (decimal.Decimal)

  • snapshot_date (datetime.date)

  • time_of_day (str | None)

  • unsettled_cryptocurrency_fiat_amount (decimal.Decimal | None)

Validators:
  • validate_price_effects » all fields

pydantic model tastytrade.account.CurrentPosition(*, account_number: str, symbol: str, instrument_type: InstrumentType, underlying_symbol: str, quantity: Decimal, quantity_direction: str, close_price: Decimal, average_open_price: Decimal, multiplier: int, cost_effect: str, is_suppressed: bool, is_frozen: bool, realized_day_gain: Decimal, realized_today: Decimal, created_at: datetime, updated_at: datetime, mark: Decimal | None = None, mark_price: Decimal | None = None, restricted_quantity: Decimal | None = None, expires_at: datetime | None = None, fixing_price: Decimal | None = None, deliverable_type: str | None = None, average_yearly_market_close_price: Decimal | None = None, average_daily_market_close_price: Decimal | None = None, realized_day_gain_date: date | None = None, realized_today_date: date | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing imformation about an individual position in a portfolio.

Show JSON schema
{
   "title": "CurrentPosition",
   "description": "Dataclass containing imformation about an individual position in a\nportfolio.",
   "type": "object",
   "properties": {
      "account-number": {
         "title": "Account-Number",
         "type": "string"
      },
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "underlying-symbol": {
         "title": "Underlying-Symbol",
         "type": "string"
      },
      "quantity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Quantity"
      },
      "quantity-direction": {
         "title": "Quantity-Direction",
         "type": "string"
      },
      "close-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Close-Price"
      },
      "average-open-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Average-Open-Price"
      },
      "multiplier": {
         "title": "Multiplier",
         "type": "integer"
      },
      "cost-effect": {
         "title": "Cost-Effect",
         "type": "string"
      },
      "is-suppressed": {
         "title": "Is-Suppressed",
         "type": "boolean"
      },
      "is-frozen": {
         "title": "Is-Frozen",
         "type": "boolean"
      },
      "realized-day-gain": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Realized-Day-Gain"
      },
      "realized-today": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Realized-Today"
      },
      "created-at": {
         "format": "date-time",
         "title": "Created-At",
         "type": "string"
      },
      "updated-at": {
         "format": "date-time",
         "title": "Updated-At",
         "type": "string"
      },
      "mark": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Mark"
      },
      "mark-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Mark-Price"
      },
      "restricted-quantity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Restricted-Quantity"
      },
      "expires-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Expires-At"
      },
      "fixing-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Fixing-Price"
      },
      "deliverable-type": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Deliverable-Type"
      },
      "average-yearly-market-close-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Average-Yearly-Market-Close-Price"
      },
      "average-daily-market-close-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Average-Daily-Market-Close-Price"
      },
      "realized-day-gain-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Realized-Day-Gain-Date"
      },
      "realized-today-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Realized-Today-Date"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      }
   },
   "required": [
      "account-number",
      "symbol",
      "instrument-type",
      "underlying-symbol",
      "quantity",
      "quantity-direction",
      "close-price",
      "average-open-price",
      "multiplier",
      "cost-effect",
      "is-suppressed",
      "is-frozen",
      "realized-day-gain",
      "realized-today",
      "created-at",
      "updated-at"
   ]
}

Fields:
  • account_number (str)

  • average_daily_market_close_price (decimal.Decimal | None)

  • average_open_price (decimal.Decimal)

  • average_yearly_market_close_price (decimal.Decimal | None)

  • close_price (decimal.Decimal)

  • cost_effect (str)

  • created_at (datetime.datetime)

  • deliverable_type (str | None)

  • expires_at (datetime.datetime | None)

  • fixing_price (decimal.Decimal | None)

  • instrument_type (tastytrade.order.InstrumentType)

  • is_frozen (bool)

  • is_suppressed (bool)

  • mark (decimal.Decimal | None)

  • mark_price (decimal.Decimal | None)

  • multiplier (int)

  • quantity (decimal.Decimal)

  • quantity_direction (str)

  • realized_day_gain (decimal.Decimal)

  • realized_day_gain_date (datetime.date | None)

  • realized_today (decimal.Decimal)

  • realized_today_date (datetime.date | None)

  • restricted_quantity (decimal.Decimal | None)

  • symbol (str)

  • underlying_symbol (str)

  • updated_at (datetime.datetime)

Validators:
  • validate_price_effects » all fields

pydantic model tastytrade.account.EmptyDict

Bases: BaseModel

Show JSON schema
{
   "title": "EmptyDict",
   "type": "object",
   "properties": {},
   "additionalProperties": false
}

pydantic model tastytrade.account.FeesInfo(*, total_fees: Decimal)

Bases: TastytradeJsonDataclass

Show JSON schema
{
   "title": "FeesInfo",
   "type": "object",
   "properties": {
      "total-fees": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Total-Fees"
      }
   },
   "required": [
      "total-fees"
   ]
}

Fields:
  • total_fees (decimal.Decimal)

Validators:
  • validate_price_effects » all fields

pydantic model tastytrade.account.Lot(*, id: str, transaction_id: int, quantity: Decimal, price: Decimal, quantity_direction: str, executed_at: datetime, transaction_date: date)

Bases: TastytradeJsonDataclass

Dataclass containing information about the lot of a position.

Show JSON schema
{
   "title": "Lot",
   "description": "Dataclass containing information about the lot of a position.",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "string"
      },
      "transaction-id": {
         "title": "Transaction-Id",
         "type": "integer"
      },
      "quantity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Quantity"
      },
      "price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Price"
      },
      "quantity-direction": {
         "title": "Quantity-Direction",
         "type": "string"
      },
      "executed-at": {
         "format": "date-time",
         "title": "Executed-At",
         "type": "string"
      },
      "transaction-date": {
         "format": "date",
         "title": "Transaction-Date",
         "type": "string"
      }
   },
   "required": [
      "id",
      "transaction-id",
      "quantity",
      "price",
      "quantity-direction",
      "executed-at",
      "transaction-date"
   ]
}

Fields:
  • executed_at (datetime.datetime)

  • id (str)

  • price (decimal.Decimal)

  • quantity (decimal.Decimal)

  • quantity_direction (str)

  • transaction_date (datetime.date)

  • transaction_id (int)

pydantic model tastytrade.account.MarginReport(*, account_number: str, description: str, margin_calculation_type: str, option_level: str, margin_requirement: Decimal, maintenance_requirement: Decimal, margin_equity: Decimal, option_buying_power: Decimal, reg_t_margin_requirement: Decimal, reg_t_option_buying_power: Decimal, maintenance_excess: Decimal, last_state_timestamp: int, groups: list[Union[tastytrade.account.MarginReportEntry, tastytrade.account.EmptyDict]], initial_requirement: Decimal | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing an overall portfolio margin report.

Show JSON schema
{
   "title": "MarginReport",
   "description": "Dataclass containing an overall portfolio margin report.",
   "type": "object",
   "properties": {
      "account-number": {
         "title": "Account-Number",
         "type": "string"
      },
      "description": {
         "title": "Description",
         "type": "string"
      },
      "margin-calculation-type": {
         "title": "Margin-Calculation-Type",
         "type": "string"
      },
      "option-level": {
         "title": "Option-Level",
         "type": "string"
      },
      "margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Margin-Requirement"
      },
      "maintenance-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Maintenance-Requirement"
      },
      "margin-equity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Margin-Equity"
      },
      "option-buying-power": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Option-Buying-Power"
      },
      "reg-t-margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Reg-T-Margin-Requirement"
      },
      "reg-t-option-buying-power": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Reg-T-Option-Buying-Power"
      },
      "maintenance-excess": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Maintenance-Excess"
      },
      "last-state-timestamp": {
         "title": "Last-State-Timestamp",
         "type": "integer"
      },
      "groups": {
         "items": {
            "anyOf": [
               {
                  "$ref": "#/$defs/MarginReportEntry"
               },
               {
                  "$ref": "#/$defs/EmptyDict"
               }
            ]
         },
         "title": "Groups",
         "type": "array"
      },
      "initial-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Initial-Requirement"
      }
   },
   "$defs": {
      "EmptyDict": {
         "additionalProperties": false,
         "properties": {},
         "title": "EmptyDict",
         "type": "object"
      },
      "MarginReportEntry": {
         "description": "Dataclass containing an individual entry (relating to a specific position)\nas part of the overall margin report.",
         "properties": {
            "description": {
               "title": "Description",
               "type": "string"
            },
            "code": {
               "title": "Code",
               "type": "string"
            },
            "buying-power": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Buying-Power"
            },
            "margin-calculation-type": {
               "title": "Margin-Calculation-Type",
               "type": "string"
            },
            "margin-requirement": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Margin-Requirement"
            },
            "expected-price-range-up-percent": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Expected-Price-Range-Up-Percent"
            },
            "expected-price-range-down-percent": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Expected-Price-Range-Down-Percent"
            },
            "groups": {
               "anyOf": [
                  {
                     "items": {
                        "type": "object"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Groups"
            },
            "initial-requirement": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Initial-Requirement"
            },
            "maintenance-requirement": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Maintenance-Requirement"
            },
            "point-of-no-return-percent": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Point-Of-No-Return-Percent"
            },
            "price-increase-percent": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Price-Increase-Percent"
            },
            "price-decrease-percent": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Price-Decrease-Percent"
            },
            "underlying-symbol": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Underlying-Symbol"
            },
            "underlying-type": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Underlying-Type"
            }
         },
         "required": [
            "description",
            "code",
            "buying-power",
            "margin-calculation-type",
            "margin-requirement"
         ],
         "title": "MarginReportEntry",
         "type": "object"
      }
   },
   "required": [
      "account-number",
      "description",
      "margin-calculation-type",
      "option-level",
      "margin-requirement",
      "maintenance-requirement",
      "margin-equity",
      "option-buying-power",
      "reg-t-margin-requirement",
      "reg-t-option-buying-power",
      "maintenance-excess",
      "last-state-timestamp",
      "groups"
   ]
}

Fields:
  • account_number (str)

  • description (str)

  • groups (list[typing.Union[tastytrade.account.MarginReportEntry, tastytrade.account.EmptyDict]])

  • initial_requirement (decimal.Decimal | None)

  • last_state_timestamp (int)

  • maintenance_excess (decimal.Decimal)

  • maintenance_requirement (decimal.Decimal)

  • margin_calculation_type (str)

  • margin_equity (decimal.Decimal)

  • margin_requirement (decimal.Decimal)

  • option_buying_power (decimal.Decimal)

  • option_level (str)

  • reg_t_margin_requirement (decimal.Decimal)

  • reg_t_option_buying_power (decimal.Decimal)

Validators:
  • validate_price_effects » all fields

pydantic model tastytrade.account.MarginReportEntry(*, description: str, code: str, buying_power: Decimal, margin_calculation_type: str, margin_requirement: Decimal, expected_price_range_up_percent: Decimal | None = None, expected_price_range_down_percent: Decimal | None = None, groups: list[dict[str, Any]] | None = None, initial_requirement: Decimal | None = None, maintenance_requirement: Decimal | None = None, point_of_no_return_percent: Decimal | None = None, price_increase_percent: Decimal | None = None, price_decrease_percent: Decimal | None = None, underlying_symbol: str | None = None, underlying_type: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing an individual entry (relating to a specific position) as part of the overall margin report.

Show JSON schema
{
   "title": "MarginReportEntry",
   "description": "Dataclass containing an individual entry (relating to a specific position)\nas part of the overall margin report.",
   "type": "object",
   "properties": {
      "description": {
         "title": "Description",
         "type": "string"
      },
      "code": {
         "title": "Code",
         "type": "string"
      },
      "buying-power": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Buying-Power"
      },
      "margin-calculation-type": {
         "title": "Margin-Calculation-Type",
         "type": "string"
      },
      "margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Margin-Requirement"
      },
      "expected-price-range-up-percent": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Expected-Price-Range-Up-Percent"
      },
      "expected-price-range-down-percent": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Expected-Price-Range-Down-Percent"
      },
      "groups": {
         "anyOf": [
            {
               "items": {
                  "type": "object"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Groups"
      },
      "initial-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Initial-Requirement"
      },
      "maintenance-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Maintenance-Requirement"
      },
      "point-of-no-return-percent": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Point-Of-No-Return-Percent"
      },
      "price-increase-percent": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Price-Increase-Percent"
      },
      "price-decrease-percent": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Price-Decrease-Percent"
      },
      "underlying-symbol": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Underlying-Symbol"
      },
      "underlying-type": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Underlying-Type"
      }
   },
   "required": [
      "description",
      "code",
      "buying-power",
      "margin-calculation-type",
      "margin-requirement"
   ]
}

Fields:
  • buying_power (decimal.Decimal)

  • code (str)

  • description (str)

  • expected_price_range_down_percent (decimal.Decimal | None)

  • expected_price_range_up_percent (decimal.Decimal | None)

  • groups (list[dict[str, typing.Any]] | None)

  • initial_requirement (decimal.Decimal | None)

  • maintenance_requirement (decimal.Decimal | None)

  • margin_calculation_type (str)

  • margin_requirement (decimal.Decimal)

  • point_of_no_return_percent (decimal.Decimal | None)

  • price_decrease_percent (decimal.Decimal | None)

  • price_increase_percent (decimal.Decimal | None)

  • underlying_symbol (str | None)

  • underlying_type (str | None)

Validators:
  • validate_price_effects » all fields

pydantic model tastytrade.account.MarginRequirement(*, underlying_symbol: str, long_equity_initial: Decimal, short_equity_initial: Decimal, long_equity_maintenance: Decimal, short_equity_maintenance: Decimal, naked_option_standard: Decimal, naked_option_minimum: Decimal, naked_option_floor: Decimal, clearing_identifier: str | None = None, is_deleted: bool | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing general margin requirement information for a symbol.

Show JSON schema
{
   "title": "MarginRequirement",
   "description": "Dataclass containing general margin requirement information for a symbol.",
   "type": "object",
   "properties": {
      "underlying-symbol": {
         "title": "Underlying-Symbol",
         "type": "string"
      },
      "long-equity-initial": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Long-Equity-Initial"
      },
      "short-equity-initial": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Short-Equity-Initial"
      },
      "long-equity-maintenance": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Long-Equity-Maintenance"
      },
      "short-equity-maintenance": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Short-Equity-Maintenance"
      },
      "naked-option-standard": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Naked-Option-Standard"
      },
      "naked-option-minimum": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Naked-Option-Minimum"
      },
      "naked-option-floor": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Naked-Option-Floor"
      },
      "clearing-identifier": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Clearing-Identifier"
      },
      "is-deleted": {
         "anyOf": [
            {
               "type": "boolean"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Is-Deleted"
      }
   },
   "required": [
      "underlying-symbol",
      "long-equity-initial",
      "short-equity-initial",
      "long-equity-maintenance",
      "short-equity-maintenance",
      "naked-option-standard",
      "naked-option-minimum",
      "naked-option-floor"
   ]
}

Fields:
  • clearing_identifier (str | None)

  • is_deleted (bool | None)

  • long_equity_initial (decimal.Decimal)

  • long_equity_maintenance (decimal.Decimal)

  • naked_option_floor (decimal.Decimal)

  • naked_option_minimum (decimal.Decimal)

  • naked_option_standard (decimal.Decimal)

  • short_equity_initial (decimal.Decimal)

  • short_equity_maintenance (decimal.Decimal)

  • underlying_symbol (str)

pydantic model tastytrade.account.NetLiqOhlc(*, open: Decimal, high: Decimal, low: Decimal, close: Decimal, pending_cash_open: Decimal, pending_cash_high: Decimal, pending_cash_low: Decimal, pending_cash_close: Decimal, total_open: Decimal, total_high: Decimal, total_low: Decimal, total_close: Decimal, time: str)

Bases: TastytradeJsonDataclass

Dataclass containing historical net liquidation data in OHLC format (open, high, low, close), with a timestamp.

Show JSON schema
{
   "title": "NetLiqOhlc",
   "description": "Dataclass containing historical net liquidation data in OHLC format\n(open, high, low, close), with a timestamp.",
   "type": "object",
   "properties": {
      "open": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Open"
      },
      "high": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "High"
      },
      "low": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Low"
      },
      "close": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Close"
      },
      "pending-cash-open": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Pending-Cash-Open"
      },
      "pending-cash-high": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Pending-Cash-High"
      },
      "pending-cash-low": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Pending-Cash-Low"
      },
      "pending-cash-close": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Pending-Cash-Close"
      },
      "total-open": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Total-Open"
      },
      "total-high": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Total-High"
      },
      "total-low": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Total-Low"
      },
      "total-close": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Total-Close"
      },
      "time": {
         "title": "Time",
         "type": "string"
      }
   },
   "required": [
      "open",
      "high",
      "low",
      "close",
      "pending-cash-open",
      "pending-cash-high",
      "pending-cash-low",
      "pending-cash-close",
      "total-open",
      "total-high",
      "total-low",
      "total-close",
      "time"
   ]
}

Fields:
  • close (decimal.Decimal)

  • high (decimal.Decimal)

  • low (decimal.Decimal)

  • open (decimal.Decimal)

  • pending_cash_close (decimal.Decimal)

  • pending_cash_high (decimal.Decimal)

  • pending_cash_low (decimal.Decimal)

  • pending_cash_open (decimal.Decimal)

  • time (str)

  • total_close (decimal.Decimal)

  • total_high (decimal.Decimal)

  • total_low (decimal.Decimal)

  • total_open (decimal.Decimal)

pydantic model tastytrade.account.PositionLimit(*, account_number: str, equity_order_size: int, equity_option_order_size: int, future_order_size: int, future_option_order_size: int, underlying_opening_order_limit: int, equity_position_size: int, equity_option_position_size: int, future_position_size: int, future_option_position_size: int)

Bases: TastytradeJsonDataclass

Dataclass containing information about general account limits.

Show JSON schema
{
   "title": "PositionLimit",
   "description": "Dataclass containing information about general account limits.",
   "type": "object",
   "properties": {
      "account-number": {
         "title": "Account-Number",
         "type": "string"
      },
      "equity-order-size": {
         "title": "Equity-Order-Size",
         "type": "integer"
      },
      "equity-option-order-size": {
         "title": "Equity-Option-Order-Size",
         "type": "integer"
      },
      "future-order-size": {
         "title": "Future-Order-Size",
         "type": "integer"
      },
      "future-option-order-size": {
         "title": "Future-Option-Order-Size",
         "type": "integer"
      },
      "underlying-opening-order-limit": {
         "title": "Underlying-Opening-Order-Limit",
         "type": "integer"
      },
      "equity-position-size": {
         "title": "Equity-Position-Size",
         "type": "integer"
      },
      "equity-option-position-size": {
         "title": "Equity-Option-Position-Size",
         "type": "integer"
      },
      "future-position-size": {
         "title": "Future-Position-Size",
         "type": "integer"
      },
      "future-option-position-size": {
         "title": "Future-Option-Position-Size",
         "type": "integer"
      }
   },
   "required": [
      "account-number",
      "equity-order-size",
      "equity-option-order-size",
      "future-order-size",
      "future-option-order-size",
      "underlying-opening-order-limit",
      "equity-position-size",
      "equity-option-position-size",
      "future-position-size",
      "future-option-position-size"
   ]
}

Fields:
  • account_number (str)

  • equity_option_order_size (int)

  • equity_option_position_size (int)

  • equity_order_size (int)

  • equity_position_size (int)

  • future_option_order_size (int)

  • future_option_position_size (int)

  • future_order_size (int)

  • future_position_size (int)

  • underlying_opening_order_limit (int)

pydantic model tastytrade.account.TradingStatus(*, account_number: str, equities_margin_calculation_type: str, fee_schedule_name: str, futures_margin_rate_multiplier: Decimal, has_intraday_equities_margin: bool, id: int, is_aggregated_at_clearing: bool, is_closed: bool, is_closing_only: bool, is_cryptocurrency_enabled: bool, is_frozen: bool, is_full_equity_margin_required: bool, is_futures_closing_only: bool, is_futures_intra_day_enabled: bool, is_futures_enabled: bool, is_in_day_trade_equity_maintenance_call: bool, is_in_margin_call: bool, is_pattern_day_trader: bool, is_small_notional_futures_intra_day_enabled: bool, is_roll_the_day_forward_enabled: bool, are_far_otm_net_options_restricted: bool, options_level: str, short_calls_enabled: bool, small_notional_futures_margin_rate_multiplier: Decimal, is_equity_offering_enabled: bool, is_equity_offering_closing_only: bool, updated_at: datetime, is_portfolio_margin_enabled: bool | None = None, is_risk_reducing_only: bool | None = None, day_trade_count: int | None = None, autotrade_account_type: str | None = None, clearing_account_number: str | None = None, clearing_aggregation_identifier: str | None = None, is_cryptocurrency_closing_only: bool | None = None, pdt_reset_on: date | None = None, cmta_override: int | None = None, enhanced_fraud_safeguards_enabled_at: datetime | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing information about an account’s trading status, such as what types of trades are allowed (e.g. margin, crypto, futures)

Show JSON schema
{
   "title": "TradingStatus",
   "description": "Dataclass containing information about an account's trading status, such\nas what types of trades are allowed (e.g. margin, crypto, futures)",
   "type": "object",
   "properties": {
      "account-number": {
         "title": "Account-Number",
         "type": "string"
      },
      "equities-margin-calculation-type": {
         "title": "Equities-Margin-Calculation-Type",
         "type": "string"
      },
      "fee-schedule-name": {
         "title": "Fee-Schedule-Name",
         "type": "string"
      },
      "futures-margin-rate-multiplier": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Futures-Margin-Rate-Multiplier"
      },
      "has-intraday-equities-margin": {
         "title": "Has-Intraday-Equities-Margin",
         "type": "boolean"
      },
      "id": {
         "title": "Id",
         "type": "integer"
      },
      "is-aggregated-at-clearing": {
         "title": "Is-Aggregated-At-Clearing",
         "type": "boolean"
      },
      "is-closed": {
         "title": "Is-Closed",
         "type": "boolean"
      },
      "is-closing-only": {
         "title": "Is-Closing-Only",
         "type": "boolean"
      },
      "is-cryptocurrency-enabled": {
         "title": "Is-Cryptocurrency-Enabled",
         "type": "boolean"
      },
      "is-frozen": {
         "title": "Is-Frozen",
         "type": "boolean"
      },
      "is-full-equity-margin-required": {
         "title": "Is-Full-Equity-Margin-Required",
         "type": "boolean"
      },
      "is-futures-closing-only": {
         "title": "Is-Futures-Closing-Only",
         "type": "boolean"
      },
      "is-futures-intra-day-enabled": {
         "title": "Is-Futures-Intra-Day-Enabled",
         "type": "boolean"
      },
      "is-futures-enabled": {
         "title": "Is-Futures-Enabled",
         "type": "boolean"
      },
      "is-in-day-trade-equity-maintenance-call": {
         "title": "Is-In-Day-Trade-Equity-Maintenance-Call",
         "type": "boolean"
      },
      "is-in-margin-call": {
         "title": "Is-In-Margin-Call",
         "type": "boolean"
      },
      "is-pattern-day-trader": {
         "title": "Is-Pattern-Day-Trader",
         "type": "boolean"
      },
      "is-small-notional-futures-intra-day-enabled": {
         "title": "Is-Small-Notional-Futures-Intra-Day-Enabled",
         "type": "boolean"
      },
      "is-roll-the-day-forward-enabled": {
         "title": "Is-Roll-The-Day-Forward-Enabled",
         "type": "boolean"
      },
      "are-far-otm-net-options-restricted": {
         "title": "Are-Far-Otm-Net-Options-Restricted",
         "type": "boolean"
      },
      "options-level": {
         "title": "Options-Level",
         "type": "string"
      },
      "short-calls-enabled": {
         "title": "Short-Calls-Enabled",
         "type": "boolean"
      },
      "small-notional-futures-margin-rate-multiplier": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Small-Notional-Futures-Margin-Rate-Multiplier"
      },
      "is-equity-offering-enabled": {
         "title": "Is-Equity-Offering-Enabled",
         "type": "boolean"
      },
      "is-equity-offering-closing-only": {
         "title": "Is-Equity-Offering-Closing-Only",
         "type": "boolean"
      },
      "updated-at": {
         "format": "date-time",
         "title": "Updated-At",
         "type": "string"
      },
      "is-portfolio-margin-enabled": {
         "anyOf": [
            {
               "type": "boolean"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Is-Portfolio-Margin-Enabled"
      },
      "is-risk-reducing-only": {
         "anyOf": [
            {
               "type": "boolean"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Is-Risk-Reducing-Only"
      },
      "day-trade-count": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Day-Trade-Count"
      },
      "autotrade-account-type": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Autotrade-Account-Type"
      },
      "clearing-account-number": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Clearing-Account-Number"
      },
      "clearing-aggregation-identifier": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Clearing-Aggregation-Identifier"
      },
      "is-cryptocurrency-closing-only": {
         "anyOf": [
            {
               "type": "boolean"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Is-Cryptocurrency-Closing-Only"
      },
      "pdt-reset-on": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Pdt-Reset-On"
      },
      "cmta-override": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Cmta-Override"
      },
      "enhanced-fraud-safeguards-enabled-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Enhanced-Fraud-Safeguards-Enabled-At"
      }
   },
   "required": [
      "account-number",
      "equities-margin-calculation-type",
      "fee-schedule-name",
      "futures-margin-rate-multiplier",
      "has-intraday-equities-margin",
      "id",
      "is-aggregated-at-clearing",
      "is-closed",
      "is-closing-only",
      "is-cryptocurrency-enabled",
      "is-frozen",
      "is-full-equity-margin-required",
      "is-futures-closing-only",
      "is-futures-intra-day-enabled",
      "is-futures-enabled",
      "is-in-day-trade-equity-maintenance-call",
      "is-in-margin-call",
      "is-pattern-day-trader",
      "is-small-notional-futures-intra-day-enabled",
      "is-roll-the-day-forward-enabled",
      "are-far-otm-net-options-restricted",
      "options-level",
      "short-calls-enabled",
      "small-notional-futures-margin-rate-multiplier",
      "is-equity-offering-enabled",
      "is-equity-offering-closing-only",
      "updated-at"
   ]
}

Fields:
  • account_number (str)

  • are_far_otm_net_options_restricted (bool)

  • autotrade_account_type (str | None)

  • clearing_account_number (str | None)

  • clearing_aggregation_identifier (str | None)

  • cmta_override (int | None)

  • day_trade_count (int | None)

  • enhanced_fraud_safeguards_enabled_at (datetime.datetime | None)

  • equities_margin_calculation_type (str)

  • fee_schedule_name (str)

  • futures_margin_rate_multiplier (decimal.Decimal)

  • has_intraday_equities_margin (bool)

  • id (int)

  • is_aggregated_at_clearing (bool)

  • is_closed (bool)

  • is_closing_only (bool)

  • is_cryptocurrency_closing_only (bool | None)

  • is_cryptocurrency_enabled (bool)

  • is_equity_offering_closing_only (bool)

  • is_equity_offering_enabled (bool)

  • is_frozen (bool)

  • is_full_equity_margin_required (bool)

  • is_futures_closing_only (bool)

  • is_futures_enabled (bool)

  • is_futures_intra_day_enabled (bool)

  • is_in_day_trade_equity_maintenance_call (bool)

  • is_in_margin_call (bool)

  • is_pattern_day_trader (bool)

  • is_portfolio_margin_enabled (bool | None)

  • is_risk_reducing_only (bool | None)

  • is_roll_the_day_forward_enabled (bool)

  • is_small_notional_futures_intra_day_enabled (bool)

  • options_level (str)

  • pdt_reset_on (datetime.date | None)

  • short_calls_enabled (bool)

  • small_notional_futures_margin_rate_multiplier (decimal.Decimal)

  • updated_at (datetime.datetime)

pydantic model tastytrade.account.Transaction(*, id: int, account_number: str, transaction_type: str, transaction_sub_type: str, description: str, executed_at: datetime, transaction_date: date, value: Decimal, net_value: Decimal, is_estimated_fee: bool, symbol: str | None = None, instrument_type: InstrumentType | None = None, underlying_symbol: str | None = None, action: OrderAction | None = None, quantity: Decimal | None = None, price: Decimal | None = None, regulatory_fees: Decimal | None = None, clearing_fees: Decimal | None = None, commission: Decimal | None = None, proprietary_index_option_fees: Decimal | None = None, ext_exchange_order_number: str | None = None, ext_global_order_number: int | None = None, ext_group_id: str | None = None, ext_group_fill_id: str | None = None, ext_exec_id: str | None = None, exec_id: str | None = None, exchange: str | None = None, order_id: int | None = None, exchange_affiliation_identifier: str | None = None, leg_count: int | None = None, destination_venue: str | None = None, other_charge: Decimal | None = None, other_charge_description: str | None = None, reverses_id: int | None = None, cost_basis_reconciliation_date: date | None = None, lots: list[tastytrade.account.Lot] | None = None, agency_price: Decimal | None = None, principal_price: Decimal | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing information about a past transaction.

Show JSON schema
{
   "title": "Transaction",
   "description": "Dataclass containing information about a past transaction.",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "integer"
      },
      "account-number": {
         "title": "Account-Number",
         "type": "string"
      },
      "transaction-type": {
         "title": "Transaction-Type",
         "type": "string"
      },
      "transaction-sub-type": {
         "title": "Transaction-Sub-Type",
         "type": "string"
      },
      "description": {
         "title": "Description",
         "type": "string"
      },
      "executed-at": {
         "format": "date-time",
         "title": "Executed-At",
         "type": "string"
      },
      "transaction-date": {
         "format": "date",
         "title": "Transaction-Date",
         "type": "string"
      },
      "value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Value"
      },
      "net-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Net-Value"
      },
      "is-estimated-fee": {
         "title": "Is-Estimated-Fee",
         "type": "boolean"
      },
      "symbol": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Symbol"
      },
      "instrument-type": {
         "anyOf": [
            {
               "$ref": "#/$defs/InstrumentType"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "underlying-symbol": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Underlying-Symbol"
      },
      "action": {
         "anyOf": [
            {
               "$ref": "#/$defs/OrderAction"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "quantity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Quantity"
      },
      "price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Price"
      },
      "regulatory-fees": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Regulatory-Fees"
      },
      "clearing-fees": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Clearing-Fees"
      },
      "commission": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Commission"
      },
      "proprietary-index-option-fees": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Proprietary-Index-Option-Fees"
      },
      "ext-exchange-order-number": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Ext-Exchange-Order-Number"
      },
      "ext-global-order-number": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Ext-Global-Order-Number"
      },
      "ext-group-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Ext-Group-Id"
      },
      "ext-group-fill-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Ext-Group-Fill-Id"
      },
      "ext-exec-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Ext-Exec-Id"
      },
      "exec-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Exec-Id"
      },
      "exchange": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Exchange"
      },
      "order-id": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Order-Id"
      },
      "exchange-affiliation-identifier": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Exchange-Affiliation-Identifier"
      },
      "leg-count": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Leg-Count"
      },
      "destination-venue": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Destination-Venue"
      },
      "other-charge": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Other-Charge"
      },
      "other-charge-description": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Other-Charge-Description"
      },
      "reverses-id": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Reverses-Id"
      },
      "cost-basis-reconciliation-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Cost-Basis-Reconciliation-Date"
      },
      "lots": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/Lot"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Lots"
      },
      "agency-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Agency-Price"
      },
      "principal-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Principal-Price"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "Lot": {
         "description": "Dataclass containing information about the lot of a position.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "transaction-id": {
               "title": "Transaction-Id",
               "type": "integer"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Price"
            },
            "quantity-direction": {
               "title": "Quantity-Direction",
               "type": "string"
            },
            "executed-at": {
               "format": "date-time",
               "title": "Executed-At",
               "type": "string"
            },
            "transaction-date": {
               "format": "date",
               "title": "Transaction-Date",
               "type": "string"
            }
         },
         "required": [
            "id",
            "transaction-id",
            "quantity",
            "price",
            "quantity-direction",
            "executed-at",
            "transaction-date"
         ],
         "title": "Lot",
         "type": "object"
      },
      "OrderAction": {
         "description": "This is an :class:`~enum.Enum` that contains the valid order actions.",
         "enum": [
            "Buy to Open",
            "Buy to Close",
            "Sell to Open",
            "Sell to Close",
            "Buy",
            "Sell"
         ],
         "title": "OrderAction",
         "type": "string"
      }
   },
   "required": [
      "id",
      "account-number",
      "transaction-type",
      "transaction-sub-type",
      "description",
      "executed-at",
      "transaction-date",
      "value",
      "net-value",
      "is-estimated-fee"
   ]
}

Fields:
  • account_number (str)

  • action (tastytrade.order.OrderAction | None)

  • agency_price (decimal.Decimal | None)

  • clearing_fees (decimal.Decimal | None)

  • commission (decimal.Decimal | None)

  • cost_basis_reconciliation_date (datetime.date | None)

  • description (str)

  • destination_venue (str | None)

  • exchange (str | None)

  • exchange_affiliation_identifier (str | None)

  • exec_id (str | None)

  • executed_at (datetime.datetime)

  • ext_exchange_order_number (str | None)

  • ext_exec_id (str | None)

  • ext_global_order_number (int | None)

  • ext_group_fill_id (str | None)

  • ext_group_id (str | None)

  • id (int)

  • instrument_type (tastytrade.order.InstrumentType | None)

  • is_estimated_fee (bool)

  • leg_count (int | None)

  • lots (list[tastytrade.account.Lot] | None)

  • net_value (decimal.Decimal)

  • order_id (int | None)

  • other_charge (decimal.Decimal | None)

  • other_charge_description (str | None)

  • price (decimal.Decimal | None)

  • principal_price (decimal.Decimal | None)

  • proprietary_index_option_fees (decimal.Decimal | None)

  • quantity (decimal.Decimal | None)

  • regulatory_fees (decimal.Decimal | None)

  • reverses_id (int | None)

  • symbol (str | None)

  • transaction_date (datetime.date)

  • transaction_sub_type (str)

  • transaction_type (str)

  • underlying_symbol (str | None)

  • value (decimal.Decimal)

Validators:
  • validate_price_effects » all fields

Backtesting

pydantic model tastytrade.backtest.Backtest(*, symbol: str, entryConditions: BacktestEntry, exitConditions: BacktestExit, legs: list[tastytrade.backtest.BacktestLeg], startDate: date, endDate: date = datetime.date(2024, 7, 31), status: str = 'pending')

Bases: BacktestJsonDataclass

Dataclass of configuration options for a backtest. Date must be <= 2024-07-31.

Show JSON schema
{
   "title": "Backtest",
   "description": "Dataclass of configuration options for a backtest.\nDate must be <= 2024-07-31.",
   "type": "object",
   "properties": {
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "entryConditions": {
         "$ref": "#/$defs/BacktestEntry"
      },
      "exitConditions": {
         "$ref": "#/$defs/BacktestExit"
      },
      "legs": {
         "items": {
            "$ref": "#/$defs/BacktestLeg"
         },
         "title": "Legs",
         "type": "array"
      },
      "startDate": {
         "format": "date",
         "title": "Startdate",
         "type": "string"
      },
      "endDate": {
         "default": "2024-07-31",
         "format": "date",
         "title": "Enddate",
         "type": "string"
      },
      "status": {
         "default": "pending",
         "title": "Status",
         "type": "string"
      }
   },
   "$defs": {
      "BacktestEntry": {
         "description": "Dataclass of parameters for backtest trade entry.",
         "properties": {
            "useExactDte": {
               "default": true,
               "title": "Useexactdte",
               "type": "boolean"
            },
            "maximumActiveTrials": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Maximumactivetrials"
            },
            "maximumActiveTrialsBehavior": {
               "anyOf": [
                  {
                     "enum": [
                        "close oldest",
                        "don't enter"
                     ],
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Maximumactivetrialsbehavior"
            },
            "frequency": {
               "default": "every day",
               "title": "Frequency",
               "type": "string"
            }
         },
         "title": "BacktestEntry",
         "type": "object"
      },
      "BacktestExit": {
         "description": "Dataclass of parameters for backtest trade exit.",
         "properties": {
            "afterDaysInTrade": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Afterdaysintrade"
            },
            "stopLossPercentage": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Stoplosspercentage"
            },
            "takeProfitPercentage": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Takeprofitpercentage"
            },
            "atDaysToExpiration": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Atdaystoexpiration"
            }
         },
         "title": "BacktestExit",
         "type": "object"
      },
      "BacktestLeg": {
         "description": "Dataclass of parameters for placing legs of backtest trades.\nLeg delta must be a multiple of 5.",
         "properties": {
            "daysUntilExpiration": {
               "default": 45,
               "title": "Daysuntilexpiration",
               "type": "integer"
            },
            "delta": {
               "default": 15,
               "title": "Delta",
               "type": "integer"
            },
            "direction": {
               "default": "sell",
               "enum": [
                  "buy",
                  "sell"
               ],
               "title": "Direction",
               "type": "string"
            },
            "quantity": {
               "default": 1,
               "title": "Quantity",
               "type": "integer"
            },
            "side": {
               "default": "call",
               "enum": [
                  "call",
                  "put"
               ],
               "title": "Side",
               "type": "string"
            }
         },
         "title": "BacktestLeg",
         "type": "object"
      }
   },
   "required": [
      "symbol",
      "entryConditions",
      "exitConditions",
      "legs",
      "startDate"
   ]
}

Fields:
  • end_date (datetime.date)

  • entry_conditions (tastytrade.backtest.BacktestEntry)

  • exit_conditions (tastytrade.backtest.BacktestExit)

  • legs (list[tastytrade.backtest.BacktestLeg])

  • start_date (datetime.date)

  • status (str)

  • symbol (str)

pydantic model tastytrade.backtest.BacktestEntry(*, useExactDte: bool = True, maximumActiveTrials: int | None = None, maximumActiveTrialsBehavior: Literal['close oldest', "don't enter"] | None = None, frequency: str = 'every day')

Bases: BacktestJsonDataclass

Dataclass of parameters for backtest trade entry.

Show JSON schema
{
   "title": "BacktestEntry",
   "description": "Dataclass of parameters for backtest trade entry.",
   "type": "object",
   "properties": {
      "useExactDte": {
         "default": true,
         "title": "Useexactdte",
         "type": "boolean"
      },
      "maximumActiveTrials": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Maximumactivetrials"
      },
      "maximumActiveTrialsBehavior": {
         "anyOf": [
            {
               "enum": [
                  "close oldest",
                  "don't enter"
               ],
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Maximumactivetrialsbehavior"
      },
      "frequency": {
         "default": "every day",
         "title": "Frequency",
         "type": "string"
      }
   }
}

Fields:
  • frequency (str)

  • maximum_active_trials (int | None)

  • maximum_active_trials_behavior (Literal['close oldest', "don't enter"] | None)

  • use_exact_DTE (bool)

pydantic model tastytrade.backtest.BacktestExit(*, afterDaysInTrade: int | None = None, stopLossPercentage: int | None = None, takeProfitPercentage: int | None = None, atDaysToExpiration: int | None = None)

Bases: BacktestJsonDataclass

Dataclass of parameters for backtest trade exit.

Show JSON schema
{
   "title": "BacktestExit",
   "description": "Dataclass of parameters for backtest trade exit.",
   "type": "object",
   "properties": {
      "afterDaysInTrade": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Afterdaysintrade"
      },
      "stopLossPercentage": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Stoplosspercentage"
      },
      "takeProfitPercentage": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Takeprofitpercentage"
      },
      "atDaysToExpiration": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Atdaystoexpiration"
      }
   }
}

Fields:
  • after_days_in_trade (int | None)

  • at_days_to_expiration (int | None)

  • stop_loss_percentage (int | None)

  • take_profit_percentage (int | None)

pydantic model tastytrade.backtest.BacktestJsonDataclass

Bases: BaseModel

Dataclass for converting backtest JSON naming conventions to snake case.

Show JSON schema
{
   "title": "BacktestJsonDataclass",
   "description": "Dataclass for converting backtest JSON naming conventions to snake case.",
   "type": "object",
   "properties": {}
}

pydantic model tastytrade.backtest.BacktestLeg(*, daysUntilExpiration: int = 45, delta: int = 15, direction: Literal['buy', 'sell'] = 'sell', quantity: int = 1, side: Literal['call', 'put'] = 'call')

Bases: BacktestJsonDataclass

Dataclass of parameters for placing legs of backtest trades. Leg delta must be a multiple of 5.

Show JSON schema
{
   "title": "BacktestLeg",
   "description": "Dataclass of parameters for placing legs of backtest trades.\nLeg delta must be a multiple of 5.",
   "type": "object",
   "properties": {
      "daysUntilExpiration": {
         "default": 45,
         "title": "Daysuntilexpiration",
         "type": "integer"
      },
      "delta": {
         "default": 15,
         "title": "Delta",
         "type": "integer"
      },
      "direction": {
         "default": "sell",
         "enum": [
            "buy",
            "sell"
         ],
         "title": "Direction",
         "type": "string"
      },
      "quantity": {
         "default": 1,
         "title": "Quantity",
         "type": "integer"
      },
      "side": {
         "default": "call",
         "enum": [
            "call",
            "put"
         ],
         "title": "Side",
         "type": "string"
      }
   }
}

Fields:
  • days_until_expiration (int)

  • delta (int)

  • direction (Literal['buy', 'sell'])

  • quantity (int)

  • side (Literal['call', 'put'])

pydantic model tastytrade.backtest.BacktestResponse(*, symbol: str, entryConditions: BacktestEntry, exitConditions: BacktestExit, legs: list[tastytrade.backtest.BacktestLeg], startDate: date, endDate: date = datetime.date(2024, 7, 31), status: str = 'pending', createdAt: datetime, id: str, results: BacktestResults, eta: int | None = None, progress: Decimal | None = None)

Bases: Backtest

Dataclass containing a backtest and associated information.

Show JSON schema
{
   "title": "BacktestResponse",
   "description": "Dataclass containing a backtest and associated information.",
   "type": "object",
   "properties": {
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "entryConditions": {
         "$ref": "#/$defs/BacktestEntry"
      },
      "exitConditions": {
         "$ref": "#/$defs/BacktestExit"
      },
      "legs": {
         "items": {
            "$ref": "#/$defs/BacktestLeg"
         },
         "title": "Legs",
         "type": "array"
      },
      "startDate": {
         "format": "date",
         "title": "Startdate",
         "type": "string"
      },
      "endDate": {
         "default": "2024-07-31",
         "format": "date",
         "title": "Enddate",
         "type": "string"
      },
      "status": {
         "default": "pending",
         "title": "Status",
         "type": "string"
      },
      "createdAt": {
         "format": "date-time",
         "title": "Createdat",
         "type": "string"
      },
      "id": {
         "title": "Id",
         "type": "string"
      },
      "results": {
         "$ref": "#/$defs/BacktestResults"
      },
      "eta": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Eta"
      },
      "progress": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Progress"
      }
   },
   "$defs": {
      "BacktestEntry": {
         "description": "Dataclass of parameters for backtest trade entry.",
         "properties": {
            "useExactDte": {
               "default": true,
               "title": "Useexactdte",
               "type": "boolean"
            },
            "maximumActiveTrials": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Maximumactivetrials"
            },
            "maximumActiveTrialsBehavior": {
               "anyOf": [
                  {
                     "enum": [
                        "close oldest",
                        "don't enter"
                     ],
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Maximumactivetrialsbehavior"
            },
            "frequency": {
               "default": "every day",
               "title": "Frequency",
               "type": "string"
            }
         },
         "title": "BacktestEntry",
         "type": "object"
      },
      "BacktestExit": {
         "description": "Dataclass of parameters for backtest trade exit.",
         "properties": {
            "afterDaysInTrade": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Afterdaysintrade"
            },
            "stopLossPercentage": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Stoplosspercentage"
            },
            "takeProfitPercentage": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Takeprofitpercentage"
            },
            "atDaysToExpiration": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Atdaystoexpiration"
            }
         },
         "title": "BacktestExit",
         "type": "object"
      },
      "BacktestLeg": {
         "description": "Dataclass of parameters for placing legs of backtest trades.\nLeg delta must be a multiple of 5.",
         "properties": {
            "daysUntilExpiration": {
               "default": 45,
               "title": "Daysuntilexpiration",
               "type": "integer"
            },
            "delta": {
               "default": 15,
               "title": "Delta",
               "type": "integer"
            },
            "direction": {
               "default": "sell",
               "enum": [
                  "buy",
                  "sell"
               ],
               "title": "Direction",
               "type": "string"
            },
            "quantity": {
               "default": 1,
               "title": "Quantity",
               "type": "integer"
            },
            "side": {
               "default": "call",
               "enum": [
                  "call",
                  "put"
               ],
               "title": "Side",
               "type": "string"
            }
         },
         "title": "BacktestLeg",
         "type": "object"
      },
      "BacktestResults": {
         "description": "Dataclass containing partial or finished results of a backtest.",
         "properties": {
            "snapshots": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/BacktestSnapshot"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "title": "Snapshots"
            },
            "statistics": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/BacktestStatistics"
                  },
                  {
                     "type": "null"
                  }
               ]
            },
            "trials": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/BacktestTrial"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "title": "Trials"
            }
         },
         "required": [
            "snapshots",
            "statistics",
            "trials"
         ],
         "title": "BacktestResults",
         "type": "object"
      },
      "BacktestSnapshot": {
         "description": "Dataclass containing a snapshot in time during the backtest.",
         "properties": {
            "dateTime": {
               "format": "date-time",
               "title": "Datetime",
               "type": "string"
            },
            "profitLoss": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Profitloss"
            },
            "normalizedUnderlyingPrice": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Normalizedunderlyingprice"
            },
            "underlyingPrice": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Underlyingprice"
            }
         },
         "required": [
            "dateTime",
            "profitLoss"
         ],
         "title": "BacktestSnapshot",
         "type": "object"
      },
      "BacktestStatistics": {
         "description": "Dataclass containing statistics on the overall performance of a backtest.",
         "properties": {
            "Avg. BPR per trade": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Avg. Bpr Per Trade"
            },
            "Avg. daily change in PNL": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Avg. Daily Change In Pnl"
            },
            "Avg. daily change in net liq": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Avg. Daily Change In Net Liq"
            },
            "Avg. days in trade": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Avg. Days In Trade"
            },
            "Avg. premium": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Avg. Premium"
            },
            "Avg. profit/loss per trade": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Avg. Profit/Loss Per Trade"
            },
            "Avg. return per trade": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Avg. Return Per Trade"
            },
            "Highest profit": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Highest Profit"
            },
            "Loss percentage": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Loss Percentage"
            },
            "Losses": {
               "title": "Losses",
               "type": "integer"
            },
            "Max drawdown": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Max Drawdown"
            },
            "Number of trades": {
               "title": "Number Of Trades",
               "type": "integer"
            },
            "Premium capture rate": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Premium Capture Rate"
            },
            "Return on used capital": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Return On Used Capital"
            },
            "Total fees": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Total Fees"
            },
            "Total premium": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Total Premium"
            },
            "Total profit/loss": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Total Profit/Loss"
            },
            "Used capital": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Used Capital"
            },
            "Win percentage": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Win Percentage"
            },
            "Wins": {
               "title": "Wins",
               "type": "integer"
            },
            "Worst loss": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Worst Loss"
            }
         },
         "required": [
            "Avg. BPR per trade",
            "Avg. daily change in PNL",
            "Avg. daily change in net liq",
            "Avg. days in trade",
            "Avg. premium",
            "Avg. profit/loss per trade",
            "Avg. return per trade",
            "Highest profit",
            "Loss percentage",
            "Losses",
            "Max drawdown",
            "Number of trades",
            "Premium capture rate",
            "Return on used capital",
            "Total fees",
            "Total premium",
            "Total profit/loss",
            "Used capital",
            "Win percentage",
            "Wins",
            "Worst loss"
         ],
         "title": "BacktestStatistics",
         "type": "object"
      },
      "BacktestTrial": {
         "description": "Dataclass containing information on trades placed during the backtest.",
         "properties": {
            "closeDateTime": {
               "format": "date-time",
               "title": "Closedatetime",
               "type": "string"
            },
            "openDateTime": {
               "format": "date-time",
               "title": "Opendatetime",
               "type": "string"
            },
            "profitLoss": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Profitloss"
            }
         },
         "required": [
            "closeDateTime",
            "openDateTime",
            "profitLoss"
         ],
         "title": "BacktestTrial",
         "type": "object"
      }
   },
   "required": [
      "symbol",
      "entryConditions",
      "exitConditions",
      "legs",
      "startDate",
      "createdAt",
      "id",
      "results"
   ]
}

Fields:
  • created_at (datetime.datetime)

  • eta (int | None)

  • id (str)

  • progress (decimal.Decimal | None)

  • results (tastytrade.backtest.BacktestResults)

pydantic model tastytrade.backtest.BacktestResults(*, snapshots: list[tastytrade.backtest.BacktestSnapshot] | None, statistics: BacktestStatistics | None, trials: list[tastytrade.backtest.BacktestTrial] | None)

Bases: BacktestJsonDataclass

Dataclass containing partial or finished results of a backtest.

Show JSON schema
{
   "title": "BacktestResults",
   "description": "Dataclass containing partial or finished results of a backtest.",
   "type": "object",
   "properties": {
      "snapshots": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/BacktestSnapshot"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "title": "Snapshots"
      },
      "statistics": {
         "anyOf": [
            {
               "$ref": "#/$defs/BacktestStatistics"
            },
            {
               "type": "null"
            }
         ]
      },
      "trials": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/BacktestTrial"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "title": "Trials"
      }
   },
   "$defs": {
      "BacktestSnapshot": {
         "description": "Dataclass containing a snapshot in time during the backtest.",
         "properties": {
            "dateTime": {
               "format": "date-time",
               "title": "Datetime",
               "type": "string"
            },
            "profitLoss": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Profitloss"
            },
            "normalizedUnderlyingPrice": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Normalizedunderlyingprice"
            },
            "underlyingPrice": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Underlyingprice"
            }
         },
         "required": [
            "dateTime",
            "profitLoss"
         ],
         "title": "BacktestSnapshot",
         "type": "object"
      },
      "BacktestStatistics": {
         "description": "Dataclass containing statistics on the overall performance of a backtest.",
         "properties": {
            "Avg. BPR per trade": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Avg. Bpr Per Trade"
            },
            "Avg. daily change in PNL": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Avg. Daily Change In Pnl"
            },
            "Avg. daily change in net liq": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Avg. Daily Change In Net Liq"
            },
            "Avg. days in trade": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Avg. Days In Trade"
            },
            "Avg. premium": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Avg. Premium"
            },
            "Avg. profit/loss per trade": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Avg. Profit/Loss Per Trade"
            },
            "Avg. return per trade": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Avg. Return Per Trade"
            },
            "Highest profit": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Highest Profit"
            },
            "Loss percentage": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Loss Percentage"
            },
            "Losses": {
               "title": "Losses",
               "type": "integer"
            },
            "Max drawdown": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Max Drawdown"
            },
            "Number of trades": {
               "title": "Number Of Trades",
               "type": "integer"
            },
            "Premium capture rate": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Premium Capture Rate"
            },
            "Return on used capital": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Return On Used Capital"
            },
            "Total fees": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Total Fees"
            },
            "Total premium": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Total Premium"
            },
            "Total profit/loss": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Total Profit/Loss"
            },
            "Used capital": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Used Capital"
            },
            "Win percentage": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Win Percentage"
            },
            "Wins": {
               "title": "Wins",
               "type": "integer"
            },
            "Worst loss": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Worst Loss"
            }
         },
         "required": [
            "Avg. BPR per trade",
            "Avg. daily change in PNL",
            "Avg. daily change in net liq",
            "Avg. days in trade",
            "Avg. premium",
            "Avg. profit/loss per trade",
            "Avg. return per trade",
            "Highest profit",
            "Loss percentage",
            "Losses",
            "Max drawdown",
            "Number of trades",
            "Premium capture rate",
            "Return on used capital",
            "Total fees",
            "Total premium",
            "Total profit/loss",
            "Used capital",
            "Win percentage",
            "Wins",
            "Worst loss"
         ],
         "title": "BacktestStatistics",
         "type": "object"
      },
      "BacktestTrial": {
         "description": "Dataclass containing information on trades placed during the backtest.",
         "properties": {
            "closeDateTime": {
               "format": "date-time",
               "title": "Closedatetime",
               "type": "string"
            },
            "openDateTime": {
               "format": "date-time",
               "title": "Opendatetime",
               "type": "string"
            },
            "profitLoss": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Profitloss"
            }
         },
         "required": [
            "closeDateTime",
            "openDateTime",
            "profitLoss"
         ],
         "title": "BacktestTrial",
         "type": "object"
      }
   },
   "required": [
      "snapshots",
      "statistics",
      "trials"
   ]
}

Fields:
  • snapshots (list[tastytrade.backtest.BacktestSnapshot] | None)

  • statistics (tastytrade.backtest.BacktestStatistics | None)

  • trials (list[tastytrade.backtest.BacktestTrial] | None)

class tastytrade.backtest.BacktestSession(session: Session)

Bases: object

Class for creating a backtesting session which can be reused for multiple backtests.

Example usage:

from tastytrade import BacktestSession, Backtest
from tqdm.asyncio import tqdm  # progress bar

backtest = Backtest(...)
backtest_session = BacktestSession(session)
results = [r async for r in tqdm(backtest_session.run(backtest))]
print(results[-1])
pydantic model tastytrade.backtest.BacktestSnapshot(*, dateTime: datetime, profitLoss: Decimal, normalizedUnderlyingPrice: Decimal | None = None, underlyingPrice: Decimal | None = None)

Bases: BacktestJsonDataclass

Dataclass containing a snapshot in time during the backtest.

Show JSON schema
{
   "title": "BacktestSnapshot",
   "description": "Dataclass containing a snapshot in time during the backtest.",
   "type": "object",
   "properties": {
      "dateTime": {
         "format": "date-time",
         "title": "Datetime",
         "type": "string"
      },
      "profitLoss": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Profitloss"
      },
      "normalizedUnderlyingPrice": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Normalizedunderlyingprice"
      },
      "underlyingPrice": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Underlyingprice"
      }
   },
   "required": [
      "dateTime",
      "profitLoss"
   ]
}

Fields:
  • date_time (datetime.datetime)

  • normalized_underlying_price (decimal.Decimal | None)

  • profit_loss (decimal.Decimal)

  • underlying_price (decimal.Decimal | None)

pydantic model tastytrade.backtest.BacktestStatistics(*, avg_bp_per_trade: Decimal, avg_daily_pnl_change: Decimal, avg_daily_net_liq_change: Decimal, avg_days_in_trade: Decimal, avg_premium: Decimal, avg_profit_loss_per_trade: Decimal, avg_return_per_trade: Decimal, highest_profit: Decimal, loss_percentage: Decimal, Losses: int, max_drawdown: Decimal, number_of_trades: int, premium_capture_rate: Decimal, return_on_used_capital: Decimal, total_fees: Decimal, total_premium: Decimal, total_profit_loss: Decimal, used_capital: Decimal, win_percentage: Decimal, Wins: int, worst_loss: Decimal)

Bases: BaseModel

Dataclass containing statistics on the overall performance of a backtest.

Show JSON schema
{
   "title": "BacktestStatistics",
   "description": "Dataclass containing statistics on the overall performance of a backtest.",
   "type": "object",
   "properties": {
      "Avg. BPR per trade": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Avg. Bpr Per Trade"
      },
      "Avg. daily change in PNL": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Avg. Daily Change In Pnl"
      },
      "Avg. daily change in net liq": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Avg. Daily Change In Net Liq"
      },
      "Avg. days in trade": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Avg. Days In Trade"
      },
      "Avg. premium": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Avg. Premium"
      },
      "Avg. profit/loss per trade": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Avg. Profit/Loss Per Trade"
      },
      "Avg. return per trade": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Avg. Return Per Trade"
      },
      "Highest profit": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Highest Profit"
      },
      "Loss percentage": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Loss Percentage"
      },
      "Losses": {
         "title": "Losses",
         "type": "integer"
      },
      "Max drawdown": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Max Drawdown"
      },
      "Number of trades": {
         "title": "Number Of Trades",
         "type": "integer"
      },
      "Premium capture rate": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Premium Capture Rate"
      },
      "Return on used capital": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Return On Used Capital"
      },
      "Total fees": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Total Fees"
      },
      "Total premium": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Total Premium"
      },
      "Total profit/loss": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Total Profit/Loss"
      },
      "Used capital": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Used Capital"
      },
      "Win percentage": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Win Percentage"
      },
      "Wins": {
         "title": "Wins",
         "type": "integer"
      },
      "Worst loss": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Worst Loss"
      }
   },
   "required": [
      "Avg. BPR per trade",
      "Avg. daily change in PNL",
      "Avg. daily change in net liq",
      "Avg. days in trade",
      "Avg. premium",
      "Avg. profit/loss per trade",
      "Avg. return per trade",
      "Highest profit",
      "Loss percentage",
      "Losses",
      "Max drawdown",
      "Number of trades",
      "Premium capture rate",
      "Return on used capital",
      "Total fees",
      "Total premium",
      "Total profit/loss",
      "Used capital",
      "Win percentage",
      "Wins",
      "Worst loss"
   ]
}

Fields:
  • avg_bp_per_trade (decimal.Decimal)

  • avg_daily_net_liq_change (decimal.Decimal)

  • avg_daily_pnl_change (decimal.Decimal)

  • avg_days_in_trade (decimal.Decimal)

  • avg_premium (decimal.Decimal)

  • avg_profit_loss_per_trade (decimal.Decimal)

  • avg_return_per_trade (decimal.Decimal)

  • highest_profit (decimal.Decimal)

  • loss_percentage (decimal.Decimal)

  • losses (int)

  • max_drawdown (decimal.Decimal)

  • number_of_trades (int)

  • premium_capture_rate (decimal.Decimal)

  • return_on_used_capital (decimal.Decimal)

  • total_fees (decimal.Decimal)

  • total_premium (decimal.Decimal)

  • total_profit_loss (decimal.Decimal)

  • used_capital (decimal.Decimal)

  • win_percentage (decimal.Decimal)

  • wins (int)

  • worst_loss (decimal.Decimal)

pydantic model tastytrade.backtest.BacktestTrial(*, closeDateTime: datetime, openDateTime: datetime, profitLoss: Decimal)

Bases: BacktestJsonDataclass

Dataclass containing information on trades placed during the backtest.

Show JSON schema
{
   "title": "BacktestTrial",
   "description": "Dataclass containing information on trades placed during the backtest.",
   "type": "object",
   "properties": {
      "closeDateTime": {
         "format": "date-time",
         "title": "Closedatetime",
         "type": "string"
      },
      "openDateTime": {
         "format": "date-time",
         "title": "Opendatetime",
         "type": "string"
      },
      "profitLoss": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Profitloss"
      }
   },
   "required": [
      "closeDateTime",
      "openDateTime",
      "profitLoss"
   ]
}

Fields:
  • close_date_time (datetime.datetime)

  • open_date_time (datetime.datetime)

  • profit_loss (decimal.Decimal)

Instruments

pydantic model tastytrade.instruments.Cryptocurrency(*, instrument_type: InstrumentType, symbol: str, id: int, short_description: str, description: str, is_closing_only: bool, active: bool, tick_size: Decimal, destination_venue_symbols: list[tastytrade.instruments.DestinationVenueSymbol], streamer_symbol: str | None = None)

Bases: TradeableTastytradeJsonDataclass

Dataclass that represents a Tastytrade cryptocurrency object. Contains information about the cryptocurrency and methods to populate that data using cryptocurrency symbol(s).

Show JSON schema
{
   "title": "Cryptocurrency",
   "description": "Dataclass that represents a Tastytrade cryptocurrency object. Contains\ninformation about the cryptocurrency and methods to populate that data\nusing cryptocurrency symbol(s).",
   "type": "object",
   "properties": {
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "id": {
         "title": "Id",
         "type": "integer"
      },
      "short-description": {
         "title": "Short-Description",
         "type": "string"
      },
      "description": {
         "title": "Description",
         "type": "string"
      },
      "is-closing-only": {
         "title": "Is-Closing-Only",
         "type": "boolean"
      },
      "active": {
         "title": "Active",
         "type": "boolean"
      },
      "tick-size": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Tick-Size"
      },
      "destination-venue-symbols": {
         "items": {
            "$ref": "#/$defs/DestinationVenueSymbol"
         },
         "title": "Destination-Venue-Symbols",
         "type": "array"
      },
      "streamer-symbol": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Streamer-Symbol"
      }
   },
   "$defs": {
      "DestinationVenueSymbol": {
         "description": "Dataclass representing a specific destination venue symbol for a\ncryptocurrency.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "integer"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "destination-venue": {
               "title": "Destination-Venue",
               "type": "string"
            },
            "routable": {
               "title": "Routable",
               "type": "boolean"
            },
            "max-quantity-precision": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Max-Quantity-Precision"
            },
            "max-price-precision": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Max-Price-Precision"
            }
         },
         "required": [
            "id",
            "symbol",
            "destination-venue",
            "routable"
         ],
         "title": "DestinationVenueSymbol",
         "type": "object"
      },
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      }
   },
   "required": [
      "instrument-type",
      "symbol",
      "id",
      "short-description",
      "description",
      "is-closing-only",
      "active",
      "tick-size",
      "destination-venue-symbols"
   ]
}

Fields:
  • active (bool)

  • description (str)

  • destination_venue_symbols (list[tastytrade.instruments.DestinationVenueSymbol])

  • id (int)

  • is_closing_only (bool)

  • short_description (str)

  • streamer_symbol (str | None)

  • tick_size (decimal.Decimal)

async classmethod a_get_cryptocurrencies(session: Session, symbols: list[str] = []) list[typing_extensions.Self]

Returns a list of cryptocurrency objects from the given symbols.

Parameters:
  • session – the session to use for the request.

  • symbols – the symbols to get the cryptocurrencies for.

async classmethod a_get_cryptocurrency(session: Session, symbol: str) Self

Returns a Cryptocurrency object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the cryptocurrency for.

classmethod get_cryptocurrencies(session: Session, symbols: list[str] = []) list[typing_extensions.Self]

Returns a list of cryptocurrency objects from the given symbols.

Parameters:
  • session – the session to use for the request.

  • symbols – the symbols to get the cryptocurrencies for.

classmethod get_cryptocurrency(session: Session, symbol: str) Self

Returns a Cryptocurrency object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the cryptocurrency for.

pydantic model tastytrade.instruments.Deliverable(*, id: int, root_symbol: str, deliverable_type: str, description: str, amount: Decimal, percent: str, symbol: str | None = None, instrument_type: InstrumentType | None = None)

Bases: TastytradeJsonDataclass

Dataclass representing the deliverable for an option.

Show JSON schema
{
   "title": "Deliverable",
   "description": "Dataclass representing the deliverable for an option.",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "integer"
      },
      "root-symbol": {
         "title": "Root-Symbol",
         "type": "string"
      },
      "deliverable-type": {
         "title": "Deliverable-Type",
         "type": "string"
      },
      "description": {
         "title": "Description",
         "type": "string"
      },
      "amount": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Amount"
      },
      "percent": {
         "title": "Percent",
         "type": "string"
      },
      "symbol": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Symbol"
      },
      "instrument-type": {
         "anyOf": [
            {
               "$ref": "#/$defs/InstrumentType"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      }
   },
   "required": [
      "id",
      "root-symbol",
      "deliverable-type",
      "description",
      "amount",
      "percent"
   ]
}

Fields:
  • amount (decimal.Decimal)

  • deliverable_type (str)

  • description (str)

  • id (int)

  • instrument_type (tastytrade.order.InstrumentType | None)

  • percent (str)

  • root_symbol (str)

  • symbol (str | None)

pydantic model tastytrade.instruments.DestinationVenueSymbol(*, id: int, symbol: str, destination_venue: str, routable: bool, max_quantity_precision: int | None = None, max_price_precision: int | None = None)

Bases: TastytradeJsonDataclass

Dataclass representing a specific destination venue symbol for a cryptocurrency.

Show JSON schema
{
   "title": "DestinationVenueSymbol",
   "description": "Dataclass representing a specific destination venue symbol for a\ncryptocurrency.",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "integer"
      },
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "destination-venue": {
         "title": "Destination-Venue",
         "type": "string"
      },
      "routable": {
         "title": "Routable",
         "type": "boolean"
      },
      "max-quantity-precision": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Max-Quantity-Precision"
      },
      "max-price-precision": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Max-Price-Precision"
      }
   },
   "required": [
      "id",
      "symbol",
      "destination-venue",
      "routable"
   ]
}

Fields:
  • destination_venue (str)

  • id (int)

  • max_price_precision (int | None)

  • max_quantity_precision (int | None)

  • routable (bool)

  • symbol (str)

pydantic model tastytrade.instruments.Equity(*, instrument_type: InstrumentType, symbol: str, id: int, is_index: bool, description: str, lendability: str, market_time_instrument_collection: str, is_closing_only: bool, is_options_closing_only: bool, active: bool, is_illiquid: bool, is_etf: bool, streamer_symbol: str, borrow_rate: Decimal | None = None, cusip: str | None = None, short_description: str | None = None, halted_at: datetime | None = None, stops_trading_at: datetime | None = None, is_fractional_quantity_eligible: bool | None = None, tick_sizes: list[tastytrade.instruments.TickSize] | None = None, listed_market: str | None = None, option_tick_sizes: list[tastytrade.instruments.TickSize] | None = None)

Bases: TradeableTastytradeJsonDataclass

Dataclass that represents a Tastytrade equity object. Contains information about the equity and methods to populate that data using equity symbol(s).

Show JSON schema
{
   "title": "Equity",
   "description": "Dataclass that represents a Tastytrade equity object. Contains information\nabout the equity and methods to populate that data using equity symbol(s).",
   "type": "object",
   "properties": {
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "id": {
         "title": "Id",
         "type": "integer"
      },
      "is-index": {
         "title": "Is-Index",
         "type": "boolean"
      },
      "description": {
         "title": "Description",
         "type": "string"
      },
      "lendability": {
         "title": "Lendability",
         "type": "string"
      },
      "market-time-instrument-collection": {
         "title": "Market-Time-Instrument-Collection",
         "type": "string"
      },
      "is-closing-only": {
         "title": "Is-Closing-Only",
         "type": "boolean"
      },
      "is-options-closing-only": {
         "title": "Is-Options-Closing-Only",
         "type": "boolean"
      },
      "active": {
         "title": "Active",
         "type": "boolean"
      },
      "is-illiquid": {
         "title": "Is-Illiquid",
         "type": "boolean"
      },
      "is-etf": {
         "title": "Is-Etf",
         "type": "boolean"
      },
      "streamer-symbol": {
         "title": "Streamer-Symbol",
         "type": "string"
      },
      "borrow-rate": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Borrow-Rate"
      },
      "cusip": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Cusip"
      },
      "short-description": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Short-Description"
      },
      "halted-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Halted-At"
      },
      "stops-trading-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Stops-Trading-At"
      },
      "is-fractional-quantity-eligible": {
         "anyOf": [
            {
               "type": "boolean"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Is-Fractional-Quantity-Eligible"
      },
      "tick-sizes": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/TickSize"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Tick-Sizes"
      },
      "listed-market": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Listed-Market"
      },
      "option-tick-sizes": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/TickSize"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Option-Tick-Sizes"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "TickSize": {
         "description": "Dataclass representing the tick size for an instrument.",
         "properties": {
            "value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Value"
            },
            "threshold": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Threshold"
            },
            "symbol": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Symbol"
            }
         },
         "required": [
            "value"
         ],
         "title": "TickSize",
         "type": "object"
      }
   },
   "required": [
      "instrument-type",
      "symbol",
      "id",
      "is-index",
      "description",
      "lendability",
      "market-time-instrument-collection",
      "is-closing-only",
      "is-options-closing-only",
      "active",
      "is-illiquid",
      "is-etf",
      "streamer-symbol"
   ]
}

Fields:
  • active (bool)

  • borrow_rate (decimal.Decimal | None)

  • cusip (str | None)

  • description (str)

  • halted_at (datetime.datetime | None)

  • id (int)

  • is_closing_only (bool)

  • is_etf (bool)

  • is_fractional_quantity_eligible (bool | None)

  • is_illiquid (bool)

  • is_index (bool)

  • is_options_closing_only (bool)

  • lendability (str)

  • listed_market (str | None)

  • market_time_instrument_collection (str)

  • option_tick_sizes (list[tastytrade.instruments.TickSize] | None)

  • short_description (str | None)

  • stops_trading_at (datetime.datetime | None)

  • streamer_symbol (str)

  • tick_sizes (list[tastytrade.instruments.TickSize] | None)

async classmethod a_get_active_equities(session: Session, per_page: int = 1000, page_offset: int | None = None, lendability: str | None = None) list[typing_extensions.Self]

Returns a list of actively traded Equity objects.

Parameters:
  • session – the session to use for the request.

  • per_page – the number of equities to get per page.

  • page_offset – provide a specific page to get; if not provided, get all pages

  • lendability – the lendability of the equities; e.g. ‘Easy To Borrow’, ‘Locate Required’, ‘Preborrow’

async classmethod a_get_equities(session: Session, symbols: list[str] | None = None, lendability: str | None = None, is_index: bool | None = None, is_etf: bool | None = None) list[typing_extensions.Self]

Returns a list of Equity objects from the given symbols.

Parameters:
  • session – the session to use for the request.

  • symbols – the symbols to get the equities for.

  • lendability – the lendability of the equities; e.g. ‘Easy To Borrow’, ‘Locate Required’, ‘Preborrow’

  • is_index – whether the equities are indexes.

  • is_etf – whether the equities are ETFs.

async classmethod a_get_equity(session: Session, symbol: str) Self

Returns a Equity object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the equity for.

classmethod get_active_equities(session: Session, per_page: int = 1000, page_offset: int | None = None, lendability: str | None = None) list[typing_extensions.Self]

Returns a list of actively traded Equity objects.

Parameters:
  • session – the session to use for the request.

  • per_page – the number of equities to get per page.

  • page_offset – provide a specific page to get; if not provided, get all pages

  • lendability – the lendability of the equities; e.g. ‘Easy To Borrow’, ‘Locate Required’, ‘Preborrow’

classmethod get_equities(session: Session, symbols: list[str] | None = None, lendability: str | None = None, is_index: bool | None = None, is_etf: bool | None = None) list[typing_extensions.Self]

Returns a list of Equity objects from the given symbols.

Parameters:
  • session – the session to use for the request.

  • symbols – the symbols to get the equities for.

  • lendability – the lendability of the equities; e.g. ‘Easy To Borrow’, ‘Locate Required’, ‘Preborrow’

  • is_index – whether the equities are indexes.

  • is_etf – whether the equities are ETFs.

classmethod get_equity(session: Session, symbol: str) Self

Returns a Equity object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the equity for.

pydantic model tastytrade.instruments.Future(*, instrument_type: InstrumentType, symbol: str)

Bases: TradeableTastytradeJsonDataclass

Dataclass that represents a Tastytrade future object. Contains information about the future and methods to fetch futures for symbol(s).

Show JSON schema
{
   "title": "Future",
   "description": "Dataclass that represents a Tastytrade future object. Contains information\nabout the future and methods to fetch futures for symbol(s).",
   "type": "object",
   "properties": {
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType",
         "default": "Future"
      },
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "product-code": {
         "title": "Product-Code",
         "type": "string"
      },
      "tick-size": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Tick-Size"
      },
      "notional-multiplier": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Notional-Multiplier"
      },
      "display-factor": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Display-Factor"
      },
      "last-trade-date": {
         "format": "date",
         "title": "Last-Trade-Date",
         "type": "string"
      },
      "expiration-date": {
         "format": "date",
         "title": "Expiration-Date",
         "type": "string"
      },
      "closing-only-date": {
         "format": "date",
         "title": "Closing-Only-Date",
         "type": "string"
      },
      "active": {
         "title": "Active",
         "type": "boolean"
      },
      "active-month": {
         "title": "Active-Month",
         "type": "boolean"
      },
      "next-active-month": {
         "title": "Next-Active-Month",
         "type": "boolean"
      },
      "is-closing-only": {
         "title": "Is-Closing-Only",
         "type": "boolean"
      },
      "stops-trading-at": {
         "format": "date-time",
         "title": "Stops-Trading-At",
         "type": "string"
      },
      "expires-at": {
         "format": "date-time",
         "title": "Expires-At",
         "type": "string"
      },
      "product-group": {
         "title": "Product-Group",
         "type": "string"
      },
      "exchange": {
         "title": "Exchange",
         "type": "string"
      },
      "streamer-exchange-code": {
         "title": "Streamer-Exchange-Code",
         "type": "string"
      },
      "back-month-first-calendar-symbol": {
         "title": "Back-Month-First-Calendar-Symbol",
         "type": "boolean"
      },
      "streamer-symbol": {
         "default": "",
         "title": "Streamer-Symbol",
         "type": "string"
      },
      "is-tradeable": {
         "anyOf": [
            {
               "type": "boolean"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Is-Tradeable"
      },
      "future-product": {
         "anyOf": [
            {
               "$ref": "#/$defs/FutureProduct"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "contract-size": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Contract-Size"
      },
      "main-fraction": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Main-Fraction"
      },
      "sub-fraction": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Sub-Fraction"
      },
      "first-notice-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "First-Notice-Date"
      },
      "roll-target-symbol": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Roll-Target-Symbol"
      },
      "true-underlying-symbol": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "True-Underlying-Symbol"
      },
      "future-etf-equivalent": {
         "anyOf": [
            {
               "$ref": "#/$defs/FutureEtfEquivalent"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "tick-sizes": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/TickSize"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Tick-Sizes"
      },
      "option-tick-sizes": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/TickSize"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Option-Tick-Sizes"
      },
      "spread-tick-sizes": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/TickSize"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Spread-Tick-Sizes"
      }
   },
   "$defs": {
      "FutureEtfEquivalent": {
         "description": "Dataclass that represents the ETF equivalent for a future (aka, the number\nof shares of the ETF that are equivalent to one future, leverage-wise).",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "share-quantity": {
               "title": "Share-Quantity",
               "type": "integer"
            }
         },
         "required": [
            "symbol",
            "share-quantity"
         ],
         "title": "FutureEtfEquivalent",
         "type": "object"
      },
      "FutureMonthCode": {
         "description": "This is an :class:`~enum.Enum` that contains the valid month codes for\nfutures.\n\nThis is really here for reference, as the API barely uses these codes.",
         "enum": [
            "F",
            "G",
            "H",
            "J",
            "K",
            "M",
            "N",
            "Q",
            "U",
            "V",
            "X",
            "Z"
         ],
         "title": "FutureMonthCode",
         "type": "string"
      },
      "FutureOptionProduct": {
         "description": "Dataclass that represents a Tastytrade future option product object.\nContains information about the future option product (deliverable for\nthe future option).",
         "properties": {
            "root-symbol": {
               "title": "Root-Symbol",
               "type": "string"
            },
            "cash-settled": {
               "title": "Cash-Settled",
               "type": "boolean"
            },
            "code": {
               "title": "Code",
               "type": "string"
            },
            "display-factor": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Display-Factor"
            },
            "exchange": {
               "title": "Exchange",
               "type": "string"
            },
            "product-type": {
               "title": "Product-Type",
               "type": "string"
            },
            "expiration-type": {
               "title": "Expiration-Type",
               "type": "string"
            },
            "settlement-delay-days": {
               "title": "Settlement-Delay-Days",
               "type": "integer"
            },
            "market-sector": {
               "title": "Market-Sector",
               "type": "string"
            },
            "clearing-code": {
               "title": "Clearing-Code",
               "type": "string"
            },
            "clearing-exchange-code": {
               "title": "Clearing-Exchange-Code",
               "type": "string"
            },
            "clearing-price-multiplier": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Clearing-Price-Multiplier"
            },
            "is-rollover": {
               "title": "Is-Rollover",
               "type": "boolean"
            },
            "future-product": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/FutureProduct"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            },
            "product-subtype": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Product-Subtype"
            },
            "legacy-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Legacy-Code"
            },
            "clearport-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Clearport-Code"
            }
         },
         "required": [
            "root-symbol",
            "cash-settled",
            "code",
            "display-factor",
            "exchange",
            "product-type",
            "expiration-type",
            "settlement-delay-days",
            "market-sector",
            "clearing-code",
            "clearing-exchange-code",
            "clearing-price-multiplier",
            "is-rollover"
         ],
         "title": "FutureOptionProduct",
         "type": "object"
      },
      "FutureProduct": {
         "description": "Dataclass that represents a Tastytrade future product object. Contains\ninformation about the future product and a method to fetch one for a\nsymbol.\n\nUseful for fetching general information about a family of futures, without\nknowing the specific expirations or symbols.",
         "properties": {
            "root-symbol": {
               "title": "Root-Symbol",
               "type": "string"
            },
            "code": {
               "title": "Code",
               "type": "string"
            },
            "description": {
               "title": "Description",
               "type": "string"
            },
            "exchange": {
               "title": "Exchange",
               "type": "string"
            },
            "product-type": {
               "title": "Product-Type",
               "type": "string"
            },
            "listed-months": {
               "items": {
                  "$ref": "#/$defs/FutureMonthCode"
               },
               "title": "Listed-Months",
               "type": "array"
            },
            "active-months": {
               "items": {
                  "$ref": "#/$defs/FutureMonthCode"
               },
               "title": "Active-Months",
               "type": "array"
            },
            "notional-multiplier": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Notional-Multiplier"
            },
            "tick-size": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Tick-Size"
            },
            "display-factor": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Display-Factor"
            },
            "streamer-exchange-code": {
               "title": "Streamer-Exchange-Code",
               "type": "string"
            },
            "small-notional": {
               "title": "Small-Notional",
               "type": "boolean"
            },
            "back-month-first-calendar-symbol": {
               "title": "Back-Month-First-Calendar-Symbol",
               "type": "boolean"
            },
            "first-notice": {
               "title": "First-Notice",
               "type": "boolean"
            },
            "cash-settled": {
               "title": "Cash-Settled",
               "type": "boolean"
            },
            "market-sector": {
               "title": "Market-Sector",
               "type": "string"
            },
            "clearing-code": {
               "title": "Clearing-Code",
               "type": "string"
            },
            "clearing-exchange-code": {
               "title": "Clearing-Exchange-Code",
               "type": "string"
            },
            "roll": {
               "$ref": "#/$defs/Roll"
            },
            "base-tick": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Base-Tick"
            },
            "sub-tick": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Sub-Tick"
            },
            "contract-limit": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Contract-Limit"
            },
            "product-subtype": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Product-Subtype"
            },
            "security-group": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Security-Group"
            },
            "true-underlying-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "True-Underlying-Code"
            },
            "clearport-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Clearport-Code"
            },
            "legacy-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Legacy-Code"
            },
            "legacy-exchange-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Legacy-Exchange-Code"
            },
            "option-products": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/FutureOptionProduct"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Option-Products"
            }
         },
         "required": [
            "root-symbol",
            "code",
            "description",
            "exchange",
            "product-type",
            "listed-months",
            "active-months",
            "notional-multiplier",
            "tick-size",
            "display-factor",
            "streamer-exchange-code",
            "small-notional",
            "back-month-first-calendar-symbol",
            "first-notice",
            "cash-settled",
            "market-sector",
            "clearing-code",
            "clearing-exchange-code",
            "roll"
         ],
         "title": "FutureProduct",
         "type": "object"
      },
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "Roll": {
         "description": "Dataclass representing a roll for a future.",
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "active-count": {
               "title": "Active-Count",
               "type": "integer"
            },
            "cash-settled": {
               "title": "Cash-Settled",
               "type": "boolean"
            },
            "business-days-offset": {
               "title": "Business-Days-Offset",
               "type": "integer"
            },
            "first-notice": {
               "title": "First-Notice",
               "type": "boolean"
            }
         },
         "required": [
            "name",
            "active-count",
            "cash-settled",
            "business-days-offset",
            "first-notice"
         ],
         "title": "Roll",
         "type": "object"
      },
      "TickSize": {
         "description": "Dataclass representing the tick size for an instrument.",
         "properties": {
            "value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Value"
            },
            "threshold": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Threshold"
            },
            "symbol": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Symbol"
            }
         },
         "required": [
            "value"
         ],
         "title": "TickSize",
         "type": "object"
      }
   },
   "required": [
      "symbol",
      "product-code",
      "tick-size",
      "notional-multiplier",
      "display-factor",
      "last-trade-date",
      "expiration-date",
      "closing-only-date",
      "active",
      "active-month",
      "next-active-month",
      "is-closing-only",
      "stops-trading-at",
      "expires-at",
      "product-group",
      "exchange",
      "streamer-exchange-code",
      "back-month-first-calendar-symbol"
   ]
}

Fields:
  • active (bool)

  • active_month (bool)

  • back_month_first_calendar_symbol (bool)

  • closing_only_date (datetime.date)

  • contract_size (decimal.Decimal | None)

  • display_factor (decimal.Decimal)

  • exchange (str)

  • expiration_date (datetime.date)

  • expires_at (datetime.datetime)

  • first_notice_date (datetime.date | None)

  • future_etf_equivalent (tastytrade.instruments.FutureEtfEquivalent | None)

  • future_product (tastytrade.instruments.FutureProduct | None)

  • instrument_type (tastytrade.order.InstrumentType)

  • is_closing_only (bool)

  • is_tradeable (bool | None)

  • last_trade_date (datetime.date)

  • main_fraction (decimal.Decimal | None)

  • next_active_month (bool)

  • notional_multiplier (decimal.Decimal)

  • option_tick_sizes (list[tastytrade.instruments.TickSize] | None)

  • product_code (str)

  • product_group (str)

  • roll_target_symbol (str | None)

  • spread_tick_sizes (list[tastytrade.instruments.TickSize] | None)

  • stops_trading_at (datetime.datetime)

  • streamer_exchange_code (str)

  • streamer_symbol (str)

  • sub_fraction (decimal.Decimal | None)

  • tick_size (decimal.Decimal)

  • tick_sizes (list[tastytrade.instruments.TickSize] | None)

  • true_underlying_symbol (str | None)

async classmethod a_get_future(session: Session, symbol: str) Self

Returns a Future object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the future for.

async classmethod a_get_futures(session: Session, symbols: list[str] | None = None, product_codes: list[str] | None = None) list[typing_extensions.Self]

Returns a list of Future objects from the given symbols or product codes.

Parameters:
  • session – the session to use for the request.

  • symbols – symbols of the futures, e.g. ‘ESZ9’, ‘/ESZ9’.

  • product_codes – the product codes of the futures, e.g. ‘ES’, ‘6A’. Ignored if symbols are provided.

classmethod get_future(session: Session, symbol: str) Self

Returns a Future object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the future for.

classmethod get_futures(session: Session, symbols: list[str] | None = None, product_codes: list[str] | None = None) list[typing_extensions.Self]

Returns a list of Future objects from the given symbols or product codes.

Parameters:
  • session – the session to use for the request.

  • symbols – symbols of the futures, e.g. ‘ESZ9’, ‘/ESZ9’.

  • product_codes – the product codes of the futures, e.g. ‘ES’, ‘6A’. Ignored if symbols are provided.

pydantic model tastytrade.instruments.FutureEtfEquivalent(*, symbol: str, share_quantity: int)

Bases: TastytradeJsonDataclass

Dataclass that represents the ETF equivalent for a future (aka, the number of shares of the ETF that are equivalent to one future, leverage-wise).

Show JSON schema
{
   "title": "FutureEtfEquivalent",
   "description": "Dataclass that represents the ETF equivalent for a future (aka, the number\nof shares of the ETF that are equivalent to one future, leverage-wise).",
   "type": "object",
   "properties": {
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "share-quantity": {
         "title": "Share-Quantity",
         "type": "integer"
      }
   },
   "required": [
      "symbol",
      "share-quantity"
   ]
}

Fields:
  • share_quantity (int)

  • symbol (str)

enum tastytrade.instruments.FutureMonthCode(value)

Bases: str, Enum

This is an Enum that contains the valid month codes for futures.

This is really here for reference, as the API barely uses these codes.

Member Type:

str

Valid values are as follows:

JAN = <FutureMonthCode.JAN: 'F'>
FEB = <FutureMonthCode.FEB: 'G'>
MAR = <FutureMonthCode.MAR: 'H'>
APR = <FutureMonthCode.APR: 'J'>
MAY = <FutureMonthCode.MAY: 'K'>
JUN = <FutureMonthCode.JUN: 'M'>
JUL = <FutureMonthCode.JUL: 'N'>
AUG = <FutureMonthCode.AUG: 'Q'>
SEP = <FutureMonthCode.SEP: 'U'>
OCT = <FutureMonthCode.OCT: 'V'>
NOV = <FutureMonthCode.NOV: 'X'>
DEC = <FutureMonthCode.DEC: 'Z'>
pydantic model tastytrade.instruments.FutureOption(*, instrument_type: InstrumentType = InstrumentType.FUTURE_OPTION, symbol: str, underlying_symbol: str, product_code: str, expiration_date: date, root_symbol: str, option_root_symbol: str, strike_price: Decimal, exchange: str, streamer_symbol: str, option_type: OptionType, exercise_style: str, is_vanilla: bool, is_primary_deliverable: bool, future_price_ratio: Decimal, multiplier: Decimal, underlying_count: Decimal, is_confirmed: bool, notional_value: Decimal, display_factor: Decimal, settlement_type: str, strike_factor: Decimal, maturity_date: date, is_exercisable_weekly: bool, last_trade_time: str, days_to_expiration: int, is_closing_only: bool, active: bool, stops_trading_at: datetime, expires_at: datetime, exchange_symbol: str, security_exchange: str, sx_id: str, future_option_product: FutureOptionProduct | None = None)

Bases: TradeableTastytradeJsonDataclass

Dataclass that represents a Tastytrade future option object. Contains information about the future option, and methods to get future options.

Show JSON schema
{
   "title": "FutureOption",
   "description": "Dataclass that represents a Tastytrade future option object. Contains\ninformation about the future option, and methods to get future options.",
   "type": "object",
   "properties": {
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType",
         "default": "Future Option"
      },
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "underlying-symbol": {
         "title": "Underlying-Symbol",
         "type": "string"
      },
      "product-code": {
         "title": "Product-Code",
         "type": "string"
      },
      "expiration-date": {
         "format": "date",
         "title": "Expiration-Date",
         "type": "string"
      },
      "root-symbol": {
         "title": "Root-Symbol",
         "type": "string"
      },
      "option-root-symbol": {
         "title": "Option-Root-Symbol",
         "type": "string"
      },
      "strike-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Strike-Price"
      },
      "exchange": {
         "title": "Exchange",
         "type": "string"
      },
      "streamer-symbol": {
         "title": "Streamer-Symbol",
         "type": "string"
      },
      "option-type": {
         "$ref": "#/$defs/OptionType"
      },
      "exercise-style": {
         "title": "Exercise-Style",
         "type": "string"
      },
      "is-vanilla": {
         "title": "Is-Vanilla",
         "type": "boolean"
      },
      "is-primary-deliverable": {
         "title": "Is-Primary-Deliverable",
         "type": "boolean"
      },
      "future-price-ratio": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Future-Price-Ratio"
      },
      "multiplier": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Multiplier"
      },
      "underlying-count": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Underlying-Count"
      },
      "is-confirmed": {
         "title": "Is-Confirmed",
         "type": "boolean"
      },
      "notional-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Notional-Value"
      },
      "display-factor": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Display-Factor"
      },
      "settlement-type": {
         "title": "Settlement-Type",
         "type": "string"
      },
      "strike-factor": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Strike-Factor"
      },
      "maturity-date": {
         "format": "date",
         "title": "Maturity-Date",
         "type": "string"
      },
      "is-exercisable-weekly": {
         "title": "Is-Exercisable-Weekly",
         "type": "boolean"
      },
      "last-trade-time": {
         "title": "Last-Trade-Time",
         "type": "string"
      },
      "days-to-expiration": {
         "title": "Days-To-Expiration",
         "type": "integer"
      },
      "is-closing-only": {
         "title": "Is-Closing-Only",
         "type": "boolean"
      },
      "active": {
         "title": "Active",
         "type": "boolean"
      },
      "stops-trading-at": {
         "format": "date-time",
         "title": "Stops-Trading-At",
         "type": "string"
      },
      "expires-at": {
         "format": "date-time",
         "title": "Expires-At",
         "type": "string"
      },
      "exchange-symbol": {
         "title": "Exchange-Symbol",
         "type": "string"
      },
      "security-exchange": {
         "title": "Security-Exchange",
         "type": "string"
      },
      "sx-id": {
         "title": "Sx-Id",
         "type": "string"
      },
      "future-option-product": {
         "anyOf": [
            {
               "$ref": "#/$defs/FutureOptionProduct"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      }
   },
   "$defs": {
      "FutureMonthCode": {
         "description": "This is an :class:`~enum.Enum` that contains the valid month codes for\nfutures.\n\nThis is really here for reference, as the API barely uses these codes.",
         "enum": [
            "F",
            "G",
            "H",
            "J",
            "K",
            "M",
            "N",
            "Q",
            "U",
            "V",
            "X",
            "Z"
         ],
         "title": "FutureMonthCode",
         "type": "string"
      },
      "FutureOptionProduct": {
         "description": "Dataclass that represents a Tastytrade future option product object.\nContains information about the future option product (deliverable for\nthe future option).",
         "properties": {
            "root-symbol": {
               "title": "Root-Symbol",
               "type": "string"
            },
            "cash-settled": {
               "title": "Cash-Settled",
               "type": "boolean"
            },
            "code": {
               "title": "Code",
               "type": "string"
            },
            "display-factor": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Display-Factor"
            },
            "exchange": {
               "title": "Exchange",
               "type": "string"
            },
            "product-type": {
               "title": "Product-Type",
               "type": "string"
            },
            "expiration-type": {
               "title": "Expiration-Type",
               "type": "string"
            },
            "settlement-delay-days": {
               "title": "Settlement-Delay-Days",
               "type": "integer"
            },
            "market-sector": {
               "title": "Market-Sector",
               "type": "string"
            },
            "clearing-code": {
               "title": "Clearing-Code",
               "type": "string"
            },
            "clearing-exchange-code": {
               "title": "Clearing-Exchange-Code",
               "type": "string"
            },
            "clearing-price-multiplier": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Clearing-Price-Multiplier"
            },
            "is-rollover": {
               "title": "Is-Rollover",
               "type": "boolean"
            },
            "future-product": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/FutureProduct"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            },
            "product-subtype": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Product-Subtype"
            },
            "legacy-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Legacy-Code"
            },
            "clearport-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Clearport-Code"
            }
         },
         "required": [
            "root-symbol",
            "cash-settled",
            "code",
            "display-factor",
            "exchange",
            "product-type",
            "expiration-type",
            "settlement-delay-days",
            "market-sector",
            "clearing-code",
            "clearing-exchange-code",
            "clearing-price-multiplier",
            "is-rollover"
         ],
         "title": "FutureOptionProduct",
         "type": "object"
      },
      "FutureProduct": {
         "description": "Dataclass that represents a Tastytrade future product object. Contains\ninformation about the future product and a method to fetch one for a\nsymbol.\n\nUseful for fetching general information about a family of futures, without\nknowing the specific expirations or symbols.",
         "properties": {
            "root-symbol": {
               "title": "Root-Symbol",
               "type": "string"
            },
            "code": {
               "title": "Code",
               "type": "string"
            },
            "description": {
               "title": "Description",
               "type": "string"
            },
            "exchange": {
               "title": "Exchange",
               "type": "string"
            },
            "product-type": {
               "title": "Product-Type",
               "type": "string"
            },
            "listed-months": {
               "items": {
                  "$ref": "#/$defs/FutureMonthCode"
               },
               "title": "Listed-Months",
               "type": "array"
            },
            "active-months": {
               "items": {
                  "$ref": "#/$defs/FutureMonthCode"
               },
               "title": "Active-Months",
               "type": "array"
            },
            "notional-multiplier": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Notional-Multiplier"
            },
            "tick-size": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Tick-Size"
            },
            "display-factor": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Display-Factor"
            },
            "streamer-exchange-code": {
               "title": "Streamer-Exchange-Code",
               "type": "string"
            },
            "small-notional": {
               "title": "Small-Notional",
               "type": "boolean"
            },
            "back-month-first-calendar-symbol": {
               "title": "Back-Month-First-Calendar-Symbol",
               "type": "boolean"
            },
            "first-notice": {
               "title": "First-Notice",
               "type": "boolean"
            },
            "cash-settled": {
               "title": "Cash-Settled",
               "type": "boolean"
            },
            "market-sector": {
               "title": "Market-Sector",
               "type": "string"
            },
            "clearing-code": {
               "title": "Clearing-Code",
               "type": "string"
            },
            "clearing-exchange-code": {
               "title": "Clearing-Exchange-Code",
               "type": "string"
            },
            "roll": {
               "$ref": "#/$defs/Roll"
            },
            "base-tick": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Base-Tick"
            },
            "sub-tick": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Sub-Tick"
            },
            "contract-limit": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Contract-Limit"
            },
            "product-subtype": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Product-Subtype"
            },
            "security-group": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Security-Group"
            },
            "true-underlying-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "True-Underlying-Code"
            },
            "clearport-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Clearport-Code"
            },
            "legacy-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Legacy-Code"
            },
            "legacy-exchange-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Legacy-Exchange-Code"
            },
            "option-products": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/FutureOptionProduct"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Option-Products"
            }
         },
         "required": [
            "root-symbol",
            "code",
            "description",
            "exchange",
            "product-type",
            "listed-months",
            "active-months",
            "notional-multiplier",
            "tick-size",
            "display-factor",
            "streamer-exchange-code",
            "small-notional",
            "back-month-first-calendar-symbol",
            "first-notice",
            "cash-settled",
            "market-sector",
            "clearing-code",
            "clearing-exchange-code",
            "roll"
         ],
         "title": "FutureProduct",
         "type": "object"
      },
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "OptionType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of options\nand their abbreviations in the API.",
         "enum": [
            "C",
            "P"
         ],
         "title": "OptionType",
         "type": "string"
      },
      "Roll": {
         "description": "Dataclass representing a roll for a future.",
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "active-count": {
               "title": "Active-Count",
               "type": "integer"
            },
            "cash-settled": {
               "title": "Cash-Settled",
               "type": "boolean"
            },
            "business-days-offset": {
               "title": "Business-Days-Offset",
               "type": "integer"
            },
            "first-notice": {
               "title": "First-Notice",
               "type": "boolean"
            }
         },
         "required": [
            "name",
            "active-count",
            "cash-settled",
            "business-days-offset",
            "first-notice"
         ],
         "title": "Roll",
         "type": "object"
      }
   },
   "required": [
      "symbol",
      "underlying-symbol",
      "product-code",
      "expiration-date",
      "root-symbol",
      "option-root-symbol",
      "strike-price",
      "exchange",
      "streamer-symbol",
      "option-type",
      "exercise-style",
      "is-vanilla",
      "is-primary-deliverable",
      "future-price-ratio",
      "multiplier",
      "underlying-count",
      "is-confirmed",
      "notional-value",
      "display-factor",
      "settlement-type",
      "strike-factor",
      "maturity-date",
      "is-exercisable-weekly",
      "last-trade-time",
      "days-to-expiration",
      "is-closing-only",
      "active",
      "stops-trading-at",
      "expires-at",
      "exchange-symbol",
      "security-exchange",
      "sx-id"
   ]
}

Fields:
  • active (bool)

  • days_to_expiration (int)

  • display_factor (decimal.Decimal)

  • exchange (str)

  • exchange_symbol (str)

  • exercise_style (str)

  • expiration_date (datetime.date)

  • expires_at (datetime.datetime)

  • future_option_product (tastytrade.instruments.FutureOptionProduct | None)

  • future_price_ratio (decimal.Decimal)

  • instrument_type (tastytrade.order.InstrumentType)

  • is_closing_only (bool)

  • is_confirmed (bool)

  • is_exercisable_weekly (bool)

  • is_primary_deliverable (bool)

  • is_vanilla (bool)

  • last_trade_time (str)

  • maturity_date (datetime.date)

  • multiplier (decimal.Decimal)

  • notional_value (decimal.Decimal)

  • option_root_symbol (str)

  • option_type (tastytrade.instruments.OptionType)

  • product_code (str)

  • root_symbol (str)

  • security_exchange (str)

  • settlement_type (str)

  • stops_trading_at (datetime.datetime)

  • streamer_symbol (str)

  • strike_factor (decimal.Decimal)

  • strike_price (decimal.Decimal)

  • sx_id (str)

  • underlying_count (decimal.Decimal)

  • underlying_symbol (str)

async classmethod a_get_future_option(session: Session, symbol: str) Self

Returns a FutureOption object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the option for, Tastytrade format

async classmethod a_get_future_options(session: Session, symbols: list[str] | None = None, root_symbol: str | None = None, expiration_date: date | None = None, option_type: OptionType | None = None, strike_price: Decimal | None = None) list[typing_extensions.Self]

Returns a list of FutureOption objects from the given symbols.

NOTE: Last I checked, all of the parameters are bugged except for symbols.

Parameters:
  • session – the session to use for the request.

  • symbols – the Tastytrade symbols to filter by.

  • root_symbol – the root symbol to get the future options for, e.g. ‘EW3’, ‘SO’

  • expiration_date – the expiration date for the future options.

  • option_type – the option type to filter by.

  • strike_price – the strike price to filter by.

classmethod get_future_option(session: Session, symbol: str) Self

Returns a FutureOption object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the option for, Tastytrade format

classmethod get_future_options(session: Session, symbols: list[str] | None = None, root_symbol: str | None = None, expiration_date: date | None = None, option_type: OptionType | None = None, strike_price: Decimal | None = None) list[typing_extensions.Self]

Returns a list of FutureOption objects from the given symbols.

NOTE: Last I checked, all of the parameters are bugged except for symbols.

Parameters:
  • session – the session to use for the request.

  • symbols – the Tastytrade symbols to filter by.

  • root_symbol – the root symbol to get the future options for, e.g. ‘EW3’, ‘SO’

  • expiration_date – the expiration date for the future options.

  • option_type – the option type to filter by.

  • strike_price – the strike price to filter by.

pydantic model tastytrade.instruments.FutureOptionProduct(*, root_symbol: str, cash_settled: bool, code: str, display_factor: Decimal, exchange: str, product_type: str, expiration_type: str, settlement_delay_days: int, market_sector: str, clearing_code: str, clearing_exchange_code: str, clearing_price_multiplier: Decimal, is_rollover: bool, future_product: FutureProduct | None = None, product_subtype: str | None = None, legacy_code: str | None = None, clearport_code: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass that represents a Tastytrade future option product object. Contains information about the future option product (deliverable for the future option).

Show JSON schema
{
   "$defs": {
      "FutureMonthCode": {
         "description": "This is an :class:`~enum.Enum` that contains the valid month codes for\nfutures.\n\nThis is really here for reference, as the API barely uses these codes.",
         "enum": [
            "F",
            "G",
            "H",
            "J",
            "K",
            "M",
            "N",
            "Q",
            "U",
            "V",
            "X",
            "Z"
         ],
         "title": "FutureMonthCode",
         "type": "string"
      },
      "FutureOptionProduct": {
         "description": "Dataclass that represents a Tastytrade future option product object.\nContains information about the future option product (deliverable for\nthe future option).",
         "properties": {
            "root-symbol": {
               "title": "Root-Symbol",
               "type": "string"
            },
            "cash-settled": {
               "title": "Cash-Settled",
               "type": "boolean"
            },
            "code": {
               "title": "Code",
               "type": "string"
            },
            "display-factor": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Display-Factor"
            },
            "exchange": {
               "title": "Exchange",
               "type": "string"
            },
            "product-type": {
               "title": "Product-Type",
               "type": "string"
            },
            "expiration-type": {
               "title": "Expiration-Type",
               "type": "string"
            },
            "settlement-delay-days": {
               "title": "Settlement-Delay-Days",
               "type": "integer"
            },
            "market-sector": {
               "title": "Market-Sector",
               "type": "string"
            },
            "clearing-code": {
               "title": "Clearing-Code",
               "type": "string"
            },
            "clearing-exchange-code": {
               "title": "Clearing-Exchange-Code",
               "type": "string"
            },
            "clearing-price-multiplier": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Clearing-Price-Multiplier"
            },
            "is-rollover": {
               "title": "Is-Rollover",
               "type": "boolean"
            },
            "future-product": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/FutureProduct"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            },
            "product-subtype": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Product-Subtype"
            },
            "legacy-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Legacy-Code"
            },
            "clearport-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Clearport-Code"
            }
         },
         "required": [
            "root-symbol",
            "cash-settled",
            "code",
            "display-factor",
            "exchange",
            "product-type",
            "expiration-type",
            "settlement-delay-days",
            "market-sector",
            "clearing-code",
            "clearing-exchange-code",
            "clearing-price-multiplier",
            "is-rollover"
         ],
         "title": "FutureOptionProduct",
         "type": "object"
      },
      "FutureProduct": {
         "description": "Dataclass that represents a Tastytrade future product object. Contains\ninformation about the future product and a method to fetch one for a\nsymbol.\n\nUseful for fetching general information about a family of futures, without\nknowing the specific expirations or symbols.",
         "properties": {
            "root-symbol": {
               "title": "Root-Symbol",
               "type": "string"
            },
            "code": {
               "title": "Code",
               "type": "string"
            },
            "description": {
               "title": "Description",
               "type": "string"
            },
            "exchange": {
               "title": "Exchange",
               "type": "string"
            },
            "product-type": {
               "title": "Product-Type",
               "type": "string"
            },
            "listed-months": {
               "items": {
                  "$ref": "#/$defs/FutureMonthCode"
               },
               "title": "Listed-Months",
               "type": "array"
            },
            "active-months": {
               "items": {
                  "$ref": "#/$defs/FutureMonthCode"
               },
               "title": "Active-Months",
               "type": "array"
            },
            "notional-multiplier": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Notional-Multiplier"
            },
            "tick-size": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Tick-Size"
            },
            "display-factor": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Display-Factor"
            },
            "streamer-exchange-code": {
               "title": "Streamer-Exchange-Code",
               "type": "string"
            },
            "small-notional": {
               "title": "Small-Notional",
               "type": "boolean"
            },
            "back-month-first-calendar-symbol": {
               "title": "Back-Month-First-Calendar-Symbol",
               "type": "boolean"
            },
            "first-notice": {
               "title": "First-Notice",
               "type": "boolean"
            },
            "cash-settled": {
               "title": "Cash-Settled",
               "type": "boolean"
            },
            "market-sector": {
               "title": "Market-Sector",
               "type": "string"
            },
            "clearing-code": {
               "title": "Clearing-Code",
               "type": "string"
            },
            "clearing-exchange-code": {
               "title": "Clearing-Exchange-Code",
               "type": "string"
            },
            "roll": {
               "$ref": "#/$defs/Roll"
            },
            "base-tick": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Base-Tick"
            },
            "sub-tick": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Sub-Tick"
            },
            "contract-limit": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Contract-Limit"
            },
            "product-subtype": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Product-Subtype"
            },
            "security-group": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Security-Group"
            },
            "true-underlying-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "True-Underlying-Code"
            },
            "clearport-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Clearport-Code"
            },
            "legacy-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Legacy-Code"
            },
            "legacy-exchange-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Legacy-Exchange-Code"
            },
            "option-products": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/FutureOptionProduct"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Option-Products"
            }
         },
         "required": [
            "root-symbol",
            "code",
            "description",
            "exchange",
            "product-type",
            "listed-months",
            "active-months",
            "notional-multiplier",
            "tick-size",
            "display-factor",
            "streamer-exchange-code",
            "small-notional",
            "back-month-first-calendar-symbol",
            "first-notice",
            "cash-settled",
            "market-sector",
            "clearing-code",
            "clearing-exchange-code",
            "roll"
         ],
         "title": "FutureProduct",
         "type": "object"
      },
      "Roll": {
         "description": "Dataclass representing a roll for a future.",
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "active-count": {
               "title": "Active-Count",
               "type": "integer"
            },
            "cash-settled": {
               "title": "Cash-Settled",
               "type": "boolean"
            },
            "business-days-offset": {
               "title": "Business-Days-Offset",
               "type": "integer"
            },
            "first-notice": {
               "title": "First-Notice",
               "type": "boolean"
            }
         },
         "required": [
            "name",
            "active-count",
            "cash-settled",
            "business-days-offset",
            "first-notice"
         ],
         "title": "Roll",
         "type": "object"
      }
   },
   "$ref": "#/$defs/FutureOptionProduct"
}

Fields:
  • cash_settled (bool)

  • clearing_code (str)

  • clearing_exchange_code (str)

  • clearing_price_multiplier (decimal.Decimal)

  • clearport_code (str | None)

  • code (str)

  • display_factor (decimal.Decimal)

  • exchange (str)

  • expiration_type (str)

  • future_product (tastytrade.instruments.FutureProduct | None)

  • is_rollover (bool)

  • legacy_code (str | None)

  • market_sector (str)

  • product_subtype (str | None)

  • product_type (str)

  • root_symbol (str)

  • settlement_delay_days (int)

async classmethod a_get_future_option_product(session: Session, root_symbol: str, exchange: str = 'CME') Self

Returns a FutureOptionProduct object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • code – the root symbol of the future option

  • exchange – the exchange to get the product from

async classmethod a_get_future_option_products(session: Session) list[typing_extensions.Self]

Returns a list of FutureOptionProduct objects available.

Parameters:

session – the session to use for the request.

classmethod get_future_option_product(session: Session, root_symbol: str, exchange: str = 'CME') Self

Returns a FutureOptionProduct object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • code – the root symbol of the future option

  • exchange – the exchange to get the product from

classmethod get_future_option_products(session: Session) list[typing_extensions.Self]

Returns a list of FutureOptionProduct objects available.

Parameters:

session – the session to use for the request.

pydantic model tastytrade.instruments.FutureProduct(*, root_symbol: str, code: str, description: str, exchange: str, product_type: str, listed_months: list[tastytrade.instruments.FutureMonthCode], active_months: list[tastytrade.instruments.FutureMonthCode], notional_multiplier: Decimal, tick_size: Decimal, display_factor: Decimal, streamer_exchange_code: str, small_notional: bool, back_month_first_calendar_symbol: bool, first_notice: bool, cash_settled: bool, market_sector: str, clearing_code: str, clearing_exchange_code: str, roll: Roll, base_tick: int | None = None, sub_tick: int | None = None, contract_limit: int | None = None, product_subtype: str | None = None, security_group: str | None = None, true_underlying_code: str | None = None, clearport_code: str | None = None, legacy_code: str | None = None, legacy_exchange_code: str | None = None, option_products: list['FutureOptionProduct'] | None = None)

Bases: TastytradeJsonDataclass

Dataclass that represents a Tastytrade future product object. Contains information about the future product and a method to fetch one for a symbol.

Useful for fetching general information about a family of futures, without knowing the specific expirations or symbols.

Show JSON schema
{
   "$defs": {
      "FutureMonthCode": {
         "description": "This is an :class:`~enum.Enum` that contains the valid month codes for\nfutures.\n\nThis is really here for reference, as the API barely uses these codes.",
         "enum": [
            "F",
            "G",
            "H",
            "J",
            "K",
            "M",
            "N",
            "Q",
            "U",
            "V",
            "X",
            "Z"
         ],
         "title": "FutureMonthCode",
         "type": "string"
      },
      "FutureOptionProduct": {
         "description": "Dataclass that represents a Tastytrade future option product object.\nContains information about the future option product (deliverable for\nthe future option).",
         "properties": {
            "root-symbol": {
               "title": "Root-Symbol",
               "type": "string"
            },
            "cash-settled": {
               "title": "Cash-Settled",
               "type": "boolean"
            },
            "code": {
               "title": "Code",
               "type": "string"
            },
            "display-factor": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Display-Factor"
            },
            "exchange": {
               "title": "Exchange",
               "type": "string"
            },
            "product-type": {
               "title": "Product-Type",
               "type": "string"
            },
            "expiration-type": {
               "title": "Expiration-Type",
               "type": "string"
            },
            "settlement-delay-days": {
               "title": "Settlement-Delay-Days",
               "type": "integer"
            },
            "market-sector": {
               "title": "Market-Sector",
               "type": "string"
            },
            "clearing-code": {
               "title": "Clearing-Code",
               "type": "string"
            },
            "clearing-exchange-code": {
               "title": "Clearing-Exchange-Code",
               "type": "string"
            },
            "clearing-price-multiplier": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Clearing-Price-Multiplier"
            },
            "is-rollover": {
               "title": "Is-Rollover",
               "type": "boolean"
            },
            "future-product": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/FutureProduct"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            },
            "product-subtype": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Product-Subtype"
            },
            "legacy-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Legacy-Code"
            },
            "clearport-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Clearport-Code"
            }
         },
         "required": [
            "root-symbol",
            "cash-settled",
            "code",
            "display-factor",
            "exchange",
            "product-type",
            "expiration-type",
            "settlement-delay-days",
            "market-sector",
            "clearing-code",
            "clearing-exchange-code",
            "clearing-price-multiplier",
            "is-rollover"
         ],
         "title": "FutureOptionProduct",
         "type": "object"
      },
      "FutureProduct": {
         "description": "Dataclass that represents a Tastytrade future product object. Contains\ninformation about the future product and a method to fetch one for a\nsymbol.\n\nUseful for fetching general information about a family of futures, without\nknowing the specific expirations or symbols.",
         "properties": {
            "root-symbol": {
               "title": "Root-Symbol",
               "type": "string"
            },
            "code": {
               "title": "Code",
               "type": "string"
            },
            "description": {
               "title": "Description",
               "type": "string"
            },
            "exchange": {
               "title": "Exchange",
               "type": "string"
            },
            "product-type": {
               "title": "Product-Type",
               "type": "string"
            },
            "listed-months": {
               "items": {
                  "$ref": "#/$defs/FutureMonthCode"
               },
               "title": "Listed-Months",
               "type": "array"
            },
            "active-months": {
               "items": {
                  "$ref": "#/$defs/FutureMonthCode"
               },
               "title": "Active-Months",
               "type": "array"
            },
            "notional-multiplier": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Notional-Multiplier"
            },
            "tick-size": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Tick-Size"
            },
            "display-factor": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Display-Factor"
            },
            "streamer-exchange-code": {
               "title": "Streamer-Exchange-Code",
               "type": "string"
            },
            "small-notional": {
               "title": "Small-Notional",
               "type": "boolean"
            },
            "back-month-first-calendar-symbol": {
               "title": "Back-Month-First-Calendar-Symbol",
               "type": "boolean"
            },
            "first-notice": {
               "title": "First-Notice",
               "type": "boolean"
            },
            "cash-settled": {
               "title": "Cash-Settled",
               "type": "boolean"
            },
            "market-sector": {
               "title": "Market-Sector",
               "type": "string"
            },
            "clearing-code": {
               "title": "Clearing-Code",
               "type": "string"
            },
            "clearing-exchange-code": {
               "title": "Clearing-Exchange-Code",
               "type": "string"
            },
            "roll": {
               "$ref": "#/$defs/Roll"
            },
            "base-tick": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Base-Tick"
            },
            "sub-tick": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Sub-Tick"
            },
            "contract-limit": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Contract-Limit"
            },
            "product-subtype": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Product-Subtype"
            },
            "security-group": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Security-Group"
            },
            "true-underlying-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "True-Underlying-Code"
            },
            "clearport-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Clearport-Code"
            },
            "legacy-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Legacy-Code"
            },
            "legacy-exchange-code": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Legacy-Exchange-Code"
            },
            "option-products": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/FutureOptionProduct"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Option-Products"
            }
         },
         "required": [
            "root-symbol",
            "code",
            "description",
            "exchange",
            "product-type",
            "listed-months",
            "active-months",
            "notional-multiplier",
            "tick-size",
            "display-factor",
            "streamer-exchange-code",
            "small-notional",
            "back-month-first-calendar-symbol",
            "first-notice",
            "cash-settled",
            "market-sector",
            "clearing-code",
            "clearing-exchange-code",
            "roll"
         ],
         "title": "FutureProduct",
         "type": "object"
      },
      "Roll": {
         "description": "Dataclass representing a roll for a future.",
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "active-count": {
               "title": "Active-Count",
               "type": "integer"
            },
            "cash-settled": {
               "title": "Cash-Settled",
               "type": "boolean"
            },
            "business-days-offset": {
               "title": "Business-Days-Offset",
               "type": "integer"
            },
            "first-notice": {
               "title": "First-Notice",
               "type": "boolean"
            }
         },
         "required": [
            "name",
            "active-count",
            "cash-settled",
            "business-days-offset",
            "first-notice"
         ],
         "title": "Roll",
         "type": "object"
      }
   },
   "$ref": "#/$defs/FutureProduct"
}

Fields:
  • active_months (list[tastytrade.instruments.FutureMonthCode])

  • back_month_first_calendar_symbol (bool)

  • base_tick (int | None)

  • cash_settled (bool)

  • clearing_code (str)

  • clearing_exchange_code (str)

  • clearport_code (str | None)

  • code (str)

  • contract_limit (int | None)

  • description (str)

  • display_factor (decimal.Decimal)

  • exchange (str)

  • first_notice (bool)

  • legacy_code (str | None)

  • legacy_exchange_code (str | None)

  • listed_months (list[tastytrade.instruments.FutureMonthCode])

  • market_sector (str)

  • notional_multiplier (decimal.Decimal)

  • option_products (list['FutureOptionProduct'] | None)

  • product_subtype (str | None)

  • product_type (str)

  • roll (tastytrade.instruments.Roll)

  • root_symbol (str)

  • security_group (str | None)

  • small_notional (bool)

  • streamer_exchange_code (str)

  • sub_tick (int | None)

  • tick_size (decimal.Decimal)

  • true_underlying_code (str | None)

async classmethod a_get_future_product(session: Session, code: str, exchange: str = 'CME') Self

Returns a FutureProduct object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • code – the product code, e.g. ‘ES’

  • exchange – the exchange to fetch from: ‘CME’, ‘SMALLS’, ‘CFE’, ‘CBOED’

async classmethod a_get_future_products(session: Session) list[typing_extensions.Self]

Returns a list of FutureProduct objects available.

Parameters:

session – the session to use for the request.

classmethod get_future_product(session: Session, code: str, exchange: str = 'CME') Self

Returns a FutureProduct object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • code – the product code, e.g. ‘ES’

  • exchange – the exchange to fetch from: ‘CME’, ‘SMALLS’, ‘CFE’, ‘CBOED’

classmethod get_future_products(session: Session) list[typing_extensions.Self]

Returns a list of FutureProduct objects available.

Parameters:

session – the session to use for the request.

pydantic model tastytrade.instruments.NestedFutureOptionChain(*, futures: list[tastytrade.instruments.NestedFutureOptionFuture], option_chains: list[tastytrade.instruments.NestedFutureOptionSubchain])

Bases: TastytradeJsonDataclass

Dataclass that represents a Tastytrade nested option chain object. Contains information about the option chain and a method to fetch one for a symbol.

This is cleaner than calling get_future_option_chain() but if you want to create actual FutureOption objects you’ll need to make an extra API request or two.

Show JSON schema
{
   "title": "NestedFutureOptionChain",
   "description": "Dataclass that represents a Tastytrade nested option chain object. Contains\ninformation about the option chain and a method to fetch one for a symbol.\n\nThis is cleaner than calling :meth:`get_future_option_chain` but if you\nwant to create actual :class:`FutureOption` objects you'll need to make an\nextra API request or two.",
   "type": "object",
   "properties": {
      "futures": {
         "items": {
            "$ref": "#/$defs/NestedFutureOptionFuture"
         },
         "title": "Futures",
         "type": "array"
      },
      "option-chains": {
         "items": {
            "$ref": "#/$defs/NestedFutureOptionSubchain"
         },
         "title": "Option-Chains",
         "type": "array"
      }
   },
   "$defs": {
      "NestedFutureOptionChainExpiration": {
         "description": "Dataclass representing an expiration in a nested future options chain.",
         "properties": {
            "root-symbol": {
               "title": "Root-Symbol",
               "type": "string"
            },
            "notional-value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Notional-Value"
            },
            "underlying-symbol": {
               "title": "Underlying-Symbol",
               "type": "string"
            },
            "strike-factor": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Strike-Factor"
            },
            "days-to-expiration": {
               "title": "Days-To-Expiration",
               "type": "integer"
            },
            "option-root-symbol": {
               "title": "Option-Root-Symbol",
               "type": "string"
            },
            "expiration-date": {
               "format": "date",
               "title": "Expiration-Date",
               "type": "string"
            },
            "expires-at": {
               "format": "date-time",
               "title": "Expires-At",
               "type": "string"
            },
            "asset": {
               "title": "Asset",
               "type": "string"
            },
            "expiration-type": {
               "title": "Expiration-Type",
               "type": "string"
            },
            "display-factor": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Display-Factor"
            },
            "option-contract-symbol": {
               "title": "Option-Contract-Symbol",
               "type": "string"
            },
            "stops-trading-at": {
               "format": "date-time",
               "title": "Stops-Trading-At",
               "type": "string"
            },
            "settlement-type": {
               "title": "Settlement-Type",
               "type": "string"
            },
            "strikes": {
               "items": {
                  "$ref": "#/$defs/Strike"
               },
               "title": "Strikes",
               "type": "array"
            },
            "tick-sizes": {
               "items": {
                  "$ref": "#/$defs/TickSize"
               },
               "title": "Tick-Sizes",
               "type": "array"
            }
         },
         "required": [
            "root-symbol",
            "notional-value",
            "underlying-symbol",
            "strike-factor",
            "days-to-expiration",
            "option-root-symbol",
            "expiration-date",
            "expires-at",
            "asset",
            "expiration-type",
            "display-factor",
            "option-contract-symbol",
            "stops-trading-at",
            "settlement-type",
            "strikes",
            "tick-sizes"
         ],
         "title": "NestedFutureOptionChainExpiration",
         "type": "object"
      },
      "NestedFutureOptionFuture": {
         "description": "Dataclass representing an underlying future in a nested future options\nchain.",
         "properties": {
            "root-symbol": {
               "title": "Root-Symbol",
               "type": "string"
            },
            "days-to-expiration": {
               "title": "Days-To-Expiration",
               "type": "integer"
            },
            "expiration-date": {
               "format": "date",
               "title": "Expiration-Date",
               "type": "string"
            },
            "expires-at": {
               "format": "date-time",
               "title": "Expires-At",
               "type": "string"
            },
            "next-active-month": {
               "title": "Next-Active-Month",
               "type": "boolean"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "active-month": {
               "title": "Active-Month",
               "type": "boolean"
            },
            "stops-trading-at": {
               "format": "date-time",
               "title": "Stops-Trading-At",
               "type": "string"
            },
            "maturity-date": {
               "anyOf": [
                  {
                     "format": "date",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Maturity-Date"
            }
         },
         "required": [
            "root-symbol",
            "days-to-expiration",
            "expiration-date",
            "expires-at",
            "next-active-month",
            "symbol",
            "active-month",
            "stops-trading-at"
         ],
         "title": "NestedFutureOptionFuture",
         "type": "object"
      },
      "NestedFutureOptionSubchain": {
         "description": "Dataclass that represents a Tastytrade nested future option chain for a\nspecific futures underlying symbol.",
         "properties": {
            "underlying-symbol": {
               "title": "Underlying-Symbol",
               "type": "string"
            },
            "root-symbol": {
               "title": "Root-Symbol",
               "type": "string"
            },
            "exercise-style": {
               "title": "Exercise-Style",
               "type": "string"
            },
            "expirations": {
               "items": {
                  "$ref": "#/$defs/NestedFutureOptionChainExpiration"
               },
               "title": "Expirations",
               "type": "array"
            }
         },
         "required": [
            "underlying-symbol",
            "root-symbol",
            "exercise-style",
            "expirations"
         ],
         "title": "NestedFutureOptionSubchain",
         "type": "object"
      },
      "Strike": {
         "description": "Dataclass representing a specific strike in an options chain, containing\nthe symbols for the call and put options.",
         "properties": {
            "strike-price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Strike-Price"
            },
            "call": {
               "title": "Call",
               "type": "string"
            },
            "put": {
               "title": "Put",
               "type": "string"
            },
            "call-streamer-symbol": {
               "title": "Call-Streamer-Symbol",
               "type": "string"
            },
            "put-streamer-symbol": {
               "title": "Put-Streamer-Symbol",
               "type": "string"
            }
         },
         "required": [
            "strike-price",
            "call",
            "put",
            "call-streamer-symbol",
            "put-streamer-symbol"
         ],
         "title": "Strike",
         "type": "object"
      },
      "TickSize": {
         "description": "Dataclass representing the tick size for an instrument.",
         "properties": {
            "value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Value"
            },
            "threshold": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Threshold"
            },
            "symbol": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Symbol"
            }
         },
         "required": [
            "value"
         ],
         "title": "TickSize",
         "type": "object"
      }
   },
   "required": [
      "futures",
      "option-chains"
   ]
}

Fields:
  • futures (list[tastytrade.instruments.NestedFutureOptionFuture])

  • option_chains (list[tastytrade.instruments.NestedFutureOptionSubchain])

async classmethod a_get_chain(session: Session, symbol: str) Self

Gets the futures option chain for the given symbol in nested format.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the option chain for.

classmethod get_chain(session: Session, symbol: str) Self

Gets the futures option chain for the given symbol in nested format.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the option chain for.

pydantic model tastytrade.instruments.NestedFutureOptionChainExpiration(*, root_symbol: str, notional_value: Decimal, underlying_symbol: str, strike_factor: Decimal, days_to_expiration: int, option_root_symbol: str, expiration_date: date, expires_at: datetime, asset: str, expiration_type: str, display_factor: Decimal, option_contract_symbol: str, stops_trading_at: datetime, settlement_type: str, strikes: list[tastytrade.instruments.Strike], tick_sizes: list[tastytrade.instruments.TickSize])

Bases: TastytradeJsonDataclass

Dataclass representing an expiration in a nested future options chain.

Show JSON schema
{
   "title": "NestedFutureOptionChainExpiration",
   "description": "Dataclass representing an expiration in a nested future options chain.",
   "type": "object",
   "properties": {
      "root-symbol": {
         "title": "Root-Symbol",
         "type": "string"
      },
      "notional-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Notional-Value"
      },
      "underlying-symbol": {
         "title": "Underlying-Symbol",
         "type": "string"
      },
      "strike-factor": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Strike-Factor"
      },
      "days-to-expiration": {
         "title": "Days-To-Expiration",
         "type": "integer"
      },
      "option-root-symbol": {
         "title": "Option-Root-Symbol",
         "type": "string"
      },
      "expiration-date": {
         "format": "date",
         "title": "Expiration-Date",
         "type": "string"
      },
      "expires-at": {
         "format": "date-time",
         "title": "Expires-At",
         "type": "string"
      },
      "asset": {
         "title": "Asset",
         "type": "string"
      },
      "expiration-type": {
         "title": "Expiration-Type",
         "type": "string"
      },
      "display-factor": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Display-Factor"
      },
      "option-contract-symbol": {
         "title": "Option-Contract-Symbol",
         "type": "string"
      },
      "stops-trading-at": {
         "format": "date-time",
         "title": "Stops-Trading-At",
         "type": "string"
      },
      "settlement-type": {
         "title": "Settlement-Type",
         "type": "string"
      },
      "strikes": {
         "items": {
            "$ref": "#/$defs/Strike"
         },
         "title": "Strikes",
         "type": "array"
      },
      "tick-sizes": {
         "items": {
            "$ref": "#/$defs/TickSize"
         },
         "title": "Tick-Sizes",
         "type": "array"
      }
   },
   "$defs": {
      "Strike": {
         "description": "Dataclass representing a specific strike in an options chain, containing\nthe symbols for the call and put options.",
         "properties": {
            "strike-price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Strike-Price"
            },
            "call": {
               "title": "Call",
               "type": "string"
            },
            "put": {
               "title": "Put",
               "type": "string"
            },
            "call-streamer-symbol": {
               "title": "Call-Streamer-Symbol",
               "type": "string"
            },
            "put-streamer-symbol": {
               "title": "Put-Streamer-Symbol",
               "type": "string"
            }
         },
         "required": [
            "strike-price",
            "call",
            "put",
            "call-streamer-symbol",
            "put-streamer-symbol"
         ],
         "title": "Strike",
         "type": "object"
      },
      "TickSize": {
         "description": "Dataclass representing the tick size for an instrument.",
         "properties": {
            "value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Value"
            },
            "threshold": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Threshold"
            },
            "symbol": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Symbol"
            }
         },
         "required": [
            "value"
         ],
         "title": "TickSize",
         "type": "object"
      }
   },
   "required": [
      "root-symbol",
      "notional-value",
      "underlying-symbol",
      "strike-factor",
      "days-to-expiration",
      "option-root-symbol",
      "expiration-date",
      "expires-at",
      "asset",
      "expiration-type",
      "display-factor",
      "option-contract-symbol",
      "stops-trading-at",
      "settlement-type",
      "strikes",
      "tick-sizes"
   ]
}

Fields:
  • asset (str)

  • days_to_expiration (int)

  • display_factor (decimal.Decimal)

  • expiration_date (datetime.date)

  • expiration_type (str)

  • expires_at (datetime.datetime)

  • notional_value (decimal.Decimal)

  • option_contract_symbol (str)

  • option_root_symbol (str)

  • root_symbol (str)

  • settlement_type (str)

  • stops_trading_at (datetime.datetime)

  • strike_factor (decimal.Decimal)

  • strikes (list[tastytrade.instruments.Strike])

  • tick_sizes (list[tastytrade.instruments.TickSize])

  • underlying_symbol (str)

pydantic model tastytrade.instruments.NestedFutureOptionFuture(*, root_symbol: str, days_to_expiration: int, expiration_date: date, expires_at: datetime, next_active_month: bool, symbol: str, active_month: bool, stops_trading_at: datetime, maturity_date: date | None = None)

Bases: TastytradeJsonDataclass

Dataclass representing an underlying future in a nested future options chain.

Show JSON schema
{
   "title": "NestedFutureOptionFuture",
   "description": "Dataclass representing an underlying future in a nested future options\nchain.",
   "type": "object",
   "properties": {
      "root-symbol": {
         "title": "Root-Symbol",
         "type": "string"
      },
      "days-to-expiration": {
         "title": "Days-To-Expiration",
         "type": "integer"
      },
      "expiration-date": {
         "format": "date",
         "title": "Expiration-Date",
         "type": "string"
      },
      "expires-at": {
         "format": "date-time",
         "title": "Expires-At",
         "type": "string"
      },
      "next-active-month": {
         "title": "Next-Active-Month",
         "type": "boolean"
      },
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "active-month": {
         "title": "Active-Month",
         "type": "boolean"
      },
      "stops-trading-at": {
         "format": "date-time",
         "title": "Stops-Trading-At",
         "type": "string"
      },
      "maturity-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Maturity-Date"
      }
   },
   "required": [
      "root-symbol",
      "days-to-expiration",
      "expiration-date",
      "expires-at",
      "next-active-month",
      "symbol",
      "active-month",
      "stops-trading-at"
   ]
}

Fields:
  • active_month (bool)

  • days_to_expiration (int)

  • expiration_date (datetime.date)

  • expires_at (datetime.datetime)

  • maturity_date (datetime.date | None)

  • next_active_month (bool)

  • root_symbol (str)

  • stops_trading_at (datetime.datetime)

  • symbol (str)

pydantic model tastytrade.instruments.NestedFutureOptionSubchain(*, underlying_symbol: str, root_symbol: str, exercise_style: str, expirations: list[tastytrade.instruments.NestedFutureOptionChainExpiration])

Bases: TastytradeJsonDataclass

Dataclass that represents a Tastytrade nested future option chain for a specific futures underlying symbol.

Show JSON schema
{
   "title": "NestedFutureOptionSubchain",
   "description": "Dataclass that represents a Tastytrade nested future option chain for a\nspecific futures underlying symbol.",
   "type": "object",
   "properties": {
      "underlying-symbol": {
         "title": "Underlying-Symbol",
         "type": "string"
      },
      "root-symbol": {
         "title": "Root-Symbol",
         "type": "string"
      },
      "exercise-style": {
         "title": "Exercise-Style",
         "type": "string"
      },
      "expirations": {
         "items": {
            "$ref": "#/$defs/NestedFutureOptionChainExpiration"
         },
         "title": "Expirations",
         "type": "array"
      }
   },
   "$defs": {
      "NestedFutureOptionChainExpiration": {
         "description": "Dataclass representing an expiration in a nested future options chain.",
         "properties": {
            "root-symbol": {
               "title": "Root-Symbol",
               "type": "string"
            },
            "notional-value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Notional-Value"
            },
            "underlying-symbol": {
               "title": "Underlying-Symbol",
               "type": "string"
            },
            "strike-factor": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Strike-Factor"
            },
            "days-to-expiration": {
               "title": "Days-To-Expiration",
               "type": "integer"
            },
            "option-root-symbol": {
               "title": "Option-Root-Symbol",
               "type": "string"
            },
            "expiration-date": {
               "format": "date",
               "title": "Expiration-Date",
               "type": "string"
            },
            "expires-at": {
               "format": "date-time",
               "title": "Expires-At",
               "type": "string"
            },
            "asset": {
               "title": "Asset",
               "type": "string"
            },
            "expiration-type": {
               "title": "Expiration-Type",
               "type": "string"
            },
            "display-factor": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Display-Factor"
            },
            "option-contract-symbol": {
               "title": "Option-Contract-Symbol",
               "type": "string"
            },
            "stops-trading-at": {
               "format": "date-time",
               "title": "Stops-Trading-At",
               "type": "string"
            },
            "settlement-type": {
               "title": "Settlement-Type",
               "type": "string"
            },
            "strikes": {
               "items": {
                  "$ref": "#/$defs/Strike"
               },
               "title": "Strikes",
               "type": "array"
            },
            "tick-sizes": {
               "items": {
                  "$ref": "#/$defs/TickSize"
               },
               "title": "Tick-Sizes",
               "type": "array"
            }
         },
         "required": [
            "root-symbol",
            "notional-value",
            "underlying-symbol",
            "strike-factor",
            "days-to-expiration",
            "option-root-symbol",
            "expiration-date",
            "expires-at",
            "asset",
            "expiration-type",
            "display-factor",
            "option-contract-symbol",
            "stops-trading-at",
            "settlement-type",
            "strikes",
            "tick-sizes"
         ],
         "title": "NestedFutureOptionChainExpiration",
         "type": "object"
      },
      "Strike": {
         "description": "Dataclass representing a specific strike in an options chain, containing\nthe symbols for the call and put options.",
         "properties": {
            "strike-price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Strike-Price"
            },
            "call": {
               "title": "Call",
               "type": "string"
            },
            "put": {
               "title": "Put",
               "type": "string"
            },
            "call-streamer-symbol": {
               "title": "Call-Streamer-Symbol",
               "type": "string"
            },
            "put-streamer-symbol": {
               "title": "Put-Streamer-Symbol",
               "type": "string"
            }
         },
         "required": [
            "strike-price",
            "call",
            "put",
            "call-streamer-symbol",
            "put-streamer-symbol"
         ],
         "title": "Strike",
         "type": "object"
      },
      "TickSize": {
         "description": "Dataclass representing the tick size for an instrument.",
         "properties": {
            "value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Value"
            },
            "threshold": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Threshold"
            },
            "symbol": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Symbol"
            }
         },
         "required": [
            "value"
         ],
         "title": "TickSize",
         "type": "object"
      }
   },
   "required": [
      "underlying-symbol",
      "root-symbol",
      "exercise-style",
      "expirations"
   ]
}

Fields:
  • exercise_style (str)

  • expirations (list[tastytrade.instruments.NestedFutureOptionChainExpiration])

  • root_symbol (str)

  • underlying_symbol (str)

pydantic model tastytrade.instruments.NestedOptionChain(*, underlying_symbol: str, root_symbol: str, option_chain_type: str, shares_per_contract: int, tick_sizes: list[tastytrade.instruments.TickSize], deliverables: list[tastytrade.instruments.Deliverable], expirations: list[tastytrade.instruments.NestedOptionChainExpiration])

Bases: TastytradeJsonDataclass

Dataclass that represents a Tastytrade nested option chain object. Contains information about the option chain and a method to fetch one for a symbol.

This is cleaner than calling get_option_chain() but if you want to create actual Option objects you’ll need to make an extra API request or two.

Show JSON schema
{
   "title": "NestedOptionChain",
   "description": "Dataclass that represents a Tastytrade nested option chain object.\nContains information about the option chain and a method to fetch one for\na symbol.\n\nThis is cleaner than calling :meth:`get_option_chain` but if you want to\ncreate actual :class:`Option` objects you'll need to make an extra API\nrequest or two.",
   "type": "object",
   "properties": {
      "underlying-symbol": {
         "title": "Underlying-Symbol",
         "type": "string"
      },
      "root-symbol": {
         "title": "Root-Symbol",
         "type": "string"
      },
      "option-chain-type": {
         "title": "Option-Chain-Type",
         "type": "string"
      },
      "shares-per-contract": {
         "title": "Shares-Per-Contract",
         "type": "integer"
      },
      "tick-sizes": {
         "items": {
            "$ref": "#/$defs/TickSize"
         },
         "title": "Tick-Sizes",
         "type": "array"
      },
      "deliverables": {
         "items": {
            "$ref": "#/$defs/Deliverable"
         },
         "title": "Deliverables",
         "type": "array"
      },
      "expirations": {
         "items": {
            "$ref": "#/$defs/NestedOptionChainExpiration"
         },
         "title": "Expirations",
         "type": "array"
      }
   },
   "$defs": {
      "Deliverable": {
         "description": "Dataclass representing the deliverable for an option.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "integer"
            },
            "root-symbol": {
               "title": "Root-Symbol",
               "type": "string"
            },
            "deliverable-type": {
               "title": "Deliverable-Type",
               "type": "string"
            },
            "description": {
               "title": "Description",
               "type": "string"
            },
            "amount": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Amount"
            },
            "percent": {
               "title": "Percent",
               "type": "string"
            },
            "symbol": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Symbol"
            },
            "instrument-type": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/InstrumentType"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            }
         },
         "required": [
            "id",
            "root-symbol",
            "deliverable-type",
            "description",
            "amount",
            "percent"
         ],
         "title": "Deliverable",
         "type": "object"
      },
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "NestedOptionChainExpiration": {
         "description": "Dataclass representing an expiration in a nested options chain.",
         "properties": {
            "expiration-type": {
               "title": "Expiration-Type",
               "type": "string"
            },
            "expiration-date": {
               "format": "date",
               "title": "Expiration-Date",
               "type": "string"
            },
            "days-to-expiration": {
               "title": "Days-To-Expiration",
               "type": "integer"
            },
            "settlement-type": {
               "title": "Settlement-Type",
               "type": "string"
            },
            "strikes": {
               "items": {
                  "$ref": "#/$defs/Strike"
               },
               "title": "Strikes",
               "type": "array"
            }
         },
         "required": [
            "expiration-type",
            "expiration-date",
            "days-to-expiration",
            "settlement-type",
            "strikes"
         ],
         "title": "NestedOptionChainExpiration",
         "type": "object"
      },
      "Strike": {
         "description": "Dataclass representing a specific strike in an options chain, containing\nthe symbols for the call and put options.",
         "properties": {
            "strike-price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Strike-Price"
            },
            "call": {
               "title": "Call",
               "type": "string"
            },
            "put": {
               "title": "Put",
               "type": "string"
            },
            "call-streamer-symbol": {
               "title": "Call-Streamer-Symbol",
               "type": "string"
            },
            "put-streamer-symbol": {
               "title": "Put-Streamer-Symbol",
               "type": "string"
            }
         },
         "required": [
            "strike-price",
            "call",
            "put",
            "call-streamer-symbol",
            "put-streamer-symbol"
         ],
         "title": "Strike",
         "type": "object"
      },
      "TickSize": {
         "description": "Dataclass representing the tick size for an instrument.",
         "properties": {
            "value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Value"
            },
            "threshold": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Threshold"
            },
            "symbol": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Symbol"
            }
         },
         "required": [
            "value"
         ],
         "title": "TickSize",
         "type": "object"
      }
   },
   "required": [
      "underlying-symbol",
      "root-symbol",
      "option-chain-type",
      "shares-per-contract",
      "tick-sizes",
      "deliverables",
      "expirations"
   ]
}

Fields:
  • deliverables (list[tastytrade.instruments.Deliverable])

  • expirations (list[tastytrade.instruments.NestedOptionChainExpiration])

  • option_chain_type (str)

  • root_symbol (str)

  • shares_per_contract (int)

  • tick_sizes (list[tastytrade.instruments.TickSize])

  • underlying_symbol (str)

async classmethod a_get_chain(session: Session, symbol: str) Self

Gets the option chain for the given symbol in nested format.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the option chain for.

classmethod get_chain(session: Session, symbol: str) Self

Gets the option chain for the given symbol in nested format.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the option chain for.

pydantic model tastytrade.instruments.NestedOptionChainExpiration(*, expiration_type: str, expiration_date: date, days_to_expiration: int, settlement_type: str, strikes: list[tastytrade.instruments.Strike])

Bases: TastytradeJsonDataclass

Dataclass representing an expiration in a nested options chain.

Show JSON schema
{
   "title": "NestedOptionChainExpiration",
   "description": "Dataclass representing an expiration in a nested options chain.",
   "type": "object",
   "properties": {
      "expiration-type": {
         "title": "Expiration-Type",
         "type": "string"
      },
      "expiration-date": {
         "format": "date",
         "title": "Expiration-Date",
         "type": "string"
      },
      "days-to-expiration": {
         "title": "Days-To-Expiration",
         "type": "integer"
      },
      "settlement-type": {
         "title": "Settlement-Type",
         "type": "string"
      },
      "strikes": {
         "items": {
            "$ref": "#/$defs/Strike"
         },
         "title": "Strikes",
         "type": "array"
      }
   },
   "$defs": {
      "Strike": {
         "description": "Dataclass representing a specific strike in an options chain, containing\nthe symbols for the call and put options.",
         "properties": {
            "strike-price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Strike-Price"
            },
            "call": {
               "title": "Call",
               "type": "string"
            },
            "put": {
               "title": "Put",
               "type": "string"
            },
            "call-streamer-symbol": {
               "title": "Call-Streamer-Symbol",
               "type": "string"
            },
            "put-streamer-symbol": {
               "title": "Put-Streamer-Symbol",
               "type": "string"
            }
         },
         "required": [
            "strike-price",
            "call",
            "put",
            "call-streamer-symbol",
            "put-streamer-symbol"
         ],
         "title": "Strike",
         "type": "object"
      }
   },
   "required": [
      "expiration-type",
      "expiration-date",
      "days-to-expiration",
      "settlement-type",
      "strikes"
   ]
}

Fields:
  • days_to_expiration (int)

  • expiration_date (datetime.date)

  • expiration_type (str)

  • settlement_type (str)

  • strikes (list[tastytrade.instruments.Strike])

pydantic model tastytrade.instruments.Option(*, instrument_type: InstrumentType, symbol: str, active: bool, strike_price: Decimal, root_symbol: str, underlying_symbol: str, expiration_date: date, exercise_style: str, shares_per_contract: int, option_type: OptionType, option_chain_type: str, expiration_type: str, settlement_type: str, stops_trading_at: datetime, market_time_instrument_collection: str, days_to_expiration: int, expires_at: datetime, is_closing_only: bool, streamer_symbol: str = '', listed_market: str | None = None, halted_at: datetime | None = None, old_security_number: str | None = None)

Bases: TradeableTastytradeJsonDataclass

Dataclass that represents a Tastytrade option object. Contains information about the option and methods to populate that data using option symbol(s).

Show JSON schema
{
   "title": "Option",
   "description": "Dataclass that represents a Tastytrade option object. Contains information\nabout the option and methods to populate that data using option symbol(s).",
   "type": "object",
   "properties": {
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "active": {
         "title": "Active",
         "type": "boolean"
      },
      "strike-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Strike-Price"
      },
      "root-symbol": {
         "title": "Root-Symbol",
         "type": "string"
      },
      "underlying-symbol": {
         "title": "Underlying-Symbol",
         "type": "string"
      },
      "expiration-date": {
         "format": "date",
         "title": "Expiration-Date",
         "type": "string"
      },
      "exercise-style": {
         "title": "Exercise-Style",
         "type": "string"
      },
      "shares-per-contract": {
         "title": "Shares-Per-Contract",
         "type": "integer"
      },
      "option-type": {
         "$ref": "#/$defs/OptionType"
      },
      "option-chain-type": {
         "title": "Option-Chain-Type",
         "type": "string"
      },
      "expiration-type": {
         "title": "Expiration-Type",
         "type": "string"
      },
      "settlement-type": {
         "title": "Settlement-Type",
         "type": "string"
      },
      "stops-trading-at": {
         "format": "date-time",
         "title": "Stops-Trading-At",
         "type": "string"
      },
      "market-time-instrument-collection": {
         "title": "Market-Time-Instrument-Collection",
         "type": "string"
      },
      "days-to-expiration": {
         "title": "Days-To-Expiration",
         "type": "integer"
      },
      "expires-at": {
         "format": "date-time",
         "title": "Expires-At",
         "type": "string"
      },
      "is-closing-only": {
         "title": "Is-Closing-Only",
         "type": "boolean"
      },
      "streamer-symbol": {
         "default": "",
         "title": "Streamer-Symbol",
         "type": "string"
      },
      "listed-market": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Listed-Market"
      },
      "halted-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Halted-At"
      },
      "old-security-number": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Old-Security-Number"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "OptionType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of options\nand their abbreviations in the API.",
         "enum": [
            "C",
            "P"
         ],
         "title": "OptionType",
         "type": "string"
      }
   },
   "required": [
      "instrument-type",
      "symbol",
      "active",
      "strike-price",
      "root-symbol",
      "underlying-symbol",
      "expiration-date",
      "exercise-style",
      "shares-per-contract",
      "option-type",
      "option-chain-type",
      "expiration-type",
      "settlement-type",
      "stops-trading-at",
      "market-time-instrument-collection",
      "days-to-expiration",
      "expires-at",
      "is-closing-only"
   ]
}

Fields:
  • active (bool)

  • days_to_expiration (int)

  • exercise_style (str)

  • expiration_date (datetime.date)

  • expiration_type (str)

  • expires_at (datetime.datetime)

  • halted_at (datetime.datetime | None)

  • is_closing_only (bool)

  • listed_market (str | None)

  • market_time_instrument_collection (str)

  • old_security_number (str | None)

  • option_chain_type (str)

  • option_type (tastytrade.instruments.OptionType)

  • root_symbol (str)

  • settlement_type (str)

  • shares_per_contract (int)

  • stops_trading_at (datetime.datetime)

  • streamer_symbol (str)

  • strike_price (decimal.Decimal)

  • underlying_symbol (str)

Validators:
  • set_streamer_symbol » all fields

async classmethod a_get_option(session: Session, symbol: str, active: bool | None = None) Self

Returns a Option object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the option for, OCC format

async classmethod a_get_options(session: Session, symbols: list[str] | None = None, active: bool | None = None, with_expired: bool | None = None) list[typing_extensions.Self]

Returns a list of Option objects from the given symbols.

Parameters:
  • session – the session to use for the request.

  • symbols – the OCC symbols to get the options for.

  • active – whether the options are active.

  • with_expired – whether to include expired options.

classmethod get_option(session: Session, symbol: str, active: bool | None = None) Self

Returns a Option object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the option for, OCC format

classmethod get_options(session: Session, symbols: list[str] | None = None, active: bool | None = None, with_expired: bool | None = None) list[typing_extensions.Self]

Returns a list of Option objects from the given symbols.

Parameters:
  • session – the session to use for the request.

  • symbols – the OCC symbols to get the options for.

  • active – whether the options are active.

  • with_expired – whether to include expired options.

classmethod occ_to_streamer_symbol(occ) str

Returns the dxfeed symbol for use in the streamer from the given OCC 2010 symbol.

Parameters:

occ – the OCC symbol to convert

classmethod streamer_symbol_to_occ(streamer_symbol) str

Returns the OCC 2010 symbol equivalent to the given streamer symbol.

Parameters:

streamer_symbol – the streamer symbol to convert

enum tastytrade.instruments.OptionType(value)

Bases: str, Enum

This is an Enum that contains the valid types of options and their abbreviations in the API.

Member Type:

str

Valid values are as follows:

CALL = <OptionType.CALL: 'C'>
PUT = <OptionType.PUT: 'P'>
pydantic model tastytrade.instruments.QuantityDecimalPrecision(*, instrument_type: InstrumentType, value: int, minimum_increment_precision: int, symbol: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass representing the decimal precision (number of places) for an instrument.

Show JSON schema
{
   "title": "QuantityDecimalPrecision",
   "description": "Dataclass representing the decimal precision (number of places) for an\ninstrument.",
   "type": "object",
   "properties": {
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "value": {
         "title": "Value",
         "type": "integer"
      },
      "minimum-increment-precision": {
         "title": "Minimum-Increment-Precision",
         "type": "integer"
      },
      "symbol": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Symbol"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      }
   },
   "required": [
      "instrument-type",
      "value",
      "minimum-increment-precision"
   ]
}

Fields:
  • instrument_type (tastytrade.order.InstrumentType)

  • minimum_increment_precision (int)

  • symbol (str | None)

  • value (int)

pydantic model tastytrade.instruments.Roll(*, name: str, active_count: int, cash_settled: bool, business_days_offset: int, first_notice: bool)

Bases: TastytradeJsonDataclass

Dataclass representing a roll for a future.

Show JSON schema
{
   "title": "Roll",
   "description": "Dataclass representing a roll for a future.",
   "type": "object",
   "properties": {
      "name": {
         "title": "Name",
         "type": "string"
      },
      "active-count": {
         "title": "Active-Count",
         "type": "integer"
      },
      "cash-settled": {
         "title": "Cash-Settled",
         "type": "boolean"
      },
      "business-days-offset": {
         "title": "Business-Days-Offset",
         "type": "integer"
      },
      "first-notice": {
         "title": "First-Notice",
         "type": "boolean"
      }
   },
   "required": [
      "name",
      "active-count",
      "cash-settled",
      "business-days-offset",
      "first-notice"
   ]
}

Fields:
  • active_count (int)

  • business_days_offset (int)

  • cash_settled (bool)

  • first_notice (bool)

  • name (str)

pydantic model tastytrade.instruments.Strike(*, strike_price: Decimal, call: str, put: str, call_streamer_symbol: str, put_streamer_symbol: str)

Bases: TastytradeJsonDataclass

Dataclass representing a specific strike in an options chain, containing the symbols for the call and put options.

Show JSON schema
{
   "title": "Strike",
   "description": "Dataclass representing a specific strike in an options chain, containing\nthe symbols for the call and put options.",
   "type": "object",
   "properties": {
      "strike-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Strike-Price"
      },
      "call": {
         "title": "Call",
         "type": "string"
      },
      "put": {
         "title": "Put",
         "type": "string"
      },
      "call-streamer-symbol": {
         "title": "Call-Streamer-Symbol",
         "type": "string"
      },
      "put-streamer-symbol": {
         "title": "Put-Streamer-Symbol",
         "type": "string"
      }
   },
   "required": [
      "strike-price",
      "call",
      "put",
      "call-streamer-symbol",
      "put-streamer-symbol"
   ]
}

Fields:
  • call (str)

  • call_streamer_symbol (str)

  • put (str)

  • put_streamer_symbol (str)

  • strike_price (decimal.Decimal)

pydantic model tastytrade.instruments.TickSize(*, value: Decimal, threshold: Decimal | None = None, symbol: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass representing the tick size for an instrument.

Show JSON schema
{
   "title": "TickSize",
   "description": "Dataclass representing the tick size for an instrument.",
   "type": "object",
   "properties": {
      "value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Value"
      },
      "threshold": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Threshold"
      },
      "symbol": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Symbol"
      }
   },
   "required": [
      "value"
   ]
}

Fields:
  • symbol (str | None)

  • threshold (decimal.Decimal | None)

  • value (decimal.Decimal)

pydantic model tastytrade.instruments.Warrant(*, symbol: str, instrument_type: InstrumentType, listed_market: str, description: str, is_closing_only: bool, active: bool, cusip: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass that represents a Tastytrade warrant object. Contains information about the warrant, and methods to get warrants.

Show JSON schema
{
   "title": "Warrant",
   "description": "Dataclass that represents a Tastytrade warrant object. Contains\ninformation about the warrant, and methods to get warrants.",
   "type": "object",
   "properties": {
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "listed-market": {
         "title": "Listed-Market",
         "type": "string"
      },
      "description": {
         "title": "Description",
         "type": "string"
      },
      "is-closing-only": {
         "title": "Is-Closing-Only",
         "type": "boolean"
      },
      "active": {
         "title": "Active",
         "type": "boolean"
      },
      "cusip": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Cusip"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      }
   },
   "required": [
      "symbol",
      "instrument-type",
      "listed-market",
      "description",
      "is-closing-only",
      "active"
   ]
}

Fields:
  • active (bool)

  • cusip (str | None)

  • description (str)

  • instrument_type (tastytrade.order.InstrumentType)

  • is_closing_only (bool)

  • listed_market (str)

  • symbol (str)

async classmethod a_get_warrant(session: Session, symbol: str) Self

Returns a Warrant object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the warrant for.

async classmethod a_get_warrants(session: Session, symbols: list[str] | None = None) list[typing_extensions.Self]

Returns a list of Warrant objects from the given symbols.

Parameters:
  • session – the session to use for the request.

  • symbols – symbols of the warrants, e.g. ‘NKLAW’

classmethod get_warrant(session: Session, symbol: str) Self

Returns a Warrant object from the given symbol.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the warrant for.

classmethod get_warrants(session: Session, symbols: list[str] | None = None) list[typing_extensions.Self]

Returns a list of Warrant objects from the given symbols.

Parameters:
  • session – the session to use for the request.

  • symbols – symbols of the warrants, e.g. ‘NKLAW’

async tastytrade.instruments.a_get_future_option_chain(session: Session, symbol: str) dict[datetime.date, list[tastytrade.instruments.FutureOption]]

Returns a mapping of expiration date to a list of futures options objects representing the options chain for the given symbol.

In the case that there are two expiries on the same day (e.g. EW and ES options), both will be returned in the same list. If you just want one expiry, you’ll need to filter the list yourself, or use NestedFutureOptionChain instead.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the option chain for.

async tastytrade.instruments.a_get_option_chain(session: Session, symbol: str) dict[datetime.date, list[tastytrade.instruments.Option]]

Returns a mapping of expiration date to a list of option objects representing the options chain for the given symbol.

In the case that there are two expiries on the same day (e.g. SPXW and SPX AM options), both will be returned in the same list. If you just want one expiry, you’ll need to filter the list yourself, or use NestedOptionChain instead.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the option chain for.

async tastytrade.instruments.a_get_quantity_decimal_precisions(session: Session) list[tastytrade.instruments.QuantityDecimalPrecision]

Returns a list of QuantityDecimalPrecision objects for different types of instruments.

Parameters:

session – the session to use for the request.

tastytrade.instruments.get_future_option_chain(session: Session, symbol: str) dict[datetime.date, list[tastytrade.instruments.FutureOption]]

Returns a mapping of expiration date to a list of futures options objects representing the options chain for the given symbol.

In the case that there are two expiries on the same day (e.g. EW and ES options), both will be returned in the same list. If you just want one expiry, you’ll need to filter the list yourself, or use NestedFutureOptionChain instead.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the option chain for.

tastytrade.instruments.get_option_chain(session: Session, symbol: str) dict[datetime.date, list[tastytrade.instruments.Option]]

Returns a mapping of expiration date to a list of option objects representing the options chain for the given symbol.

In the case that there are two expiries on the same day (e.g. SPXW and SPX AM options), both will be returned in the same list. If you just want one expiry, you’ll need to filter the list yourself, or use NestedOptionChain instead.

Parameters:
  • session – the session to use for the request.

  • symbol – the symbol to get the option chain for.

tastytrade.instruments.get_quantity_decimal_precisions(session: Session) list[tastytrade.instruments.QuantityDecimalPrecision]

Returns a list of QuantityDecimalPrecision objects for different types of instruments.

Parameters:

session – the session to use for the request.

Metrics

pydantic model tastytrade.metrics.DividendInfo(*, occurred_date: date, amount: Decimal)

Bases: TastytradeJsonDataclass

Dataclass representing dividend information for a given symbol.

Show JSON schema
{
   "title": "DividendInfo",
   "description": "Dataclass representing dividend information for a given symbol.",
   "type": "object",
   "properties": {
      "occurred-date": {
         "format": "date",
         "title": "Occurred-Date",
         "type": "string"
      },
      "amount": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Amount"
      }
   },
   "required": [
      "occurred-date",
      "amount"
   ]
}

Fields:
  • amount (decimal.Decimal)

  • occurred_date (datetime.date)

pydantic model tastytrade.metrics.EarningsInfo(*, occurred_date: date, eps: Decimal)

Bases: TastytradeJsonDataclass

Dataclass representing earnings information for a given symbol.

Show JSON schema
{
   "title": "EarningsInfo",
   "description": "Dataclass representing earnings information for a given symbol.",
   "type": "object",
   "properties": {
      "occurred-date": {
         "format": "date",
         "title": "Occurred-Date",
         "type": "string"
      },
      "eps": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Eps"
      }
   },
   "required": [
      "occurred-date",
      "eps"
   ]
}

Fields:
  • eps (decimal.Decimal)

  • occurred_date (datetime.date)

pydantic model tastytrade.metrics.EarningsReport(*, estimated: bool, late_flag: int, visible: bool, actual_eps: Decimal | None = None, consensus_estimate: Decimal | None = None, expected_report_date: date | None = None, quarter_end_date: date | None = None, time_of_day: str | None = None, updated_at: datetime | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing information about a recent earnings report, or the expected date of the next one.

Show JSON schema
{
   "title": "EarningsReport",
   "description": "Dataclass containing information about a recent earnings report, or the\nexpected date of the next one.",
   "type": "object",
   "properties": {
      "estimated": {
         "title": "Estimated",
         "type": "boolean"
      },
      "late-flag": {
         "title": "Late-Flag",
         "type": "integer"
      },
      "visible": {
         "title": "Visible",
         "type": "boolean"
      },
      "actual-eps": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Actual-Eps"
      },
      "consensus-estimate": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Consensus-Estimate"
      },
      "expected-report-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Expected-Report-Date"
      },
      "quarter-end-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Quarter-End-Date"
      },
      "time-of-day": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Time-Of-Day"
      },
      "updated-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Updated-At"
      }
   },
   "required": [
      "estimated",
      "late-flag",
      "visible"
   ]
}

Fields:
  • actual_eps (decimal.Decimal | None)

  • consensus_estimate (decimal.Decimal | None)

  • estimated (bool)

  • expected_report_date (datetime.date | None)

  • late_flag (int)

  • quarter_end_date (datetime.date | None)

  • time_of_day (str | None)

  • updated_at (datetime.datetime | None)

  • visible (bool)

pydantic model tastytrade.metrics.Liquidity(*, sum: Decimal, count: int, started_at: datetime, updated_at: datetime | None = None)

Bases: TastytradeJsonDataclass

Dataclass representing liquidity information for a given symbol.

Show JSON schema
{
   "title": "Liquidity",
   "description": "Dataclass representing liquidity information for a given symbol.",
   "type": "object",
   "properties": {
      "sum": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Sum"
      },
      "count": {
         "title": "Count",
         "type": "integer"
      },
      "started-at": {
         "format": "date-time",
         "title": "Started-At",
         "type": "string"
      },
      "updated-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Updated-At"
      }
   },
   "required": [
      "sum",
      "count",
      "started-at"
   ]
}

Fields:
  • count (int)

  • started_at (datetime.datetime)

  • sum (decimal.Decimal)

  • updated_at (datetime.datetime | None)

pydantic model tastytrade.metrics.MarketMetricInfo(*, symbol: str, implied_volatility_index: Decimal | None = None, implied_volatility_index_5_day_change: Decimal | None = None, implied_volatility_index_rank: str | None = None, tos_implied_volatility_index_rank: Decimal | None = None, tw_implied_volatility_index_rank: Decimal | None = None, tos_implied_volatility_index_rank_updated_at: datetime | None = None, implied_volatility_index_rank_source: str | None = None, implied_volatility_percentile: str | None = None, implied_volatility_updated_at: datetime | None = None, liquidity_rating: int | None = None, updated_at: datetime, option_expiration_implied_volatilities: list[tastytrade.metrics.OptionExpirationImpliedVolatility] | None = None, beta: Decimal | None = None, corr_spy_3month: Decimal | None = None, market_cap: Decimal, earnings: EarningsReport | None = None, price_earnings_ratio: Decimal | None = None, earnings_per_share: Decimal | None = None, dividend_rate_per_share: Decimal | None = None, implied_volatility_30_day: Decimal | None = None, historical_volatility_30_day: Decimal | None = None, historical_volatility_60_day: Decimal | None = None, historical_volatility_90_day: Decimal | None = None, iv_hv_30_day_difference: Decimal | None = None, beta_updated_at: datetime | None = None, created_at: datetime | None = None, dividend_ex_date: date | None = None, dividend_next_date: date | None = None, dividend_pay_date: date | None = None, dividend_updated_at: datetime | None = None, liquidity_value: Decimal | None = None, liquidity_rank: Decimal | None = None, liquidity_running_state: Liquidity | None = None, dividend_yield: Decimal | None = None, listed_market: str | None = None, lendability: str | None = None, borrow_rate: Decimal | None = None)

Bases: TastytradeJsonDataclass

Dataclass representing market metrics for a given symbol.

Contains lots of useful information, like IV rank, IV percentile and beta.

Show JSON schema
{
   "title": "MarketMetricInfo",
   "description": "Dataclass representing market metrics for a given symbol.\n\nContains lots of useful information, like IV rank, IV percentile and beta.",
   "type": "object",
   "properties": {
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "implied-volatility-index": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Implied-Volatility-Index"
      },
      "implied-volatility-index-5-day-change": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Implied-Volatility-Index-5-Day-Change"
      },
      "implied-volatility-index-rank": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Implied-Volatility-Index-Rank"
      },
      "tos-implied-volatility-index-rank": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Tos-Implied-Volatility-Index-Rank"
      },
      "tw-implied-volatility-index-rank": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Tw-Implied-Volatility-Index-Rank"
      },
      "tos-implied-volatility-index-rank-updated-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Tos-Implied-Volatility-Index-Rank-Updated-At"
      },
      "implied-volatility-index-rank-source": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Implied-Volatility-Index-Rank-Source"
      },
      "implied-volatility-percentile": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Implied-Volatility-Percentile"
      },
      "implied-volatility-updated-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Implied-Volatility-Updated-At"
      },
      "liquidity-rating": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Liquidity-Rating"
      },
      "updated-at": {
         "format": "date-time",
         "title": "Updated-At",
         "type": "string"
      },
      "option-expiration-implied-volatilities": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/OptionExpirationImpliedVolatility"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Option-Expiration-Implied-Volatilities"
      },
      "beta": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Beta"
      },
      "corr-spy-3month": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Corr-Spy-3Month"
      },
      "market-cap": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Market-Cap"
      },
      "earnings": {
         "anyOf": [
            {
               "$ref": "#/$defs/EarningsReport"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "price-earnings-ratio": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Price-Earnings-Ratio"
      },
      "earnings-per-share": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Earnings-Per-Share"
      },
      "dividend-rate-per-share": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Dividend-Rate-Per-Share"
      },
      "implied-volatility-30-day": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Implied-Volatility-30-Day"
      },
      "historical-volatility-30-day": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Historical-Volatility-30-Day"
      },
      "historical-volatility-60-day": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Historical-Volatility-60-Day"
      },
      "historical-volatility-90-day": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Historical-Volatility-90-Day"
      },
      "iv-hv-30-day-difference": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Iv-Hv-30-Day-Difference"
      },
      "beta-updated-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Beta-Updated-At"
      },
      "created-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Created-At"
      },
      "dividend-ex-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Dividend-Ex-Date"
      },
      "dividend-next-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Dividend-Next-Date"
      },
      "dividend-pay-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Dividend-Pay-Date"
      },
      "dividend-updated-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Dividend-Updated-At"
      },
      "liquidity-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Liquidity-Value"
      },
      "liquidity-rank": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Liquidity-Rank"
      },
      "liquidity-running-state": {
         "anyOf": [
            {
               "$ref": "#/$defs/Liquidity"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "dividend-yield": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Dividend-Yield"
      },
      "listed-market": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Listed-Market"
      },
      "lendability": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Lendability"
      },
      "borrow-rate": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Borrow-Rate"
      }
   },
   "$defs": {
      "EarningsReport": {
         "description": "Dataclass containing information about a recent earnings report, or the\nexpected date of the next one.",
         "properties": {
            "estimated": {
               "title": "Estimated",
               "type": "boolean"
            },
            "late-flag": {
               "title": "Late-Flag",
               "type": "integer"
            },
            "visible": {
               "title": "Visible",
               "type": "boolean"
            },
            "actual-eps": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Actual-Eps"
            },
            "consensus-estimate": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Consensus-Estimate"
            },
            "expected-report-date": {
               "anyOf": [
                  {
                     "format": "date",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Expected-Report-Date"
            },
            "quarter-end-date": {
               "anyOf": [
                  {
                     "format": "date",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Quarter-End-Date"
            },
            "time-of-day": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Time-Of-Day"
            },
            "updated-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Updated-At"
            }
         },
         "required": [
            "estimated",
            "late-flag",
            "visible"
         ],
         "title": "EarningsReport",
         "type": "object"
      },
      "Liquidity": {
         "description": "Dataclass representing liquidity information for a given symbol.",
         "properties": {
            "sum": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Sum"
            },
            "count": {
               "title": "Count",
               "type": "integer"
            },
            "started-at": {
               "format": "date-time",
               "title": "Started-At",
               "type": "string"
            },
            "updated-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Updated-At"
            }
         },
         "required": [
            "sum",
            "count",
            "started-at"
         ],
         "title": "Liquidity",
         "type": "object"
      },
      "OptionExpirationImpliedVolatility": {
         "description": "Dataclass containing implied volatility information for a given symbol\nand expiration date.",
         "properties": {
            "expiration-date": {
               "format": "date",
               "title": "Expiration-Date",
               "type": "string"
            },
            "settlement-type": {
               "title": "Settlement-Type",
               "type": "string"
            },
            "option-chain-type": {
               "title": "Option-Chain-Type",
               "type": "string"
            },
            "implied-volatility": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Implied-Volatility"
            }
         },
         "required": [
            "expiration-date",
            "settlement-type",
            "option-chain-type"
         ],
         "title": "OptionExpirationImpliedVolatility",
         "type": "object"
      }
   },
   "required": [
      "symbol",
      "updated-at",
      "market-cap"
   ]
}

Fields:
  • beta (decimal.Decimal | None)

  • beta_updated_at (datetime.datetime | None)

  • borrow_rate (decimal.Decimal | None)

  • corr_spy_3month (decimal.Decimal | None)

  • created_at (datetime.datetime | None)

  • dividend_ex_date (datetime.date | None)

  • dividend_next_date (datetime.date | None)

  • dividend_pay_date (datetime.date | None)

  • dividend_rate_per_share (decimal.Decimal | None)

  • dividend_updated_at (datetime.datetime | None)

  • dividend_yield (decimal.Decimal | None)

  • earnings (tastytrade.metrics.EarningsReport | None)

  • earnings_per_share (decimal.Decimal | None)

  • historical_volatility_30_day (decimal.Decimal | None)

  • historical_volatility_60_day (decimal.Decimal | None)

  • historical_volatility_90_day (decimal.Decimal | None)

  • implied_volatility_30_day (decimal.Decimal | None)

  • implied_volatility_index (decimal.Decimal | None)

  • implied_volatility_index_5_day_change (decimal.Decimal | None)

  • implied_volatility_index_rank (str | None)

  • implied_volatility_index_rank_source (str | None)

  • implied_volatility_percentile (str | None)

  • implied_volatility_updated_at (datetime.datetime | None)

  • iv_hv_30_day_difference (decimal.Decimal | None)

  • lendability (str | None)

  • liquidity_rank (decimal.Decimal | None)

  • liquidity_rating (int | None)

  • liquidity_running_state (tastytrade.metrics.Liquidity | None)

  • liquidity_value (decimal.Decimal | None)

  • listed_market (str | None)

  • market_cap (decimal.Decimal)

  • option_expiration_implied_volatilities (list[tastytrade.metrics.OptionExpirationImpliedVolatility] | None)

  • price_earnings_ratio (decimal.Decimal | None)

  • symbol (str)

  • tos_implied_volatility_index_rank (decimal.Decimal | None)

  • tos_implied_volatility_index_rank_updated_at (datetime.datetime | None)

  • tw_implied_volatility_index_rank (decimal.Decimal | None)

  • updated_at (datetime.datetime)

pydantic model tastytrade.metrics.OptionExpirationImpliedVolatility(*, expiration_date: date, settlement_type: str, option_chain_type: str, implied_volatility: Decimal | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing implied volatility information for a given symbol and expiration date.

Show JSON schema
{
   "title": "OptionExpirationImpliedVolatility",
   "description": "Dataclass containing implied volatility information for a given symbol\nand expiration date.",
   "type": "object",
   "properties": {
      "expiration-date": {
         "format": "date",
         "title": "Expiration-Date",
         "type": "string"
      },
      "settlement-type": {
         "title": "Settlement-Type",
         "type": "string"
      },
      "option-chain-type": {
         "title": "Option-Chain-Type",
         "type": "string"
      },
      "implied-volatility": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Implied-Volatility"
      }
   },
   "required": [
      "expiration-date",
      "settlement-type",
      "option-chain-type"
   ]
}

Fields:
  • expiration_date (datetime.date)

  • implied_volatility (decimal.Decimal | None)

  • option_chain_type (str)

  • settlement_type (str)

async tastytrade.metrics.a_get_dividends(session: Session, symbol: str) list[tastytrade.metrics.DividendInfo]

Retrieves dividend information for the given symbol.

Parameters:
  • session – active user session to use

  • symbol – symbol to retrieve dividend information for

async tastytrade.metrics.a_get_earnings(session: Session, symbol: str, start_date: date) list[tastytrade.metrics.EarningsInfo]

Retrieves earnings information for the given symbol.

Parameters:
  • session – active user session to use

  • symbol – symbol to retrieve earnings information for

  • start_date – limits earnings to those on or after the given date

async tastytrade.metrics.a_get_market_metrics(session: Session, symbols: list[str]) list[tastytrade.metrics.MarketMetricInfo]

Retrieves market metrics for the given symbols.

Parameters:
  • session – active user session to use

  • symbols – list of symbols to retrieve metrics for

async tastytrade.metrics.a_get_risk_free_rate(session: Session) Decimal

Retrieves the current risk-free rate.

Parameters:

session – active user session to use

tastytrade.metrics.get_dividends(session: Session, symbol: str) list[tastytrade.metrics.DividendInfo]

Retrieves dividend information for the given symbol.

Parameters:
  • session – active user session to use

  • symbol – symbol to retrieve dividend information for

tastytrade.metrics.get_earnings(session: Session, symbol: str, start_date: date) list[tastytrade.metrics.EarningsInfo]

Retrieves earnings information for the given symbol.

Parameters:
  • session – active user session to use

  • symbol – symbol to retrieve earnings information for

  • start_date – limits earnings to those on or after the given date

tastytrade.metrics.get_market_metrics(session: Session, symbols: list[str]) list[tastytrade.metrics.MarketMetricInfo]

Retrieves market metrics for the given symbols.

Parameters:
  • session – active user session to use

  • symbols – list of symbols to retrieve metrics for

tastytrade.metrics.get_risk_free_rate(session: Session) Decimal

Retrieves the current risk-free rate.

Parameters:

session – active user session to use

Order

pydantic model tastytrade.order.AdvancedInstructions(*, strict_position_effect_validation: bool = False)

Bases: TastytradeJsonDataclass

Dataclass containing advanced order rules.

Show JSON schema
{
   "title": "AdvancedInstructions",
   "description": "Dataclass containing advanced order rules.",
   "type": "object",
   "properties": {
      "strict-position-effect-validation": {
         "default": false,
         "title": "Strict-Position-Effect-Validation",
         "type": "boolean"
      }
   }
}

Fields:
field strict_position_effect_validation: bool = False (alias 'strict-position-effect-validation')

By default, if a position meant to be closed by a closing order is no longer open, the API will turn it into an opening order. With this flag, the API would instead discard the closing order.

pydantic model tastytrade.order.BuyingPowerEffect(*, change_in_margin_requirement: Decimal, change_in_buying_power: Decimal, current_buying_power: Decimal, new_buying_power: Decimal, isolated_order_margin_requirement: Decimal, is_spread: bool, impact: Decimal, effect: PriceEffect)

Bases: TastytradeJsonDataclass

Dataclass containing information about the effect of a trade on buying power.

Show JSON schema
{
   "title": "BuyingPowerEffect",
   "description": "Dataclass containing information about the effect of a trade on buying\npower.",
   "type": "object",
   "properties": {
      "change-in-margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Change-In-Margin-Requirement"
      },
      "change-in-buying-power": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Change-In-Buying-Power"
      },
      "current-buying-power": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Current-Buying-Power"
      },
      "new-buying-power": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "New-Buying-Power"
      },
      "isolated-order-margin-requirement": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Isolated-Order-Margin-Requirement"
      },
      "is-spread": {
         "title": "Is-Spread",
         "type": "boolean"
      },
      "impact": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Impact"
      },
      "effect": {
         "$ref": "#/$defs/PriceEffect"
      }
   },
   "$defs": {
      "PriceEffect": {
         "description": "This is an :class:`~enum.Enum` that shows the sign of a price effect, since\nTastytrade is apparently against negative numbers.",
         "enum": [
            "Credit",
            "Debit",
            "None"
         ],
         "title": "PriceEffect",
         "type": "string"
      }
   },
   "required": [
      "change-in-margin-requirement",
      "change-in-buying-power",
      "current-buying-power",
      "new-buying-power",
      "isolated-order-margin-requirement",
      "is-spread",
      "impact",
      "effect"
   ]
}

Fields:
  • change_in_buying_power (decimal.Decimal)

  • change_in_margin_requirement (decimal.Decimal)

  • current_buying_power (decimal.Decimal)

  • effect (tastytrade.utils.PriceEffect)

  • impact (decimal.Decimal)

  • is_spread (bool)

  • isolated_order_margin_requirement (decimal.Decimal)

  • new_buying_power (decimal.Decimal)

Validators:
  • validate_price_effects » all fields

enum tastytrade.order.ComplexOrderType(value)

Bases: str, Enum

This is an Enum that contains the valid complex order types.

Member Type:

str

Valid values are as follows:

OCO = <ComplexOrderType.OCO: 'OCO'>
OTOCO = <ComplexOrderType.OTOCO: 'OTOCO'>
pydantic model tastytrade.order.ComputedData(*, open: bool, updated_at: datetime, total_fees: Decimal, total_commissions: Decimal, realized_gain: Decimal, realized_gain_with_fees: Decimal, winner_realized_and_closed: bool, winner_realized: bool, winner_realized_with_fees: bool, roll_count: int, opened_at: datetime, last_occurred_at: datetime, started_at_days_to_expiration: int, duration: int, total_opening_cost: Decimal, total_closing_cost: Decimal, total_cost: Decimal, gcd_open_quantity: Decimal, fees_missing: bool, open_entries: list[tastytrade.order.OrderChainEntry], total_cost_per_unit: Decimal | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing computed data about an order chain.

Show JSON schema
{
   "title": "ComputedData",
   "description": "Dataclass containing computed data about an order chain.",
   "type": "object",
   "properties": {
      "open": {
         "title": "Open",
         "type": "boolean"
      },
      "updated-at": {
         "format": "date-time",
         "title": "Updated-At",
         "type": "string"
      },
      "total-fees": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Total-Fees"
      },
      "total-commissions": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Total-Commissions"
      },
      "realized-gain": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Realized-Gain"
      },
      "realized-gain-with-fees": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Realized-Gain-With-Fees"
      },
      "winner-realized-and-closed": {
         "title": "Winner-Realized-And-Closed",
         "type": "boolean"
      },
      "winner-realized": {
         "title": "Winner-Realized",
         "type": "boolean"
      },
      "winner-realized-with-fees": {
         "title": "Winner-Realized-With-Fees",
         "type": "boolean"
      },
      "roll-count": {
         "title": "Roll-Count",
         "type": "integer"
      },
      "opened-at": {
         "format": "date-time",
         "title": "Opened-At",
         "type": "string"
      },
      "last-occurred-at": {
         "format": "date-time",
         "title": "Last-Occurred-At",
         "type": "string"
      },
      "started-at-days-to-expiration": {
         "title": "Started-At-Days-To-Expiration",
         "type": "integer"
      },
      "duration": {
         "title": "Duration",
         "type": "integer"
      },
      "total-opening-cost": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Total-Opening-Cost"
      },
      "total-closing-cost": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Total-Closing-Cost"
      },
      "total-cost": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Total-Cost"
      },
      "gcd-open-quantity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Gcd-Open-Quantity"
      },
      "fees-missing": {
         "title": "Fees-Missing",
         "type": "boolean"
      },
      "open-entries": {
         "items": {
            "$ref": "#/$defs/OrderChainEntry"
         },
         "title": "Open-Entries",
         "type": "array"
      },
      "total-cost-per-unit": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Total-Cost-Per-Unit"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "OrderChainEntry": {
         "description": "Dataclass containing information about a single order in an order chain.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "quantity": {
               "title": "Quantity",
               "type": "string"
            },
            "quantity-type": {
               "title": "Quantity-Type",
               "type": "string"
            },
            "quantity-numeric": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity-Numeric"
            }
         },
         "required": [
            "symbol",
            "instrument-type",
            "quantity",
            "quantity-type",
            "quantity-numeric"
         ],
         "title": "OrderChainEntry",
         "type": "object"
      }
   },
   "required": [
      "open",
      "updated-at",
      "total-fees",
      "total-commissions",
      "realized-gain",
      "realized-gain-with-fees",
      "winner-realized-and-closed",
      "winner-realized",
      "winner-realized-with-fees",
      "roll-count",
      "opened-at",
      "last-occurred-at",
      "started-at-days-to-expiration",
      "duration",
      "total-opening-cost",
      "total-closing-cost",
      "total-cost",
      "gcd-open-quantity",
      "fees-missing",
      "open-entries"
   ]
}

Fields:
  • duration (int)

  • fees_missing (bool)

  • gcd_open_quantity (decimal.Decimal)

  • last_occurred_at (datetime.datetime)

  • open (bool)

  • open_entries (list[tastytrade.order.OrderChainEntry])

  • opened_at (datetime.datetime)

  • realized_gain (decimal.Decimal)

  • realized_gain_with_fees (decimal.Decimal)

  • roll_count (int)

  • started_at_days_to_expiration (int)

  • total_closing_cost (decimal.Decimal)

  • total_commissions (decimal.Decimal)

  • total_cost (decimal.Decimal)

  • total_cost_per_unit (decimal.Decimal | None)

  • total_fees (decimal.Decimal)

  • total_opening_cost (decimal.Decimal)

  • updated_at (datetime.datetime)

  • winner_realized (bool)

  • winner_realized_and_closed (bool)

  • winner_realized_with_fees (bool)

Validators:
  • validate_price_effects » all fields

pydantic model tastytrade.order.FeeCalculation(*, regulatory_fees: Decimal, clearing_fees: Decimal, commission: Decimal, proprietary_index_option_fees: Decimal, total_fees: Decimal)

Bases: TastytradeJsonDataclass

Dataclass containing information about the fees associated with a trade.

Show JSON schema
{
   "title": "FeeCalculation",
   "description": "Dataclass containing information about the fees associated with a trade.",
   "type": "object",
   "properties": {
      "regulatory-fees": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Regulatory-Fees"
      },
      "clearing-fees": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Clearing-Fees"
      },
      "commission": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Commission"
      },
      "proprietary-index-option-fees": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Proprietary-Index-Option-Fees"
      },
      "total-fees": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Total-Fees"
      }
   },
   "required": [
      "regulatory-fees",
      "clearing-fees",
      "commission",
      "proprietary-index-option-fees",
      "total-fees"
   ]
}

Fields:
  • clearing_fees (decimal.Decimal)

  • commission (decimal.Decimal)

  • proprietary_index_option_fees (decimal.Decimal)

  • regulatory_fees (decimal.Decimal)

  • total_fees (decimal.Decimal)

Validators:
  • validate_price_effects » all fields

pydantic model tastytrade.order.FillInfo(*, fill_id: str, quantity: Decimal, fill_price: Decimal, filled_at: datetime, destination_venue: str | None = None, ext_group_fill_id: str | None = None, ext_exec_id: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass that contains information about an order fill.

Show JSON schema
{
   "title": "FillInfo",
   "description": "Dataclass that contains information about an order fill.",
   "type": "object",
   "properties": {
      "fill-id": {
         "title": "Fill-Id",
         "type": "string"
      },
      "quantity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Quantity"
      },
      "fill-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Fill-Price"
      },
      "filled-at": {
         "format": "date-time",
         "title": "Filled-At",
         "type": "string"
      },
      "destination-venue": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Destination-Venue"
      },
      "ext-group-fill-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Ext-Group-Fill-Id"
      },
      "ext-exec-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Ext-Exec-Id"
      }
   },
   "required": [
      "fill-id",
      "quantity",
      "fill-price",
      "filled-at"
   ]
}

Fields:
  • destination_venue (str | None)

  • ext_exec_id (str | None)

  • ext_group_fill_id (str | None)

  • fill_id (str)

  • fill_price (decimal.Decimal)

  • filled_at (datetime.datetime)

  • quantity (decimal.Decimal)

enum tastytrade.order.InstrumentType(value)

Bases: str, Enum

This is an Enum that contains the valid types of instruments and their representation in the API.

Member Type:

str

Valid values are as follows:

BOND = <InstrumentType.BOND: 'Bond'>
CRYPTOCURRENCY = <InstrumentType.CRYPTOCURRENCY: 'Cryptocurrency'>
CURRENCY_PAIR = <InstrumentType.CURRENCY_PAIR: 'Currency Pair'>
EQUITY = <InstrumentType.EQUITY: 'Equity'>
EQUITY_OFFERING = <InstrumentType.EQUITY_OFFERING: 'Equity Offering'>
EQUITY_OPTION = <InstrumentType.EQUITY_OPTION: 'Equity Option'>
FIXED_INCOME = <InstrumentType.FIXED_INCOME: 'Fixed Income Security'>
FUTURE = <InstrumentType.FUTURE: 'Future'>
FUTURE_OPTION = <InstrumentType.FUTURE_OPTION: 'Future Option'>
INDEX = <InstrumentType.INDEX: 'Index'>
LIQUIDITY_POOL = <InstrumentType.LIQUIDITY_POOL: 'Liquidity Pool'>
UNKNOWN = <InstrumentType.UNKNOWN: 'Unknown'>
WARRANT = <InstrumentType.WARRANT: 'Warrant'>
pydantic model tastytrade.order.Leg(*, instrument_type: InstrumentType, symbol: str, action: OrderAction, quantity: Decimal | None = None, remaining_quantity: Decimal | None = None, fills: list[tastytrade.order.FillInfo] | None = None)

Bases: TastytradeJsonDataclass

Dataclass that represents an order leg.

Classes that inherit from TradeableTastytradeJsonDataclass can call build_leg() to build a leg from the dataclass.

Show JSON schema
{
   "title": "Leg",
   "description": "Dataclass that represents an order leg.\n\nClasses that inherit from :class:`TradeableTastytradeJsonDataclass` can\ncall :meth:`build_leg` to build a leg from the dataclass.",
   "type": "object",
   "properties": {
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "action": {
         "$ref": "#/$defs/OrderAction"
      },
      "quantity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Quantity"
      },
      "remaining-quantity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Remaining-Quantity"
      },
      "fills": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/FillInfo"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Fills"
      }
   },
   "$defs": {
      "FillInfo": {
         "description": "Dataclass that contains information about an order fill.",
         "properties": {
            "fill-id": {
               "title": "Fill-Id",
               "type": "string"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "fill-price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Fill-Price"
            },
            "filled-at": {
               "format": "date-time",
               "title": "Filled-At",
               "type": "string"
            },
            "destination-venue": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Destination-Venue"
            },
            "ext-group-fill-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ext-Group-Fill-Id"
            },
            "ext-exec-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ext-Exec-Id"
            }
         },
         "required": [
            "fill-id",
            "quantity",
            "fill-price",
            "filled-at"
         ],
         "title": "FillInfo",
         "type": "object"
      },
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "OrderAction": {
         "description": "This is an :class:`~enum.Enum` that contains the valid order actions.",
         "enum": [
            "Buy to Open",
            "Buy to Close",
            "Sell to Open",
            "Sell to Close",
            "Buy",
            "Sell"
         ],
         "title": "OrderAction",
         "type": "string"
      }
   },
   "required": [
      "instrument-type",
      "symbol",
      "action"
   ]
}

Fields:
  • action (tastytrade.order.OrderAction)

  • fills (list[tastytrade.order.FillInfo] | None)

  • instrument_type (tastytrade.order.InstrumentType)

  • quantity (decimal.Decimal | None)

  • remaining_quantity (decimal.Decimal | None)

  • symbol (str)

pydantic model tastytrade.order.Message(*, code: str, message: str, preflight_id: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass that represents a message from the Tastytrade API, usually a warning or an error.

Show JSON schema
{
   "title": "Message",
   "description": "Dataclass that represents a message from the Tastytrade API, usually\na warning or an error.",
   "type": "object",
   "properties": {
      "code": {
         "title": "Code",
         "type": "string"
      },
      "message": {
         "title": "Message",
         "type": "string"
      },
      "preflight-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Preflight-Id"
      }
   },
   "required": [
      "code",
      "message"
   ]
}

Fields:
  • code (str)

  • message (str)

  • preflight_id (str | None)

pydantic model tastytrade.order.NewComplexOrder(*, orders: list[tastytrade.order.NewOrder], source: str = 'tastyware/tastytrade:v9.6', trigger_order: NewOrder | None = None, type: ComplexOrderType = ComplexOrderType.OCO)

Bases: TastytradeJsonDataclass

Dataclass containing information about a new OTOCO order. Also used for modifying existing orders.

Show JSON schema
{
   "title": "NewComplexOrder",
   "description": "Dataclass containing information about a new OTOCO order.\nAlso used for modifying existing orders.",
   "type": "object",
   "properties": {
      "orders": {
         "items": {
            "$ref": "#/$defs/NewOrder"
         },
         "title": "Orders",
         "type": "array"
      },
      "source": {
         "default": "tastyware/tastytrade:v9.6",
         "title": "Source",
         "type": "string"
      },
      "trigger-order": {
         "anyOf": [
            {
               "$ref": "#/$defs/NewOrder"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "type": {
         "$ref": "#/$defs/ComplexOrderType",
         "default": "OCO"
      }
   },
   "$defs": {
      "AdvancedInstructions": {
         "description": "Dataclass containing advanced order rules.",
         "properties": {
            "strict-position-effect-validation": {
               "default": false,
               "title": "Strict-Position-Effect-Validation",
               "type": "boolean"
            }
         },
         "title": "AdvancedInstructions",
         "type": "object"
      },
      "ComplexOrderType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid complex order types.",
         "enum": [
            "OCO",
            "OTOCO"
         ],
         "title": "ComplexOrderType",
         "type": "string"
      },
      "FillInfo": {
         "description": "Dataclass that contains information about an order fill.",
         "properties": {
            "fill-id": {
               "title": "Fill-Id",
               "type": "string"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "fill-price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Fill-Price"
            },
            "filled-at": {
               "format": "date-time",
               "title": "Filled-At",
               "type": "string"
            },
            "destination-venue": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Destination-Venue"
            },
            "ext-group-fill-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ext-Group-Fill-Id"
            },
            "ext-exec-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ext-Exec-Id"
            }
         },
         "required": [
            "fill-id",
            "quantity",
            "fill-price",
            "filled-at"
         ],
         "title": "FillInfo",
         "type": "object"
      },
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "Leg": {
         "description": "Dataclass that represents an order leg.\n\nClasses that inherit from :class:`TradeableTastytradeJsonDataclass` can\ncall :meth:`build_leg` to build a leg from the dataclass.",
         "properties": {
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "action": {
               "$ref": "#/$defs/OrderAction"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Quantity"
            },
            "remaining-quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Remaining-Quantity"
            },
            "fills": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/FillInfo"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Fills"
            }
         },
         "required": [
            "instrument-type",
            "symbol",
            "action"
         ],
         "title": "Leg",
         "type": "object"
      },
      "NewOrder": {
         "description": "Dataclass containing information about a new order. Also used for\nmodifying existing orders.",
         "properties": {
            "time-in-force": {
               "$ref": "#/$defs/OrderTimeInForce"
            },
            "order-type": {
               "$ref": "#/$defs/OrderType"
            },
            "source": {
               "default": "tastyware/tastytrade:v9.6",
               "title": "Source",
               "type": "string"
            },
            "legs": {
               "items": {
                  "$ref": "#/$defs/Leg"
               },
               "title": "Legs",
               "type": "array"
            },
            "gtc-date": {
               "anyOf": [
                  {
                     "format": "date",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Gtc-Date"
            },
            "stop-trigger": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Stop-Trigger"
            },
            "price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Price"
            },
            "value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Value"
            },
            "partition-key": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Partition-Key"
            },
            "preflight-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Preflight-Id"
            },
            "rules": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/OrderRule"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            },
            "advanced-instructions": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/AdvancedInstructions"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            }
         },
         "required": [
            "time-in-force",
            "order-type",
            "legs"
         ],
         "title": "NewOrder",
         "type": "object"
      },
      "OrderAction": {
         "description": "This is an :class:`~enum.Enum` that contains the valid order actions.",
         "enum": [
            "Buy to Open",
            "Buy to Close",
            "Sell to Open",
            "Sell to Close",
            "Buy",
            "Sell"
         ],
         "title": "OrderAction",
         "type": "string"
      },
      "OrderCondition": {
         "description": "Dataclass that represents an order condition for an order rule.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "action": {
               "title": "Action",
               "type": "string"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "indicator": {
               "title": "Indicator",
               "type": "string"
            },
            "comparator": {
               "title": "Comparator",
               "type": "string"
            },
            "threshold": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Threshold"
            },
            "is-threshold-based-on-notional": {
               "title": "Is-Threshold-Based-On-Notional",
               "type": "boolean"
            },
            "triggered-at": {
               "format": "date-time",
               "title": "Triggered-At",
               "type": "string"
            },
            "triggered-value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Triggered-Value"
            },
            "price-components": {
               "items": {
                  "$ref": "#/$defs/OrderConditionPriceComponent"
               },
               "title": "Price-Components",
               "type": "array"
            }
         },
         "required": [
            "id",
            "action",
            "symbol",
            "instrument-type",
            "indicator",
            "comparator",
            "threshold",
            "is-threshold-based-on-notional",
            "triggered-at",
            "triggered-value",
            "price-components"
         ],
         "title": "OrderCondition",
         "type": "object"
      },
      "OrderConditionPriceComponent": {
         "description": "Dataclass that represents a price component of an order condition.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "quantity-direction": {
               "title": "Quantity-Direction",
               "type": "string"
            }
         },
         "required": [
            "symbol",
            "instrument-type",
            "quantity",
            "quantity-direction"
         ],
         "title": "OrderConditionPriceComponent",
         "type": "object"
      },
      "OrderRule": {
         "description": "Dataclass that represents an order rule for a complex order.",
         "properties": {
            "route-after": {
               "format": "date-time",
               "title": "Route-After",
               "type": "string"
            },
            "routed-at": {
               "format": "date-time",
               "title": "Routed-At",
               "type": "string"
            },
            "cancel-at": {
               "format": "date-time",
               "title": "Cancel-At",
               "type": "string"
            },
            "cancelled-at": {
               "format": "date-time",
               "title": "Cancelled-At",
               "type": "string"
            },
            "order-conditions": {
               "items": {
                  "$ref": "#/$defs/OrderCondition"
               },
               "title": "Order-Conditions",
               "type": "array"
            }
         },
         "required": [
            "route-after",
            "routed-at",
            "cancel-at",
            "cancelled-at",
            "order-conditions"
         ],
         "title": "OrderRule",
         "type": "object"
      },
      "OrderTimeInForce": {
         "description": "This is an :class:`~enum.Enum` that contains the valid TIFs for orders.",
         "enum": [
            "Day",
            "GTC",
            "GTD",
            "Ext",
            "GTC Ext",
            "IOC"
         ],
         "title": "OrderTimeInForce",
         "type": "string"
      },
      "OrderType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of orders.",
         "enum": [
            "Limit",
            "Market",
            "Marketable Limit",
            "Stop",
            "Stop Limit",
            "Notional Market"
         ],
         "title": "OrderType",
         "type": "string"
      }
   },
   "required": [
      "orders"
   ]
}

Fields:
  • orders (list[tastytrade.order.NewOrder])

  • source (str)

  • trigger_order (tastytrade.order.NewOrder | None)

  • type (tastytrade.order.ComplexOrderType)

pydantic model tastytrade.order.NewOrder(*, time_in_force: OrderTimeInForce, order_type: OrderType, source: str = 'tastyware/tastytrade:v9.6', legs: list[tastytrade.order.Leg], gtc_date: date | None = None, stop_trigger: Decimal | None = None, price: Decimal | None = None, value: Decimal | None = None, partition_key: str | None = None, preflight_id: str | None = None, rules: OrderRule | None = None, advanced_instructions: AdvancedInstructions | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing information about a new order. Also used for modifying existing orders.

Show JSON schema
{
   "title": "NewOrder",
   "description": "Dataclass containing information about a new order. Also used for\nmodifying existing orders.",
   "type": "object",
   "properties": {
      "time-in-force": {
         "$ref": "#/$defs/OrderTimeInForce"
      },
      "order-type": {
         "$ref": "#/$defs/OrderType"
      },
      "source": {
         "default": "tastyware/tastytrade:v9.6",
         "title": "Source",
         "type": "string"
      },
      "legs": {
         "items": {
            "$ref": "#/$defs/Leg"
         },
         "title": "Legs",
         "type": "array"
      },
      "gtc-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Gtc-Date"
      },
      "stop-trigger": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Stop-Trigger"
      },
      "price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Price"
      },
      "value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Value"
      },
      "partition-key": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Partition-Key"
      },
      "preflight-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Preflight-Id"
      },
      "rules": {
         "anyOf": [
            {
               "$ref": "#/$defs/OrderRule"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "advanced-instructions": {
         "anyOf": [
            {
               "$ref": "#/$defs/AdvancedInstructions"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      }
   },
   "$defs": {
      "AdvancedInstructions": {
         "description": "Dataclass containing advanced order rules.",
         "properties": {
            "strict-position-effect-validation": {
               "default": false,
               "title": "Strict-Position-Effect-Validation",
               "type": "boolean"
            }
         },
         "title": "AdvancedInstructions",
         "type": "object"
      },
      "FillInfo": {
         "description": "Dataclass that contains information about an order fill.",
         "properties": {
            "fill-id": {
               "title": "Fill-Id",
               "type": "string"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "fill-price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Fill-Price"
            },
            "filled-at": {
               "format": "date-time",
               "title": "Filled-At",
               "type": "string"
            },
            "destination-venue": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Destination-Venue"
            },
            "ext-group-fill-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ext-Group-Fill-Id"
            },
            "ext-exec-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ext-Exec-Id"
            }
         },
         "required": [
            "fill-id",
            "quantity",
            "fill-price",
            "filled-at"
         ],
         "title": "FillInfo",
         "type": "object"
      },
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "Leg": {
         "description": "Dataclass that represents an order leg.\n\nClasses that inherit from :class:`TradeableTastytradeJsonDataclass` can\ncall :meth:`build_leg` to build a leg from the dataclass.",
         "properties": {
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "action": {
               "$ref": "#/$defs/OrderAction"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Quantity"
            },
            "remaining-quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Remaining-Quantity"
            },
            "fills": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/FillInfo"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Fills"
            }
         },
         "required": [
            "instrument-type",
            "symbol",
            "action"
         ],
         "title": "Leg",
         "type": "object"
      },
      "OrderAction": {
         "description": "This is an :class:`~enum.Enum` that contains the valid order actions.",
         "enum": [
            "Buy to Open",
            "Buy to Close",
            "Sell to Open",
            "Sell to Close",
            "Buy",
            "Sell"
         ],
         "title": "OrderAction",
         "type": "string"
      },
      "OrderCondition": {
         "description": "Dataclass that represents an order condition for an order rule.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "action": {
               "title": "Action",
               "type": "string"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "indicator": {
               "title": "Indicator",
               "type": "string"
            },
            "comparator": {
               "title": "Comparator",
               "type": "string"
            },
            "threshold": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Threshold"
            },
            "is-threshold-based-on-notional": {
               "title": "Is-Threshold-Based-On-Notional",
               "type": "boolean"
            },
            "triggered-at": {
               "format": "date-time",
               "title": "Triggered-At",
               "type": "string"
            },
            "triggered-value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Triggered-Value"
            },
            "price-components": {
               "items": {
                  "$ref": "#/$defs/OrderConditionPriceComponent"
               },
               "title": "Price-Components",
               "type": "array"
            }
         },
         "required": [
            "id",
            "action",
            "symbol",
            "instrument-type",
            "indicator",
            "comparator",
            "threshold",
            "is-threshold-based-on-notional",
            "triggered-at",
            "triggered-value",
            "price-components"
         ],
         "title": "OrderCondition",
         "type": "object"
      },
      "OrderConditionPriceComponent": {
         "description": "Dataclass that represents a price component of an order condition.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "quantity-direction": {
               "title": "Quantity-Direction",
               "type": "string"
            }
         },
         "required": [
            "symbol",
            "instrument-type",
            "quantity",
            "quantity-direction"
         ],
         "title": "OrderConditionPriceComponent",
         "type": "object"
      },
      "OrderRule": {
         "description": "Dataclass that represents an order rule for a complex order.",
         "properties": {
            "route-after": {
               "format": "date-time",
               "title": "Route-After",
               "type": "string"
            },
            "routed-at": {
               "format": "date-time",
               "title": "Routed-At",
               "type": "string"
            },
            "cancel-at": {
               "format": "date-time",
               "title": "Cancel-At",
               "type": "string"
            },
            "cancelled-at": {
               "format": "date-time",
               "title": "Cancelled-At",
               "type": "string"
            },
            "order-conditions": {
               "items": {
                  "$ref": "#/$defs/OrderCondition"
               },
               "title": "Order-Conditions",
               "type": "array"
            }
         },
         "required": [
            "route-after",
            "routed-at",
            "cancel-at",
            "cancelled-at",
            "order-conditions"
         ],
         "title": "OrderRule",
         "type": "object"
      },
      "OrderTimeInForce": {
         "description": "This is an :class:`~enum.Enum` that contains the valid TIFs for orders.",
         "enum": [
            "Day",
            "GTC",
            "GTD",
            "Ext",
            "GTC Ext",
            "IOC"
         ],
         "title": "OrderTimeInForce",
         "type": "string"
      },
      "OrderType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of orders.",
         "enum": [
            "Limit",
            "Market",
            "Marketable Limit",
            "Stop",
            "Stop Limit",
            "Notional Market"
         ],
         "title": "OrderType",
         "type": "string"
      }
   },
   "required": [
      "time-in-force",
      "order-type",
      "legs"
   ]
}

Fields:
field price: Decimal | None = None

The price of the order; negative = debit, positive = credit

field stop_trigger: Decimal | None = None (alias 'stop-trigger')

For a stop/stop limit order. If the latter, use price for the limit price

field value: Decimal | None = None

The actual notional value of the order. Only for notional market orders!

enum tastytrade.order.OrderAction(value)

Bases: str, Enum

This is an Enum that contains the valid order actions.

Member Type:

str

Valid values are as follows:

BUY_TO_OPEN = <OrderAction.BUY_TO_OPEN: 'Buy to Open'>
BUY_TO_CLOSE = <OrderAction.BUY_TO_CLOSE: 'Buy to Close'>
SELL_TO_OPEN = <OrderAction.SELL_TO_OPEN: 'Sell to Open'>
SELL_TO_CLOSE = <OrderAction.SELL_TO_CLOSE: 'Sell to Close'>
BUY = <OrderAction.BUY: 'Buy'>
SELL = <OrderAction.SELL: 'Sell'>
pydantic model tastytrade.order.OrderChain(*, id: int, account_number: str, description: str, underlying_symbol: str, computed_data: ComputedData, lite_nodes: list[tastytrade.order.OrderChainNode], lite_nodes_sizes: int | None = None, updated_at: datetime | None = None, created_at: datetime | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing information about an order chain: a group of orders for a specific underlying, such as total P/L, rolls, current P/L in a symbol, etc.

Show JSON schema
{
   "title": "OrderChain",
   "description": "Dataclass containing information about an order chain: a group of orders\nfor a specific underlying, such as total P/L, rolls, current P/L in a\nsymbol, etc.",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "integer"
      },
      "account-number": {
         "title": "Account-Number",
         "type": "string"
      },
      "description": {
         "title": "Description",
         "type": "string"
      },
      "underlying-symbol": {
         "title": "Underlying-Symbol",
         "type": "string"
      },
      "computed-data": {
         "$ref": "#/$defs/ComputedData"
      },
      "lite-nodes": {
         "items": {
            "$ref": "#/$defs/OrderChainNode"
         },
         "title": "Lite-Nodes",
         "type": "array"
      },
      "lite-nodes-sizes": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Lite-Nodes-Sizes"
      },
      "updated-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Updated-At"
      },
      "created-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Created-At"
      }
   },
   "$defs": {
      "ComputedData": {
         "description": "Dataclass containing computed data about an order chain.",
         "properties": {
            "open": {
               "title": "Open",
               "type": "boolean"
            },
            "updated-at": {
               "format": "date-time",
               "title": "Updated-At",
               "type": "string"
            },
            "total-fees": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Total-Fees"
            },
            "total-commissions": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Total-Commissions"
            },
            "realized-gain": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Realized-Gain"
            },
            "realized-gain-with-fees": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Realized-Gain-With-Fees"
            },
            "winner-realized-and-closed": {
               "title": "Winner-Realized-And-Closed",
               "type": "boolean"
            },
            "winner-realized": {
               "title": "Winner-Realized",
               "type": "boolean"
            },
            "winner-realized-with-fees": {
               "title": "Winner-Realized-With-Fees",
               "type": "boolean"
            },
            "roll-count": {
               "title": "Roll-Count",
               "type": "integer"
            },
            "opened-at": {
               "format": "date-time",
               "title": "Opened-At",
               "type": "string"
            },
            "last-occurred-at": {
               "format": "date-time",
               "title": "Last-Occurred-At",
               "type": "string"
            },
            "started-at-days-to-expiration": {
               "title": "Started-At-Days-To-Expiration",
               "type": "integer"
            },
            "duration": {
               "title": "Duration",
               "type": "integer"
            },
            "total-opening-cost": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Total-Opening-Cost"
            },
            "total-closing-cost": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Total-Closing-Cost"
            },
            "total-cost": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Total-Cost"
            },
            "gcd-open-quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Gcd-Open-Quantity"
            },
            "fees-missing": {
               "title": "Fees-Missing",
               "type": "boolean"
            },
            "open-entries": {
               "items": {
                  "$ref": "#/$defs/OrderChainEntry"
               },
               "title": "Open-Entries",
               "type": "array"
            },
            "total-cost-per-unit": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Total-Cost-Per-Unit"
            }
         },
         "required": [
            "open",
            "updated-at",
            "total-fees",
            "total-commissions",
            "realized-gain",
            "realized-gain-with-fees",
            "winner-realized-and-closed",
            "winner-realized",
            "winner-realized-with-fees",
            "roll-count",
            "opened-at",
            "last-occurred-at",
            "started-at-days-to-expiration",
            "duration",
            "total-opening-cost",
            "total-closing-cost",
            "total-cost",
            "gcd-open-quantity",
            "fees-missing",
            "open-entries"
         ],
         "title": "ComputedData",
         "type": "object"
      },
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "OrderAction": {
         "description": "This is an :class:`~enum.Enum` that contains the valid order actions.",
         "enum": [
            "Buy to Open",
            "Buy to Close",
            "Sell to Open",
            "Sell to Close",
            "Buy",
            "Sell"
         ],
         "title": "OrderAction",
         "type": "string"
      },
      "OrderChainEntry": {
         "description": "Dataclass containing information about a single order in an order chain.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "quantity": {
               "title": "Quantity",
               "type": "string"
            },
            "quantity-type": {
               "title": "Quantity-Type",
               "type": "string"
            },
            "quantity-numeric": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity-Numeric"
            }
         },
         "required": [
            "symbol",
            "instrument-type",
            "quantity",
            "quantity-type",
            "quantity-numeric"
         ],
         "title": "OrderChainEntry",
         "type": "object"
      },
      "OrderChainLeg": {
         "description": "Dataclass containing information about a single leg in an order\nfrom an order chain.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "action": {
               "$ref": "#/$defs/OrderAction"
            },
            "fill-quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Fill-Quantity"
            },
            "order-quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Order-Quantity"
            }
         },
         "required": [
            "symbol",
            "instrument-type",
            "action",
            "fill-quantity",
            "order-quantity"
         ],
         "title": "OrderChainLeg",
         "type": "object"
      },
      "OrderChainNode": {
         "description": "Dataclass containing information about a single node in an order chain.",
         "properties": {
            "node-type": {
               "title": "Node-Type",
               "type": "string"
            },
            "id": {
               "title": "Id",
               "type": "string"
            },
            "description": {
               "title": "Description",
               "type": "string"
            },
            "occurred-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Occurred-At"
            },
            "total-fees": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Total-Fees"
            },
            "total-fill-cost": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Total-Fill-Cost"
            },
            "gcd-quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Gcd-Quantity"
            },
            "fill-cost-per-quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Fill-Cost-Per-Quantity"
            },
            "order-fill-count": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Order-Fill-Count"
            },
            "roll": {
               "anyOf": [
                  {
                     "type": "boolean"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Roll"
            },
            "legs": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/OrderChainLeg"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Legs"
            },
            "entries": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/OrderChainEntry"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Entries"
            }
         },
         "required": [
            "node-type",
            "id",
            "description"
         ],
         "title": "OrderChainNode",
         "type": "object"
      }
   },
   "required": [
      "id",
      "account-number",
      "description",
      "underlying-symbol",
      "computed-data",
      "lite-nodes"
   ]
}

Fields:
  • account_number (str)

  • computed_data (tastytrade.order.ComputedData)

  • created_at (datetime.datetime | None)

  • description (str)

  • id (int)

  • lite_nodes (list[tastytrade.order.OrderChainNode])

  • lite_nodes_sizes (int | None)

  • underlying_symbol (str)

  • updated_at (datetime.datetime | None)

pydantic model tastytrade.order.OrderChainEntry(*, symbol: str, instrument_type: InstrumentType, quantity: str, quantity_type: str, quantity_numeric: Decimal)

Bases: TastytradeJsonDataclass

Dataclass containing information about a single order in an order chain.

Show JSON schema
{
   "title": "OrderChainEntry",
   "description": "Dataclass containing information about a single order in an order chain.",
   "type": "object",
   "properties": {
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "quantity": {
         "title": "Quantity",
         "type": "string"
      },
      "quantity-type": {
         "title": "Quantity-Type",
         "type": "string"
      },
      "quantity-numeric": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Quantity-Numeric"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      }
   },
   "required": [
      "symbol",
      "instrument-type",
      "quantity",
      "quantity-type",
      "quantity-numeric"
   ]
}

Fields:
  • instrument_type (tastytrade.order.InstrumentType)

  • quantity (str)

  • quantity_numeric (decimal.Decimal)

  • quantity_type (str)

  • symbol (str)

pydantic model tastytrade.order.OrderChainLeg(*, symbol: str, instrument_type: InstrumentType, action: OrderAction, fill_quantity: Decimal, order_quantity: Decimal)

Bases: TastytradeJsonDataclass

Dataclass containing information about a single leg in an order from an order chain.

Show JSON schema
{
   "title": "OrderChainLeg",
   "description": "Dataclass containing information about a single leg in an order\nfrom an order chain.",
   "type": "object",
   "properties": {
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "action": {
         "$ref": "#/$defs/OrderAction"
      },
      "fill-quantity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Fill-Quantity"
      },
      "order-quantity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Order-Quantity"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "OrderAction": {
         "description": "This is an :class:`~enum.Enum` that contains the valid order actions.",
         "enum": [
            "Buy to Open",
            "Buy to Close",
            "Sell to Open",
            "Sell to Close",
            "Buy",
            "Sell"
         ],
         "title": "OrderAction",
         "type": "string"
      }
   },
   "required": [
      "symbol",
      "instrument-type",
      "action",
      "fill-quantity",
      "order-quantity"
   ]
}

Fields:
  • action (tastytrade.order.OrderAction)

  • fill_quantity (decimal.Decimal)

  • instrument_type (tastytrade.order.InstrumentType)

  • order_quantity (decimal.Decimal)

  • symbol (str)

pydantic model tastytrade.order.OrderChainNode(*, node_type: str, id: str, description: str, occurred_at: datetime | None = None, total_fees: Decimal | None = None, total_fill_cost: Decimal | None = None, gcd_quantity: Decimal | None = None, fill_cost_per_quantity: Decimal | None = None, order_fill_count: int | None = None, roll: bool | None = None, legs: list[tastytrade.order.OrderChainLeg] | None = None, entries: list[tastytrade.order.OrderChainEntry] | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing information about a single node in an order chain.

Show JSON schema
{
   "title": "OrderChainNode",
   "description": "Dataclass containing information about a single node in an order chain.",
   "type": "object",
   "properties": {
      "node-type": {
         "title": "Node-Type",
         "type": "string"
      },
      "id": {
         "title": "Id",
         "type": "string"
      },
      "description": {
         "title": "Description",
         "type": "string"
      },
      "occurred-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Occurred-At"
      },
      "total-fees": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Total-Fees"
      },
      "total-fill-cost": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Total-Fill-Cost"
      },
      "gcd-quantity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Gcd-Quantity"
      },
      "fill-cost-per-quantity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Fill-Cost-Per-Quantity"
      },
      "order-fill-count": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Order-Fill-Count"
      },
      "roll": {
         "anyOf": [
            {
               "type": "boolean"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Roll"
      },
      "legs": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/OrderChainLeg"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Legs"
      },
      "entries": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/OrderChainEntry"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Entries"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "OrderAction": {
         "description": "This is an :class:`~enum.Enum` that contains the valid order actions.",
         "enum": [
            "Buy to Open",
            "Buy to Close",
            "Sell to Open",
            "Sell to Close",
            "Buy",
            "Sell"
         ],
         "title": "OrderAction",
         "type": "string"
      },
      "OrderChainEntry": {
         "description": "Dataclass containing information about a single order in an order chain.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "quantity": {
               "title": "Quantity",
               "type": "string"
            },
            "quantity-type": {
               "title": "Quantity-Type",
               "type": "string"
            },
            "quantity-numeric": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity-Numeric"
            }
         },
         "required": [
            "symbol",
            "instrument-type",
            "quantity",
            "quantity-type",
            "quantity-numeric"
         ],
         "title": "OrderChainEntry",
         "type": "object"
      },
      "OrderChainLeg": {
         "description": "Dataclass containing information about a single leg in an order\nfrom an order chain.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "action": {
               "$ref": "#/$defs/OrderAction"
            },
            "fill-quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Fill-Quantity"
            },
            "order-quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Order-Quantity"
            }
         },
         "required": [
            "symbol",
            "instrument-type",
            "action",
            "fill-quantity",
            "order-quantity"
         ],
         "title": "OrderChainLeg",
         "type": "object"
      }
   },
   "required": [
      "node-type",
      "id",
      "description"
   ]
}

Fields:
  • description (str)

  • entries (list[tastytrade.order.OrderChainEntry] | None)

  • fill_cost_per_quantity (decimal.Decimal | None)

  • gcd_quantity (decimal.Decimal | None)

  • id (str)

  • legs (list[tastytrade.order.OrderChainLeg] | None)

  • node_type (str)

  • occurred_at (datetime.datetime | None)

  • order_fill_count (int | None)

  • roll (bool | None)

  • total_fees (decimal.Decimal | None)

  • total_fill_cost (decimal.Decimal | None)

Validators:
  • validate_price_effects » all fields

pydantic model tastytrade.order.OrderCondition(*, id: str, action: str, symbol: str, instrument_type: InstrumentType, indicator: str, comparator: str, threshold: Decimal, is_threshold_based_on_notional: bool, triggered_at: datetime, triggered_value: Decimal, price_components: list[tastytrade.order.OrderConditionPriceComponent])

Bases: TastytradeJsonDataclass

Dataclass that represents an order condition for an order rule.

Show JSON schema
{
   "title": "OrderCondition",
   "description": "Dataclass that represents an order condition for an order rule.",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "string"
      },
      "action": {
         "title": "Action",
         "type": "string"
      },
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "indicator": {
         "title": "Indicator",
         "type": "string"
      },
      "comparator": {
         "title": "Comparator",
         "type": "string"
      },
      "threshold": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Threshold"
      },
      "is-threshold-based-on-notional": {
         "title": "Is-Threshold-Based-On-Notional",
         "type": "boolean"
      },
      "triggered-at": {
         "format": "date-time",
         "title": "Triggered-At",
         "type": "string"
      },
      "triggered-value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Triggered-Value"
      },
      "price-components": {
         "items": {
            "$ref": "#/$defs/OrderConditionPriceComponent"
         },
         "title": "Price-Components",
         "type": "array"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "OrderConditionPriceComponent": {
         "description": "Dataclass that represents a price component of an order condition.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "quantity-direction": {
               "title": "Quantity-Direction",
               "type": "string"
            }
         },
         "required": [
            "symbol",
            "instrument-type",
            "quantity",
            "quantity-direction"
         ],
         "title": "OrderConditionPriceComponent",
         "type": "object"
      }
   },
   "required": [
      "id",
      "action",
      "symbol",
      "instrument-type",
      "indicator",
      "comparator",
      "threshold",
      "is-threshold-based-on-notional",
      "triggered-at",
      "triggered-value",
      "price-components"
   ]
}

Fields:
  • action (str)

  • comparator (str)

  • id (str)

  • indicator (str)

  • instrument_type (tastytrade.order.InstrumentType)

  • is_threshold_based_on_notional (bool)

  • price_components (list[tastytrade.order.OrderConditionPriceComponent])

  • symbol (str)

  • threshold (decimal.Decimal)

  • triggered_at (datetime.datetime)

  • triggered_value (decimal.Decimal)

pydantic model tastytrade.order.OrderConditionPriceComponent(*, symbol: str, instrument_type: InstrumentType, quantity: Decimal, quantity_direction: str)

Bases: TastytradeJsonDataclass

Dataclass that represents a price component of an order condition.

Show JSON schema
{
   "title": "OrderConditionPriceComponent",
   "description": "Dataclass that represents a price component of an order condition.",
   "type": "object",
   "properties": {
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "quantity": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Quantity"
      },
      "quantity-direction": {
         "title": "Quantity-Direction",
         "type": "string"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      }
   },
   "required": [
      "symbol",
      "instrument-type",
      "quantity",
      "quantity-direction"
   ]
}

Fields:
  • instrument_type (tastytrade.order.InstrumentType)

  • quantity (decimal.Decimal)

  • quantity_direction (str)

  • symbol (str)

pydantic model tastytrade.order.OrderRule(*, route_after: datetime, routed_at: datetime, cancel_at: datetime, cancelled_at: datetime, order_conditions: list[tastytrade.order.OrderCondition])

Bases: TastytradeJsonDataclass

Dataclass that represents an order rule for a complex order.

Show JSON schema
{
   "title": "OrderRule",
   "description": "Dataclass that represents an order rule for a complex order.",
   "type": "object",
   "properties": {
      "route-after": {
         "format": "date-time",
         "title": "Route-After",
         "type": "string"
      },
      "routed-at": {
         "format": "date-time",
         "title": "Routed-At",
         "type": "string"
      },
      "cancel-at": {
         "format": "date-time",
         "title": "Cancel-At",
         "type": "string"
      },
      "cancelled-at": {
         "format": "date-time",
         "title": "Cancelled-At",
         "type": "string"
      },
      "order-conditions": {
         "items": {
            "$ref": "#/$defs/OrderCondition"
         },
         "title": "Order-Conditions",
         "type": "array"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "OrderCondition": {
         "description": "Dataclass that represents an order condition for an order rule.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "action": {
               "title": "Action",
               "type": "string"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "indicator": {
               "title": "Indicator",
               "type": "string"
            },
            "comparator": {
               "title": "Comparator",
               "type": "string"
            },
            "threshold": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Threshold"
            },
            "is-threshold-based-on-notional": {
               "title": "Is-Threshold-Based-On-Notional",
               "type": "boolean"
            },
            "triggered-at": {
               "format": "date-time",
               "title": "Triggered-At",
               "type": "string"
            },
            "triggered-value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Triggered-Value"
            },
            "price-components": {
               "items": {
                  "$ref": "#/$defs/OrderConditionPriceComponent"
               },
               "title": "Price-Components",
               "type": "array"
            }
         },
         "required": [
            "id",
            "action",
            "symbol",
            "instrument-type",
            "indicator",
            "comparator",
            "threshold",
            "is-threshold-based-on-notional",
            "triggered-at",
            "triggered-value",
            "price-components"
         ],
         "title": "OrderCondition",
         "type": "object"
      },
      "OrderConditionPriceComponent": {
         "description": "Dataclass that represents a price component of an order condition.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "quantity-direction": {
               "title": "Quantity-Direction",
               "type": "string"
            }
         },
         "required": [
            "symbol",
            "instrument-type",
            "quantity",
            "quantity-direction"
         ],
         "title": "OrderConditionPriceComponent",
         "type": "object"
      }
   },
   "required": [
      "route-after",
      "routed-at",
      "cancel-at",
      "cancelled-at",
      "order-conditions"
   ]
}

Fields:
  • cancel_at (datetime.datetime)

  • cancelled_at (datetime.datetime)

  • order_conditions (list[tastytrade.order.OrderCondition])

  • route_after (datetime.datetime)

  • routed_at (datetime.datetime)

enum tastytrade.order.OrderStatus(value)

Bases: str, Enum

This is an Enum that contains different order statuses. A typical (successful) order follows a progression:

RECEIVED -> LIVE -> FILLED

Member Type:

str

Valid values are as follows:

RECEIVED = <OrderStatus.RECEIVED: 'Received'>
CANCELLED = <OrderStatus.CANCELLED: 'Cancelled'>
FILLED = <OrderStatus.FILLED: 'Filled'>
EXPIRED = <OrderStatus.EXPIRED: 'Expired'>
LIVE = <OrderStatus.LIVE: 'Live'>
REJECTED = <OrderStatus.REJECTED: 'Rejected'>
CONTINGENT = <OrderStatus.CONTINGENT: 'Contingent'>
ROUTED = <OrderStatus.ROUTED: 'Routed'>
IN_FLIGHT = <OrderStatus.IN_FLIGHT: 'In Flight'>
CANCEL_REQUESTED = <OrderStatus.CANCEL_REQUESTED: 'Cancel Requested'>
REPLACE_REQUESTED = <OrderStatus.REPLACE_REQUESTED: 'Replace Requested'>
REMOVED = <OrderStatus.REMOVED: 'Removed'>
PARTIALLY_REMOVED = <OrderStatus.PARTIALLY_REMOVED: 'Partially Removed'>
enum tastytrade.order.OrderTimeInForce(value)

Bases: str, Enum

This is an Enum that contains the valid TIFs for orders.

Member Type:

str

Valid values are as follows:

DAY = <OrderTimeInForce.DAY: 'Day'>
GTC = <OrderTimeInForce.GTC: 'GTC'>
GTD = <OrderTimeInForce.GTD: 'GTD'>
EXT = <OrderTimeInForce.EXT: 'Ext'>
GTC_EXT = <OrderTimeInForce.GTC_EXT: 'GTC Ext'>
IOC = <OrderTimeInForce.IOC: 'IOC'>
enum tastytrade.order.OrderType(value)

Bases: str, Enum

This is an Enum that contains the valid types of orders.

Member Type:

str

Valid values are as follows:

LIMIT = <OrderType.LIMIT: 'Limit'>
MARKET = <OrderType.MARKET: 'Market'>
MARKETABLE_LIMIT = <OrderType.MARKETABLE_LIMIT: 'Marketable Limit'>
STOP = <OrderType.STOP: 'Stop'>
STOP_LIMIT = <OrderType.STOP_LIMIT: 'Stop Limit'>
NOTIONAL_MARKET = <OrderType.NOTIONAL_MARKET: 'Notional Market'>
pydantic model tastytrade.order.PlacedComplexOrder(*, account_number: str, type: str, orders: list[tastytrade.order.PlacedOrder], id: int = -1, trigger_order: PlacedOrder | None = None, terminal_at: str | None = None, ratio_price_threshold: Decimal | None = None, ratio_price_comparator: str | None = None, ratio_price_is_threshold_based_on_notional: bool | None = None, related_orders: list[dict[str, str]] | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing information about an already placed complex order.

Show JSON schema
{
   "title": "PlacedComplexOrder",
   "description": "Dataclass containing information about an already placed complex order.",
   "type": "object",
   "properties": {
      "account-number": {
         "title": "Account-Number",
         "type": "string"
      },
      "type": {
         "title": "Type",
         "type": "string"
      },
      "orders": {
         "items": {
            "$ref": "#/$defs/PlacedOrder"
         },
         "title": "Orders",
         "type": "array"
      },
      "id": {
         "default": -1,
         "title": "Id",
         "type": "integer"
      },
      "trigger-order": {
         "anyOf": [
            {
               "$ref": "#/$defs/PlacedOrder"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "terminal-at": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Terminal-At"
      },
      "ratio-price-threshold": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Ratio-Price-Threshold"
      },
      "ratio-price-comparator": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Ratio-Price-Comparator"
      },
      "ratio-price-is-threshold-based-on-notional": {
         "anyOf": [
            {
               "type": "boolean"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Ratio-Price-Is-Threshold-Based-On-Notional"
      },
      "related-orders": {
         "anyOf": [
            {
               "items": {
                  "additionalProperties": {
                     "type": "string"
                  },
                  "type": "object"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Related-Orders"
      }
   },
   "$defs": {
      "FillInfo": {
         "description": "Dataclass that contains information about an order fill.",
         "properties": {
            "fill-id": {
               "title": "Fill-Id",
               "type": "string"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "fill-price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Fill-Price"
            },
            "filled-at": {
               "format": "date-time",
               "title": "Filled-At",
               "type": "string"
            },
            "destination-venue": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Destination-Venue"
            },
            "ext-group-fill-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ext-Group-Fill-Id"
            },
            "ext-exec-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ext-Exec-Id"
            }
         },
         "required": [
            "fill-id",
            "quantity",
            "fill-price",
            "filled-at"
         ],
         "title": "FillInfo",
         "type": "object"
      },
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "Leg": {
         "description": "Dataclass that represents an order leg.\n\nClasses that inherit from :class:`TradeableTastytradeJsonDataclass` can\ncall :meth:`build_leg` to build a leg from the dataclass.",
         "properties": {
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "action": {
               "$ref": "#/$defs/OrderAction"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Quantity"
            },
            "remaining-quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Remaining-Quantity"
            },
            "fills": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/FillInfo"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Fills"
            }
         },
         "required": [
            "instrument-type",
            "symbol",
            "action"
         ],
         "title": "Leg",
         "type": "object"
      },
      "OrderAction": {
         "description": "This is an :class:`~enum.Enum` that contains the valid order actions.",
         "enum": [
            "Buy to Open",
            "Buy to Close",
            "Sell to Open",
            "Sell to Close",
            "Buy",
            "Sell"
         ],
         "title": "OrderAction",
         "type": "string"
      },
      "OrderCondition": {
         "description": "Dataclass that represents an order condition for an order rule.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "action": {
               "title": "Action",
               "type": "string"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "indicator": {
               "title": "Indicator",
               "type": "string"
            },
            "comparator": {
               "title": "Comparator",
               "type": "string"
            },
            "threshold": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Threshold"
            },
            "is-threshold-based-on-notional": {
               "title": "Is-Threshold-Based-On-Notional",
               "type": "boolean"
            },
            "triggered-at": {
               "format": "date-time",
               "title": "Triggered-At",
               "type": "string"
            },
            "triggered-value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Triggered-Value"
            },
            "price-components": {
               "items": {
                  "$ref": "#/$defs/OrderConditionPriceComponent"
               },
               "title": "Price-Components",
               "type": "array"
            }
         },
         "required": [
            "id",
            "action",
            "symbol",
            "instrument-type",
            "indicator",
            "comparator",
            "threshold",
            "is-threshold-based-on-notional",
            "triggered-at",
            "triggered-value",
            "price-components"
         ],
         "title": "OrderCondition",
         "type": "object"
      },
      "OrderConditionPriceComponent": {
         "description": "Dataclass that represents a price component of an order condition.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "quantity-direction": {
               "title": "Quantity-Direction",
               "type": "string"
            }
         },
         "required": [
            "symbol",
            "instrument-type",
            "quantity",
            "quantity-direction"
         ],
         "title": "OrderConditionPriceComponent",
         "type": "object"
      },
      "OrderRule": {
         "description": "Dataclass that represents an order rule for a complex order.",
         "properties": {
            "route-after": {
               "format": "date-time",
               "title": "Route-After",
               "type": "string"
            },
            "routed-at": {
               "format": "date-time",
               "title": "Routed-At",
               "type": "string"
            },
            "cancel-at": {
               "format": "date-time",
               "title": "Cancel-At",
               "type": "string"
            },
            "cancelled-at": {
               "format": "date-time",
               "title": "Cancelled-At",
               "type": "string"
            },
            "order-conditions": {
               "items": {
                  "$ref": "#/$defs/OrderCondition"
               },
               "title": "Order-Conditions",
               "type": "array"
            }
         },
         "required": [
            "route-after",
            "routed-at",
            "cancel-at",
            "cancelled-at",
            "order-conditions"
         ],
         "title": "OrderRule",
         "type": "object"
      },
      "OrderStatus": {
         "description": "This is an :class:`~enum.Enum` that contains different order statuses.\nA typical (successful) order follows a progression:\n\nRECEIVED -> LIVE -> FILLED",
         "enum": [
            "Received",
            "Cancelled",
            "Filled",
            "Expired",
            "Live",
            "Rejected",
            "Contingent",
            "Routed",
            "In Flight",
            "Cancel Requested",
            "Replace Requested",
            "Removed",
            "Partially Removed"
         ],
         "title": "OrderStatus",
         "type": "string"
      },
      "OrderTimeInForce": {
         "description": "This is an :class:`~enum.Enum` that contains the valid TIFs for orders.",
         "enum": [
            "Day",
            "GTC",
            "GTD",
            "Ext",
            "GTC Ext",
            "IOC"
         ],
         "title": "OrderTimeInForce",
         "type": "string"
      },
      "OrderType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of orders.",
         "enum": [
            "Limit",
            "Market",
            "Marketable Limit",
            "Stop",
            "Stop Limit",
            "Notional Market"
         ],
         "title": "OrderType",
         "type": "string"
      },
      "PlacedOrder": {
         "description": "Dataclass containing information about an existing order, whether it's\nbeen filled or not.",
         "properties": {
            "account-number": {
               "title": "Account-Number",
               "type": "string"
            },
            "time-in-force": {
               "$ref": "#/$defs/OrderTimeInForce"
            },
            "order-type": {
               "$ref": "#/$defs/OrderType"
            },
            "underlying-symbol": {
               "title": "Underlying-Symbol",
               "type": "string"
            },
            "underlying-instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "status": {
               "$ref": "#/$defs/OrderStatus"
            },
            "cancellable": {
               "title": "Cancellable",
               "type": "boolean"
            },
            "editable": {
               "title": "Editable",
               "type": "boolean"
            },
            "edited": {
               "title": "Edited",
               "type": "boolean"
            },
            "updated-at": {
               "format": "date-time",
               "title": "Updated-At",
               "type": "string"
            },
            "legs": {
               "items": {
                  "$ref": "#/$defs/Leg"
               },
               "title": "Legs",
               "type": "array"
            },
            "id": {
               "default": -1,
               "title": "Id",
               "type": "integer"
            },
            "size": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Size"
            },
            "price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Price"
            },
            "gtc-date": {
               "anyOf": [
                  {
                     "format": "date",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Gtc-Date"
            },
            "value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Value"
            },
            "stop-trigger": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Stop-Trigger"
            },
            "contingent-status": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Contingent-Status"
            },
            "confirmation-status": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Confirmation-Status"
            },
            "cancelled-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Cancelled-At"
            },
            "cancel-user-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Cancel-User-Id"
            },
            "cancel-username": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Cancel-Username"
            },
            "replacing-order-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Replacing-Order-Id"
            },
            "replaces-order-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Replaces-Order-Id"
            },
            "in-flight-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "In-Flight-At"
            },
            "live-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Live-At"
            },
            "received-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Received-At"
            },
            "reject-reason": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Reject-Reason"
            },
            "user-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "User-Id"
            },
            "username": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Username"
            },
            "terminal-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Terminal-At"
            },
            "complex-order-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Complex-Order-Id"
            },
            "complex-order-tag": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Complex-Order-Tag"
            },
            "preflight-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Preflight-Id"
            },
            "order-rule": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/OrderRule"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            }
         },
         "required": [
            "account-number",
            "time-in-force",
            "order-type",
            "underlying-symbol",
            "underlying-instrument-type",
            "status",
            "cancellable",
            "editable",
            "edited",
            "updated-at",
            "legs"
         ],
         "title": "PlacedOrder",
         "type": "object"
      }
   },
   "required": [
      "account-number",
      "type",
      "orders"
   ]
}

Fields:
  • account_number (str)

  • id (int)

  • orders (list[tastytrade.order.PlacedOrder])

  • ratio_price_comparator (str | None)

  • ratio_price_is_threshold_based_on_notional (bool | None)

  • ratio_price_threshold (decimal.Decimal | None)

  • related_orders (list[dict[str, str]] | None)

  • terminal_at (str | None)

  • trigger_order (tastytrade.order.PlacedOrder | None)

  • type (str)

field id: int = -1

the ID of the order; test orders placed with dry_run don’t have an ID

pydantic model tastytrade.order.PlacedComplexOrderResponse(*, buying_power_effect: BuyingPowerEffect, complex_order: PlacedComplexOrder, fee_calculation: FeeCalculation | None = None, warnings: list[tastytrade.order.Message] | None = None, errors: list[tastytrade.order.Message] | None = None)

Bases: TastytradeJsonDataclass

Dataclass grouping together information about a placed complex order.

Show JSON schema
{
   "title": "PlacedComplexOrderResponse",
   "description": "Dataclass grouping together information about a placed complex order.",
   "type": "object",
   "properties": {
      "buying-power-effect": {
         "$ref": "#/$defs/BuyingPowerEffect"
      },
      "complex-order": {
         "$ref": "#/$defs/PlacedComplexOrder"
      },
      "fee-calculation": {
         "anyOf": [
            {
               "$ref": "#/$defs/FeeCalculation"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "warnings": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/Message"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Warnings"
      },
      "errors": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/Message"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Errors"
      }
   },
   "$defs": {
      "BuyingPowerEffect": {
         "description": "Dataclass containing information about the effect of a trade on buying\npower.",
         "properties": {
            "change-in-margin-requirement": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Change-In-Margin-Requirement"
            },
            "change-in-buying-power": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Change-In-Buying-Power"
            },
            "current-buying-power": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Current-Buying-Power"
            },
            "new-buying-power": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "New-Buying-Power"
            },
            "isolated-order-margin-requirement": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Isolated-Order-Margin-Requirement"
            },
            "is-spread": {
               "title": "Is-Spread",
               "type": "boolean"
            },
            "impact": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Impact"
            },
            "effect": {
               "$ref": "#/$defs/PriceEffect"
            }
         },
         "required": [
            "change-in-margin-requirement",
            "change-in-buying-power",
            "current-buying-power",
            "new-buying-power",
            "isolated-order-margin-requirement",
            "is-spread",
            "impact",
            "effect"
         ],
         "title": "BuyingPowerEffect",
         "type": "object"
      },
      "FeeCalculation": {
         "description": "Dataclass containing information about the fees associated with a trade.",
         "properties": {
            "regulatory-fees": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Regulatory-Fees"
            },
            "clearing-fees": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Clearing-Fees"
            },
            "commission": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Commission"
            },
            "proprietary-index-option-fees": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Proprietary-Index-Option-Fees"
            },
            "total-fees": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Total-Fees"
            }
         },
         "required": [
            "regulatory-fees",
            "clearing-fees",
            "commission",
            "proprietary-index-option-fees",
            "total-fees"
         ],
         "title": "FeeCalculation",
         "type": "object"
      },
      "FillInfo": {
         "description": "Dataclass that contains information about an order fill.",
         "properties": {
            "fill-id": {
               "title": "Fill-Id",
               "type": "string"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "fill-price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Fill-Price"
            },
            "filled-at": {
               "format": "date-time",
               "title": "Filled-At",
               "type": "string"
            },
            "destination-venue": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Destination-Venue"
            },
            "ext-group-fill-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ext-Group-Fill-Id"
            },
            "ext-exec-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ext-Exec-Id"
            }
         },
         "required": [
            "fill-id",
            "quantity",
            "fill-price",
            "filled-at"
         ],
         "title": "FillInfo",
         "type": "object"
      },
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "Leg": {
         "description": "Dataclass that represents an order leg.\n\nClasses that inherit from :class:`TradeableTastytradeJsonDataclass` can\ncall :meth:`build_leg` to build a leg from the dataclass.",
         "properties": {
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "action": {
               "$ref": "#/$defs/OrderAction"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Quantity"
            },
            "remaining-quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Remaining-Quantity"
            },
            "fills": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/FillInfo"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Fills"
            }
         },
         "required": [
            "instrument-type",
            "symbol",
            "action"
         ],
         "title": "Leg",
         "type": "object"
      },
      "Message": {
         "description": "Dataclass that represents a message from the Tastytrade API, usually\na warning or an error.",
         "properties": {
            "code": {
               "title": "Code",
               "type": "string"
            },
            "message": {
               "title": "Message",
               "type": "string"
            },
            "preflight-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Preflight-Id"
            }
         },
         "required": [
            "code",
            "message"
         ],
         "title": "Message",
         "type": "object"
      },
      "OrderAction": {
         "description": "This is an :class:`~enum.Enum` that contains the valid order actions.",
         "enum": [
            "Buy to Open",
            "Buy to Close",
            "Sell to Open",
            "Sell to Close",
            "Buy",
            "Sell"
         ],
         "title": "OrderAction",
         "type": "string"
      },
      "OrderCondition": {
         "description": "Dataclass that represents an order condition for an order rule.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "action": {
               "title": "Action",
               "type": "string"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "indicator": {
               "title": "Indicator",
               "type": "string"
            },
            "comparator": {
               "title": "Comparator",
               "type": "string"
            },
            "threshold": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Threshold"
            },
            "is-threshold-based-on-notional": {
               "title": "Is-Threshold-Based-On-Notional",
               "type": "boolean"
            },
            "triggered-at": {
               "format": "date-time",
               "title": "Triggered-At",
               "type": "string"
            },
            "triggered-value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Triggered-Value"
            },
            "price-components": {
               "items": {
                  "$ref": "#/$defs/OrderConditionPriceComponent"
               },
               "title": "Price-Components",
               "type": "array"
            }
         },
         "required": [
            "id",
            "action",
            "symbol",
            "instrument-type",
            "indicator",
            "comparator",
            "threshold",
            "is-threshold-based-on-notional",
            "triggered-at",
            "triggered-value",
            "price-components"
         ],
         "title": "OrderCondition",
         "type": "object"
      },
      "OrderConditionPriceComponent": {
         "description": "Dataclass that represents a price component of an order condition.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "quantity-direction": {
               "title": "Quantity-Direction",
               "type": "string"
            }
         },
         "required": [
            "symbol",
            "instrument-type",
            "quantity",
            "quantity-direction"
         ],
         "title": "OrderConditionPriceComponent",
         "type": "object"
      },
      "OrderRule": {
         "description": "Dataclass that represents an order rule for a complex order.",
         "properties": {
            "route-after": {
               "format": "date-time",
               "title": "Route-After",
               "type": "string"
            },
            "routed-at": {
               "format": "date-time",
               "title": "Routed-At",
               "type": "string"
            },
            "cancel-at": {
               "format": "date-time",
               "title": "Cancel-At",
               "type": "string"
            },
            "cancelled-at": {
               "format": "date-time",
               "title": "Cancelled-At",
               "type": "string"
            },
            "order-conditions": {
               "items": {
                  "$ref": "#/$defs/OrderCondition"
               },
               "title": "Order-Conditions",
               "type": "array"
            }
         },
         "required": [
            "route-after",
            "routed-at",
            "cancel-at",
            "cancelled-at",
            "order-conditions"
         ],
         "title": "OrderRule",
         "type": "object"
      },
      "OrderStatus": {
         "description": "This is an :class:`~enum.Enum` that contains different order statuses.\nA typical (successful) order follows a progression:\n\nRECEIVED -> LIVE -> FILLED",
         "enum": [
            "Received",
            "Cancelled",
            "Filled",
            "Expired",
            "Live",
            "Rejected",
            "Contingent",
            "Routed",
            "In Flight",
            "Cancel Requested",
            "Replace Requested",
            "Removed",
            "Partially Removed"
         ],
         "title": "OrderStatus",
         "type": "string"
      },
      "OrderTimeInForce": {
         "description": "This is an :class:`~enum.Enum` that contains the valid TIFs for orders.",
         "enum": [
            "Day",
            "GTC",
            "GTD",
            "Ext",
            "GTC Ext",
            "IOC"
         ],
         "title": "OrderTimeInForce",
         "type": "string"
      },
      "OrderType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of orders.",
         "enum": [
            "Limit",
            "Market",
            "Marketable Limit",
            "Stop",
            "Stop Limit",
            "Notional Market"
         ],
         "title": "OrderType",
         "type": "string"
      },
      "PlacedComplexOrder": {
         "description": "Dataclass containing information about an already placed complex order.",
         "properties": {
            "account-number": {
               "title": "Account-Number",
               "type": "string"
            },
            "type": {
               "title": "Type",
               "type": "string"
            },
            "orders": {
               "items": {
                  "$ref": "#/$defs/PlacedOrder"
               },
               "title": "Orders",
               "type": "array"
            },
            "id": {
               "default": -1,
               "title": "Id",
               "type": "integer"
            },
            "trigger-order": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/PlacedOrder"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            },
            "terminal-at": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Terminal-At"
            },
            "ratio-price-threshold": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ratio-Price-Threshold"
            },
            "ratio-price-comparator": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ratio-Price-Comparator"
            },
            "ratio-price-is-threshold-based-on-notional": {
               "anyOf": [
                  {
                     "type": "boolean"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ratio-Price-Is-Threshold-Based-On-Notional"
            },
            "related-orders": {
               "anyOf": [
                  {
                     "items": {
                        "additionalProperties": {
                           "type": "string"
                        },
                        "type": "object"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Related-Orders"
            }
         },
         "required": [
            "account-number",
            "type",
            "orders"
         ],
         "title": "PlacedComplexOrder",
         "type": "object"
      },
      "PlacedOrder": {
         "description": "Dataclass containing information about an existing order, whether it's\nbeen filled or not.",
         "properties": {
            "account-number": {
               "title": "Account-Number",
               "type": "string"
            },
            "time-in-force": {
               "$ref": "#/$defs/OrderTimeInForce"
            },
            "order-type": {
               "$ref": "#/$defs/OrderType"
            },
            "underlying-symbol": {
               "title": "Underlying-Symbol",
               "type": "string"
            },
            "underlying-instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "status": {
               "$ref": "#/$defs/OrderStatus"
            },
            "cancellable": {
               "title": "Cancellable",
               "type": "boolean"
            },
            "editable": {
               "title": "Editable",
               "type": "boolean"
            },
            "edited": {
               "title": "Edited",
               "type": "boolean"
            },
            "updated-at": {
               "format": "date-time",
               "title": "Updated-At",
               "type": "string"
            },
            "legs": {
               "items": {
                  "$ref": "#/$defs/Leg"
               },
               "title": "Legs",
               "type": "array"
            },
            "id": {
               "default": -1,
               "title": "Id",
               "type": "integer"
            },
            "size": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Size"
            },
            "price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Price"
            },
            "gtc-date": {
               "anyOf": [
                  {
                     "format": "date",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Gtc-Date"
            },
            "value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Value"
            },
            "stop-trigger": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Stop-Trigger"
            },
            "contingent-status": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Contingent-Status"
            },
            "confirmation-status": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Confirmation-Status"
            },
            "cancelled-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Cancelled-At"
            },
            "cancel-user-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Cancel-User-Id"
            },
            "cancel-username": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Cancel-Username"
            },
            "replacing-order-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Replacing-Order-Id"
            },
            "replaces-order-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Replaces-Order-Id"
            },
            "in-flight-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "In-Flight-At"
            },
            "live-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Live-At"
            },
            "received-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Received-At"
            },
            "reject-reason": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Reject-Reason"
            },
            "user-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "User-Id"
            },
            "username": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Username"
            },
            "terminal-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Terminal-At"
            },
            "complex-order-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Complex-Order-Id"
            },
            "complex-order-tag": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Complex-Order-Tag"
            },
            "preflight-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Preflight-Id"
            },
            "order-rule": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/OrderRule"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            }
         },
         "required": [
            "account-number",
            "time-in-force",
            "order-type",
            "underlying-symbol",
            "underlying-instrument-type",
            "status",
            "cancellable",
            "editable",
            "edited",
            "updated-at",
            "legs"
         ],
         "title": "PlacedOrder",
         "type": "object"
      },
      "PriceEffect": {
         "description": "This is an :class:`~enum.Enum` that shows the sign of a price effect, since\nTastytrade is apparently against negative numbers.",
         "enum": [
            "Credit",
            "Debit",
            "None"
         ],
         "title": "PriceEffect",
         "type": "string"
      }
   },
   "required": [
      "buying-power-effect",
      "complex-order"
   ]
}

Fields:
  • buying_power_effect (tastytrade.order.BuyingPowerEffect)

  • complex_order (tastytrade.order.PlacedComplexOrder)

  • errors (list[tastytrade.order.Message] | None)

  • fee_calculation (tastytrade.order.FeeCalculation | None)

  • warnings (list[tastytrade.order.Message] | None)

pydantic model tastytrade.order.PlacedOrder(*, account_number: str, time_in_force: OrderTimeInForce, order_type: OrderType, underlying_symbol: str, underlying_instrument_type: InstrumentType, status: OrderStatus, cancellable: bool, editable: bool, edited: bool, updated_at: datetime, legs: list[tastytrade.order.Leg], id: int = -1, size: Decimal | None = None, price: Decimal | None = None, gtc_date: date | None = None, value: Decimal | None = None, stop_trigger: str | None = None, contingent_status: str | None = None, confirmation_status: str | None = None, cancelled_at: datetime | None = None, cancel_user_id: str | None = None, cancel_username: str | None = None, replacing_order_id: str | None = None, replaces_order_id: str | None = None, in_flight_at: datetime | None = None, live_at: datetime | None = None, received_at: datetime | None = None, reject_reason: str | None = None, user_id: str | None = None, username: str | None = None, terminal_at: datetime | None = None, complex_order_id: str | int | None = None, complex_order_tag: str | None = None, preflight_id: str | int | None = None, order_rule: OrderRule | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing information about an existing order, whether it’s been filled or not.

Show JSON schema
{
   "title": "PlacedOrder",
   "description": "Dataclass containing information about an existing order, whether it's\nbeen filled or not.",
   "type": "object",
   "properties": {
      "account-number": {
         "title": "Account-Number",
         "type": "string"
      },
      "time-in-force": {
         "$ref": "#/$defs/OrderTimeInForce"
      },
      "order-type": {
         "$ref": "#/$defs/OrderType"
      },
      "underlying-symbol": {
         "title": "Underlying-Symbol",
         "type": "string"
      },
      "underlying-instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "status": {
         "$ref": "#/$defs/OrderStatus"
      },
      "cancellable": {
         "title": "Cancellable",
         "type": "boolean"
      },
      "editable": {
         "title": "Editable",
         "type": "boolean"
      },
      "edited": {
         "title": "Edited",
         "type": "boolean"
      },
      "updated-at": {
         "format": "date-time",
         "title": "Updated-At",
         "type": "string"
      },
      "legs": {
         "items": {
            "$ref": "#/$defs/Leg"
         },
         "title": "Legs",
         "type": "array"
      },
      "id": {
         "default": -1,
         "title": "Id",
         "type": "integer"
      },
      "size": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Size"
      },
      "price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Price"
      },
      "gtc-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Gtc-Date"
      },
      "value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Value"
      },
      "stop-trigger": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Stop-Trigger"
      },
      "contingent-status": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Contingent-Status"
      },
      "confirmation-status": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Confirmation-Status"
      },
      "cancelled-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Cancelled-At"
      },
      "cancel-user-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Cancel-User-Id"
      },
      "cancel-username": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Cancel-Username"
      },
      "replacing-order-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Replacing-Order-Id"
      },
      "replaces-order-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Replaces-Order-Id"
      },
      "in-flight-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "In-Flight-At"
      },
      "live-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Live-At"
      },
      "received-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Received-At"
      },
      "reject-reason": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Reject-Reason"
      },
      "user-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "User-Id"
      },
      "username": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Username"
      },
      "terminal-at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Terminal-At"
      },
      "complex-order-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Complex-Order-Id"
      },
      "complex-order-tag": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Complex-Order-Tag"
      },
      "preflight-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Preflight-Id"
      },
      "order-rule": {
         "anyOf": [
            {
               "$ref": "#/$defs/OrderRule"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      }
   },
   "$defs": {
      "FillInfo": {
         "description": "Dataclass that contains information about an order fill.",
         "properties": {
            "fill-id": {
               "title": "Fill-Id",
               "type": "string"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "fill-price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Fill-Price"
            },
            "filled-at": {
               "format": "date-time",
               "title": "Filled-At",
               "type": "string"
            },
            "destination-venue": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Destination-Venue"
            },
            "ext-group-fill-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ext-Group-Fill-Id"
            },
            "ext-exec-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ext-Exec-Id"
            }
         },
         "required": [
            "fill-id",
            "quantity",
            "fill-price",
            "filled-at"
         ],
         "title": "FillInfo",
         "type": "object"
      },
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "Leg": {
         "description": "Dataclass that represents an order leg.\n\nClasses that inherit from :class:`TradeableTastytradeJsonDataclass` can\ncall :meth:`build_leg` to build a leg from the dataclass.",
         "properties": {
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "action": {
               "$ref": "#/$defs/OrderAction"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Quantity"
            },
            "remaining-quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Remaining-Quantity"
            },
            "fills": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/FillInfo"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Fills"
            }
         },
         "required": [
            "instrument-type",
            "symbol",
            "action"
         ],
         "title": "Leg",
         "type": "object"
      },
      "OrderAction": {
         "description": "This is an :class:`~enum.Enum` that contains the valid order actions.",
         "enum": [
            "Buy to Open",
            "Buy to Close",
            "Sell to Open",
            "Sell to Close",
            "Buy",
            "Sell"
         ],
         "title": "OrderAction",
         "type": "string"
      },
      "OrderCondition": {
         "description": "Dataclass that represents an order condition for an order rule.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "action": {
               "title": "Action",
               "type": "string"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "indicator": {
               "title": "Indicator",
               "type": "string"
            },
            "comparator": {
               "title": "Comparator",
               "type": "string"
            },
            "threshold": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Threshold"
            },
            "is-threshold-based-on-notional": {
               "title": "Is-Threshold-Based-On-Notional",
               "type": "boolean"
            },
            "triggered-at": {
               "format": "date-time",
               "title": "Triggered-At",
               "type": "string"
            },
            "triggered-value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Triggered-Value"
            },
            "price-components": {
               "items": {
                  "$ref": "#/$defs/OrderConditionPriceComponent"
               },
               "title": "Price-Components",
               "type": "array"
            }
         },
         "required": [
            "id",
            "action",
            "symbol",
            "instrument-type",
            "indicator",
            "comparator",
            "threshold",
            "is-threshold-based-on-notional",
            "triggered-at",
            "triggered-value",
            "price-components"
         ],
         "title": "OrderCondition",
         "type": "object"
      },
      "OrderConditionPriceComponent": {
         "description": "Dataclass that represents a price component of an order condition.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "quantity-direction": {
               "title": "Quantity-Direction",
               "type": "string"
            }
         },
         "required": [
            "symbol",
            "instrument-type",
            "quantity",
            "quantity-direction"
         ],
         "title": "OrderConditionPriceComponent",
         "type": "object"
      },
      "OrderRule": {
         "description": "Dataclass that represents an order rule for a complex order.",
         "properties": {
            "route-after": {
               "format": "date-time",
               "title": "Route-After",
               "type": "string"
            },
            "routed-at": {
               "format": "date-time",
               "title": "Routed-At",
               "type": "string"
            },
            "cancel-at": {
               "format": "date-time",
               "title": "Cancel-At",
               "type": "string"
            },
            "cancelled-at": {
               "format": "date-time",
               "title": "Cancelled-At",
               "type": "string"
            },
            "order-conditions": {
               "items": {
                  "$ref": "#/$defs/OrderCondition"
               },
               "title": "Order-Conditions",
               "type": "array"
            }
         },
         "required": [
            "route-after",
            "routed-at",
            "cancel-at",
            "cancelled-at",
            "order-conditions"
         ],
         "title": "OrderRule",
         "type": "object"
      },
      "OrderStatus": {
         "description": "This is an :class:`~enum.Enum` that contains different order statuses.\nA typical (successful) order follows a progression:\n\nRECEIVED -> LIVE -> FILLED",
         "enum": [
            "Received",
            "Cancelled",
            "Filled",
            "Expired",
            "Live",
            "Rejected",
            "Contingent",
            "Routed",
            "In Flight",
            "Cancel Requested",
            "Replace Requested",
            "Removed",
            "Partially Removed"
         ],
         "title": "OrderStatus",
         "type": "string"
      },
      "OrderTimeInForce": {
         "description": "This is an :class:`~enum.Enum` that contains the valid TIFs for orders.",
         "enum": [
            "Day",
            "GTC",
            "GTD",
            "Ext",
            "GTC Ext",
            "IOC"
         ],
         "title": "OrderTimeInForce",
         "type": "string"
      },
      "OrderType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of orders.",
         "enum": [
            "Limit",
            "Market",
            "Marketable Limit",
            "Stop",
            "Stop Limit",
            "Notional Market"
         ],
         "title": "OrderType",
         "type": "string"
      }
   },
   "required": [
      "account-number",
      "time-in-force",
      "order-type",
      "underlying-symbol",
      "underlying-instrument-type",
      "status",
      "cancellable",
      "editable",
      "edited",
      "updated-at",
      "legs"
   ]
}

Fields:
  • account_number (str)

  • cancel_user_id (str | None)

  • cancel_username (str | None)

  • cancellable (bool)

  • cancelled_at (datetime.datetime | None)

  • complex_order_id (str | int | None)

  • complex_order_tag (str | None)

  • confirmation_status (str | None)

  • contingent_status (str | None)

  • editable (bool)

  • edited (bool)

  • gtc_date (datetime.date | None)

  • id (int)

  • in_flight_at (datetime.datetime | None)

  • legs (list[tastytrade.order.Leg])

  • live_at (datetime.datetime | None)

  • order_rule (tastytrade.order.OrderRule | None)

  • order_type (tastytrade.order.OrderType)

  • preflight_id (str | int | None)

  • price (decimal.Decimal | None)

  • received_at (datetime.datetime | None)

  • reject_reason (str | None)

  • replaces_order_id (str | None)

  • replacing_order_id (str | None)

  • size (decimal.Decimal | None)

  • status (tastytrade.order.OrderStatus)

  • stop_trigger (str | None)

  • terminal_at (datetime.datetime | None)

  • time_in_force (tastytrade.order.OrderTimeInForce)

  • underlying_instrument_type (tastytrade.order.InstrumentType)

  • underlying_symbol (str)

  • updated_at (datetime.datetime)

  • user_id (str | None)

  • username (str | None)

  • value (decimal.Decimal | None)

Validators:
  • validate_price_effects » all fields

field id: int = -1

the ID of the order; test orders placed with dry_run don’t have an ID

Validated by:
  • validate_price_effects

pydantic model tastytrade.order.PlacedOrderResponse(*, buying_power_effect: BuyingPowerEffect, order: PlacedOrder, fee_calculation: FeeCalculation | None = None, warnings: list[tastytrade.order.Message] | None = None, errors: list[tastytrade.order.Message] | None = None)

Bases: TastytradeJsonDataclass

Dataclass grouping together information about a placed order.

Show JSON schema
{
   "title": "PlacedOrderResponse",
   "description": "Dataclass grouping together information about a placed order.",
   "type": "object",
   "properties": {
      "buying-power-effect": {
         "$ref": "#/$defs/BuyingPowerEffect"
      },
      "order": {
         "$ref": "#/$defs/PlacedOrder"
      },
      "fee-calculation": {
         "anyOf": [
            {
               "$ref": "#/$defs/FeeCalculation"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "warnings": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/Message"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Warnings"
      },
      "errors": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/Message"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Errors"
      }
   },
   "$defs": {
      "BuyingPowerEffect": {
         "description": "Dataclass containing information about the effect of a trade on buying\npower.",
         "properties": {
            "change-in-margin-requirement": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Change-In-Margin-Requirement"
            },
            "change-in-buying-power": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Change-In-Buying-Power"
            },
            "current-buying-power": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Current-Buying-Power"
            },
            "new-buying-power": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "New-Buying-Power"
            },
            "isolated-order-margin-requirement": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Isolated-Order-Margin-Requirement"
            },
            "is-spread": {
               "title": "Is-Spread",
               "type": "boolean"
            },
            "impact": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Impact"
            },
            "effect": {
               "$ref": "#/$defs/PriceEffect"
            }
         },
         "required": [
            "change-in-margin-requirement",
            "change-in-buying-power",
            "current-buying-power",
            "new-buying-power",
            "isolated-order-margin-requirement",
            "is-spread",
            "impact",
            "effect"
         ],
         "title": "BuyingPowerEffect",
         "type": "object"
      },
      "FeeCalculation": {
         "description": "Dataclass containing information about the fees associated with a trade.",
         "properties": {
            "regulatory-fees": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Regulatory-Fees"
            },
            "clearing-fees": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Clearing-Fees"
            },
            "commission": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Commission"
            },
            "proprietary-index-option-fees": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Proprietary-Index-Option-Fees"
            },
            "total-fees": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Total-Fees"
            }
         },
         "required": [
            "regulatory-fees",
            "clearing-fees",
            "commission",
            "proprietary-index-option-fees",
            "total-fees"
         ],
         "title": "FeeCalculation",
         "type": "object"
      },
      "FillInfo": {
         "description": "Dataclass that contains information about an order fill.",
         "properties": {
            "fill-id": {
               "title": "Fill-Id",
               "type": "string"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "fill-price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Fill-Price"
            },
            "filled-at": {
               "format": "date-time",
               "title": "Filled-At",
               "type": "string"
            },
            "destination-venue": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Destination-Venue"
            },
            "ext-group-fill-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ext-Group-Fill-Id"
            },
            "ext-exec-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Ext-Exec-Id"
            }
         },
         "required": [
            "fill-id",
            "quantity",
            "fill-price",
            "filled-at"
         ],
         "title": "FillInfo",
         "type": "object"
      },
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      },
      "Leg": {
         "description": "Dataclass that represents an order leg.\n\nClasses that inherit from :class:`TradeableTastytradeJsonDataclass` can\ncall :meth:`build_leg` to build a leg from the dataclass.",
         "properties": {
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "action": {
               "$ref": "#/$defs/OrderAction"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Quantity"
            },
            "remaining-quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Remaining-Quantity"
            },
            "fills": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/FillInfo"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Fills"
            }
         },
         "required": [
            "instrument-type",
            "symbol",
            "action"
         ],
         "title": "Leg",
         "type": "object"
      },
      "Message": {
         "description": "Dataclass that represents a message from the Tastytrade API, usually\na warning or an error.",
         "properties": {
            "code": {
               "title": "Code",
               "type": "string"
            },
            "message": {
               "title": "Message",
               "type": "string"
            },
            "preflight-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Preflight-Id"
            }
         },
         "required": [
            "code",
            "message"
         ],
         "title": "Message",
         "type": "object"
      },
      "OrderAction": {
         "description": "This is an :class:`~enum.Enum` that contains the valid order actions.",
         "enum": [
            "Buy to Open",
            "Buy to Close",
            "Sell to Open",
            "Sell to Close",
            "Buy",
            "Sell"
         ],
         "title": "OrderAction",
         "type": "string"
      },
      "OrderCondition": {
         "description": "Dataclass that represents an order condition for an order rule.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "action": {
               "title": "Action",
               "type": "string"
            },
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "indicator": {
               "title": "Indicator",
               "type": "string"
            },
            "comparator": {
               "title": "Comparator",
               "type": "string"
            },
            "threshold": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Threshold"
            },
            "is-threshold-based-on-notional": {
               "title": "Is-Threshold-Based-On-Notional",
               "type": "boolean"
            },
            "triggered-at": {
               "format": "date-time",
               "title": "Triggered-At",
               "type": "string"
            },
            "triggered-value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Triggered-Value"
            },
            "price-components": {
               "items": {
                  "$ref": "#/$defs/OrderConditionPriceComponent"
               },
               "title": "Price-Components",
               "type": "array"
            }
         },
         "required": [
            "id",
            "action",
            "symbol",
            "instrument-type",
            "indicator",
            "comparator",
            "threshold",
            "is-threshold-based-on-notional",
            "triggered-at",
            "triggered-value",
            "price-components"
         ],
         "title": "OrderCondition",
         "type": "object"
      },
      "OrderConditionPriceComponent": {
         "description": "Dataclass that represents a price component of an order condition.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "quantity": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  }
               ],
               "title": "Quantity"
            },
            "quantity-direction": {
               "title": "Quantity-Direction",
               "type": "string"
            }
         },
         "required": [
            "symbol",
            "instrument-type",
            "quantity",
            "quantity-direction"
         ],
         "title": "OrderConditionPriceComponent",
         "type": "object"
      },
      "OrderRule": {
         "description": "Dataclass that represents an order rule for a complex order.",
         "properties": {
            "route-after": {
               "format": "date-time",
               "title": "Route-After",
               "type": "string"
            },
            "routed-at": {
               "format": "date-time",
               "title": "Routed-At",
               "type": "string"
            },
            "cancel-at": {
               "format": "date-time",
               "title": "Cancel-At",
               "type": "string"
            },
            "cancelled-at": {
               "format": "date-time",
               "title": "Cancelled-At",
               "type": "string"
            },
            "order-conditions": {
               "items": {
                  "$ref": "#/$defs/OrderCondition"
               },
               "title": "Order-Conditions",
               "type": "array"
            }
         },
         "required": [
            "route-after",
            "routed-at",
            "cancel-at",
            "cancelled-at",
            "order-conditions"
         ],
         "title": "OrderRule",
         "type": "object"
      },
      "OrderStatus": {
         "description": "This is an :class:`~enum.Enum` that contains different order statuses.\nA typical (successful) order follows a progression:\n\nRECEIVED -> LIVE -> FILLED",
         "enum": [
            "Received",
            "Cancelled",
            "Filled",
            "Expired",
            "Live",
            "Rejected",
            "Contingent",
            "Routed",
            "In Flight",
            "Cancel Requested",
            "Replace Requested",
            "Removed",
            "Partially Removed"
         ],
         "title": "OrderStatus",
         "type": "string"
      },
      "OrderTimeInForce": {
         "description": "This is an :class:`~enum.Enum` that contains the valid TIFs for orders.",
         "enum": [
            "Day",
            "GTC",
            "GTD",
            "Ext",
            "GTC Ext",
            "IOC"
         ],
         "title": "OrderTimeInForce",
         "type": "string"
      },
      "OrderType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of orders.",
         "enum": [
            "Limit",
            "Market",
            "Marketable Limit",
            "Stop",
            "Stop Limit",
            "Notional Market"
         ],
         "title": "OrderType",
         "type": "string"
      },
      "PlacedOrder": {
         "description": "Dataclass containing information about an existing order, whether it's\nbeen filled or not.",
         "properties": {
            "account-number": {
               "title": "Account-Number",
               "type": "string"
            },
            "time-in-force": {
               "$ref": "#/$defs/OrderTimeInForce"
            },
            "order-type": {
               "$ref": "#/$defs/OrderType"
            },
            "underlying-symbol": {
               "title": "Underlying-Symbol",
               "type": "string"
            },
            "underlying-instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "status": {
               "$ref": "#/$defs/OrderStatus"
            },
            "cancellable": {
               "title": "Cancellable",
               "type": "boolean"
            },
            "editable": {
               "title": "Editable",
               "type": "boolean"
            },
            "edited": {
               "title": "Edited",
               "type": "boolean"
            },
            "updated-at": {
               "format": "date-time",
               "title": "Updated-At",
               "type": "string"
            },
            "legs": {
               "items": {
                  "$ref": "#/$defs/Leg"
               },
               "title": "Legs",
               "type": "array"
            },
            "id": {
               "default": -1,
               "title": "Id",
               "type": "integer"
            },
            "size": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Size"
            },
            "price": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Price"
            },
            "gtc-date": {
               "anyOf": [
                  {
                     "format": "date",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Gtc-Date"
            },
            "value": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Value"
            },
            "stop-trigger": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Stop-Trigger"
            },
            "contingent-status": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Contingent-Status"
            },
            "confirmation-status": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Confirmation-Status"
            },
            "cancelled-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Cancelled-At"
            },
            "cancel-user-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Cancel-User-Id"
            },
            "cancel-username": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Cancel-Username"
            },
            "replacing-order-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Replacing-Order-Id"
            },
            "replaces-order-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Replaces-Order-Id"
            },
            "in-flight-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "In-Flight-At"
            },
            "live-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Live-At"
            },
            "received-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Received-At"
            },
            "reject-reason": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Reject-Reason"
            },
            "user-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "User-Id"
            },
            "username": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Username"
            },
            "terminal-at": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Terminal-At"
            },
            "complex-order-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Complex-Order-Id"
            },
            "complex-order-tag": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Complex-Order-Tag"
            },
            "preflight-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Preflight-Id"
            },
            "order-rule": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/OrderRule"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            }
         },
         "required": [
            "account-number",
            "time-in-force",
            "order-type",
            "underlying-symbol",
            "underlying-instrument-type",
            "status",
            "cancellable",
            "editable",
            "edited",
            "updated-at",
            "legs"
         ],
         "title": "PlacedOrder",
         "type": "object"
      },
      "PriceEffect": {
         "description": "This is an :class:`~enum.Enum` that shows the sign of a price effect, since\nTastytrade is apparently against negative numbers.",
         "enum": [
            "Credit",
            "Debit",
            "None"
         ],
         "title": "PriceEffect",
         "type": "string"
      }
   },
   "required": [
      "buying-power-effect",
      "order"
   ]
}

Fields:
  • buying_power_effect (tastytrade.order.BuyingPowerEffect)

  • errors (list[tastytrade.order.Message] | None)

  • fee_calculation (tastytrade.order.FeeCalculation | None)

  • order (tastytrade.order.PlacedOrder)

  • warnings (list[tastytrade.order.Message] | None)

pydantic model tastytrade.order.TradeableTastytradeJsonDataclass(*, instrument_type: InstrumentType, symbol: str)

Bases: TastytradeJsonDataclass

Dataclass that represents a tradeable instrument.

Classes that inherit from this class can call build_leg() to build a leg from the dataclass.

Show JSON schema
{
   "title": "TradeableTastytradeJsonDataclass",
   "description": "Dataclass that represents a tradeable instrument.\n\nClasses that inherit from this class can call :meth:`build_leg` to build a\nleg from the dataclass.",
   "type": "object",
   "properties": {
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "symbol": {
         "title": "Symbol",
         "type": "string"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      }
   },
   "required": [
      "instrument-type",
      "symbol"
   ]
}

Fields:
  • instrument_type (tastytrade.order.InstrumentType)

  • symbol (str)

build_leg(quantity: Decimal, action: OrderAction) Leg

Builds an order Leg from the dataclass.

Parameters:
  • quantity – the quantity of the symbol to trade

  • actionOrderAction to perform, e.g. BUY_TO_OPEN

Returns:

a Leg object

Search

pydantic model tastytrade.search.SymbolData(*, symbol: str, description: str)

Bases: TastytradeJsonDataclass

Dataclass holding search results for an individual item.

Show JSON schema
{
   "title": "SymbolData",
   "description": "Dataclass holding search results for an individual item.",
   "type": "object",
   "properties": {
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "description": {
         "title": "Description",
         "type": "string"
      }
   },
   "required": [
      "symbol",
      "description"
   ]
}

Fields:
  • description (str)

  • symbol (str)

Performs a symbol search using the Tastytrade API and returns a list of symbols that are similar to the given search phrase.

Parameters:
  • session – active user session to use

  • symbol – search phrase

Performs a symbol search using the Tastytrade API and returns a list of symbols that are similar to the given search phrase.

Parameters:
  • session – active user session to use

  • symbol – search phrase

Session

pydantic model tastytrade.session.Address(*, city: str, country: str, is_domestic: bool, is_foreign: bool, postal_code: str, state_region: str, street_one: str, street_two: str | None = None, street_three: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing customer address information.

Show JSON schema
{
   "title": "Address",
   "description": "Dataclass containing customer address information.",
   "type": "object",
   "properties": {
      "city": {
         "title": "City",
         "type": "string"
      },
      "country": {
         "title": "Country",
         "type": "string"
      },
      "is-domestic": {
         "title": "Is-Domestic",
         "type": "boolean"
      },
      "is-foreign": {
         "title": "Is-Foreign",
         "type": "boolean"
      },
      "postal-code": {
         "title": "Postal-Code",
         "type": "string"
      },
      "state-region": {
         "title": "State-Region",
         "type": "string"
      },
      "street-one": {
         "title": "Street-One",
         "type": "string"
      },
      "street-two": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Street-Two"
      },
      "street-three": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Street-Three"
      }
   },
   "required": [
      "city",
      "country",
      "is-domestic",
      "is-foreign",
      "postal-code",
      "state-region",
      "street-one"
   ]
}

Fields:
  • city (str)

  • country (str)

  • is_domestic (bool)

  • is_foreign (bool)

  • postal_code (str)

  • state_region (str)

  • street_one (str)

  • street_three (str | None)

  • street_two (str | None)

pydantic model tastytrade.session.Customer(*, id: str, first_name: str, first_surname: str, last_name: str, address: Address, customer_suitability: CustomerSuitability, mailing_address: Address, is_foreign: bool, regulatory_domain: str, usa_citizenship_type: str, home_phone_number: str, mobile_phone_number: str, work_phone_number: str, birth_date: date, email: str, external_id: str, tax_number: str, tax_number_type: str, citizenship_country: str, agreed_to_margining: bool, subject_to_tax_withholding: bool, agreed_to_terms: bool, ext_crm_id: str, has_industry_affiliation: bool, has_listed_affiliation: bool, has_political_affiliation: bool, has_delayed_quotes: bool, has_pending_or_approved_application: bool, is_professional: bool, permitted_account_types: list[tastytrade.session.CustomerAccountType], created_at: datetime, identifiable_type: str, person: CustomerPerson, gender: str | None = None, middle_name: str | None = None, prefix_name: str | None = None, second_surname: str | None = None, suffix_name: str | None = None, foreign_tax_number: str | None = None, birth_country: str | None = None, visa_expiration_date: date | None = None, visa_type: str | None = None, signature_of_agreement: bool | None = None, desk_customer_id: str | None = None, entity: CustomerEntity | None = None, family_member_names: str | None = None, has_institutional_assets: str | None = None, industry_affiliation_firm: str | None = None, is_investment_adviser: bool | None = None, listed_affiliation_symbol: str | None = None, political_organization: str | None = None, user_id: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing customer information.

Show JSON schema
{
   "title": "Customer",
   "description": "Dataclass containing customer information.",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "string"
      },
      "first-name": {
         "title": "First-Name",
         "type": "string"
      },
      "first-surname": {
         "title": "First-Surname",
         "type": "string"
      },
      "last-name": {
         "title": "Last-Name",
         "type": "string"
      },
      "address": {
         "$ref": "#/$defs/Address"
      },
      "customer-suitability": {
         "$ref": "#/$defs/CustomerSuitability"
      },
      "mailing-address": {
         "$ref": "#/$defs/Address"
      },
      "is-foreign": {
         "title": "Is-Foreign",
         "type": "boolean"
      },
      "regulatory-domain": {
         "title": "Regulatory-Domain",
         "type": "string"
      },
      "usa-citizenship-type": {
         "title": "Usa-Citizenship-Type",
         "type": "string"
      },
      "home-phone-number": {
         "title": "Home-Phone-Number",
         "type": "string"
      },
      "mobile-phone-number": {
         "title": "Mobile-Phone-Number",
         "type": "string"
      },
      "work-phone-number": {
         "title": "Work-Phone-Number",
         "type": "string"
      },
      "birth-date": {
         "format": "date",
         "title": "Birth-Date",
         "type": "string"
      },
      "email": {
         "title": "Email",
         "type": "string"
      },
      "external-id": {
         "title": "External-Id",
         "type": "string"
      },
      "tax-number": {
         "title": "Tax-Number",
         "type": "string"
      },
      "tax-number-type": {
         "title": "Tax-Number-Type",
         "type": "string"
      },
      "citizenship-country": {
         "title": "Citizenship-Country",
         "type": "string"
      },
      "agreed-to-margining": {
         "title": "Agreed-To-Margining",
         "type": "boolean"
      },
      "subject-to-tax-withholding": {
         "title": "Subject-To-Tax-Withholding",
         "type": "boolean"
      },
      "agreed-to-terms": {
         "title": "Agreed-To-Terms",
         "type": "boolean"
      },
      "ext-crm-id": {
         "title": "Ext-Crm-Id",
         "type": "string"
      },
      "has-industry-affiliation": {
         "title": "Has-Industry-Affiliation",
         "type": "boolean"
      },
      "has-listed-affiliation": {
         "title": "Has-Listed-Affiliation",
         "type": "boolean"
      },
      "has-political-affiliation": {
         "title": "Has-Political-Affiliation",
         "type": "boolean"
      },
      "has-delayed-quotes": {
         "title": "Has-Delayed-Quotes",
         "type": "boolean"
      },
      "has-pending-or-approved-application": {
         "title": "Has-Pending-Or-Approved-Application",
         "type": "boolean"
      },
      "is-professional": {
         "title": "Is-Professional",
         "type": "boolean"
      },
      "permitted-account-types": {
         "items": {
            "$ref": "#/$defs/CustomerAccountType"
         },
         "title": "Permitted-Account-Types",
         "type": "array"
      },
      "created-at": {
         "format": "date-time",
         "title": "Created-At",
         "type": "string"
      },
      "identifiable-type": {
         "title": "Identifiable-Type",
         "type": "string"
      },
      "person": {
         "$ref": "#/$defs/CustomerPerson"
      },
      "gender": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Gender"
      },
      "middle-name": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Middle-Name"
      },
      "prefix-name": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Prefix-Name"
      },
      "second-surname": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Second-Surname"
      },
      "suffix-name": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Suffix-Name"
      },
      "foreign-tax-number": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Foreign-Tax-Number"
      },
      "birth-country": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Birth-Country"
      },
      "visa-expiration-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Visa-Expiration-Date"
      },
      "visa-type": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Visa-Type"
      },
      "signature-of-agreement": {
         "anyOf": [
            {
               "type": "boolean"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Signature-Of-Agreement"
      },
      "desk-customer-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Desk-Customer-Id"
      },
      "entity": {
         "anyOf": [
            {
               "$ref": "#/$defs/CustomerEntity"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "family-member-names": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Family-Member-Names"
      },
      "has-institutional-assets": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Has-Institutional-Assets"
      },
      "industry-affiliation-firm": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Industry-Affiliation-Firm"
      },
      "is-investment-adviser": {
         "anyOf": [
            {
               "type": "boolean"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Is-Investment-Adviser"
      },
      "listed-affiliation-symbol": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Listed-Affiliation-Symbol"
      },
      "political-organization": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Political-Organization"
      },
      "user-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "User-Id"
      }
   },
   "$defs": {
      "Address": {
         "description": "Dataclass containing customer address information.",
         "properties": {
            "city": {
               "title": "City",
               "type": "string"
            },
            "country": {
               "title": "Country",
               "type": "string"
            },
            "is-domestic": {
               "title": "Is-Domestic",
               "type": "boolean"
            },
            "is-foreign": {
               "title": "Is-Foreign",
               "type": "boolean"
            },
            "postal-code": {
               "title": "Postal-Code",
               "type": "string"
            },
            "state-region": {
               "title": "State-Region",
               "type": "string"
            },
            "street-one": {
               "title": "Street-One",
               "type": "string"
            },
            "street-two": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Street-Two"
            },
            "street-three": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Street-Three"
            }
         },
         "required": [
            "city",
            "country",
            "is-domestic",
            "is-foreign",
            "postal-code",
            "state-region",
            "street-one"
         ],
         "title": "Address",
         "type": "object"
      },
      "CustomerAccountMarginType": {
         "description": "Dataclass containing margin information for a customer account type.",
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "is-margin": {
               "title": "Is-Margin",
               "type": "boolean"
            }
         },
         "required": [
            "name",
            "is-margin"
         ],
         "title": "CustomerAccountMarginType",
         "type": "object"
      },
      "CustomerAccountType": {
         "description": "Dataclass containing information for a type of customer account.",
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "description": {
               "title": "Description",
               "type": "string"
            },
            "is-tax-advantaged": {
               "title": "Is-Tax-Advantaged",
               "type": "boolean"
            },
            "is-publicly-available": {
               "title": "Is-Publicly-Available",
               "type": "boolean"
            },
            "has-multiple-owners": {
               "title": "Has-Multiple-Owners",
               "type": "boolean"
            },
            "margin-types": {
               "items": {
                  "$ref": "#/$defs/CustomerAccountMarginType"
               },
               "title": "Margin-Types",
               "type": "array"
            }
         },
         "required": [
            "name",
            "description",
            "is-tax-advantaged",
            "is-publicly-available",
            "has-multiple-owners",
            "margin-types"
         ],
         "title": "CustomerAccountType",
         "type": "object"
      },
      "CustomerEntity": {
         "description": "Dataclass containing customer entity information.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "address": {
               "$ref": "#/$defs/Address"
            },
            "business-nature": {
               "title": "Business-Nature",
               "type": "string"
            },
            "email": {
               "title": "Email",
               "type": "string"
            },
            "entity-officers": {
               "items": {
                  "$ref": "#/$defs/EntityOfficer"
               },
               "title": "Entity-Officers",
               "type": "array"
            },
            "entity-suitability": {
               "$ref": "#/$defs/EntitySuitability"
            },
            "entity-type": {
               "title": "Entity-Type",
               "type": "string"
            },
            "foreign-institution": {
               "title": "Foreign-Institution",
               "type": "string"
            },
            "grantor-birth-date": {
               "title": "Grantor-Birth-Date",
               "type": "string"
            },
            "grantor-email": {
               "title": "Grantor-Email",
               "type": "string"
            },
            "grantor-first-name": {
               "title": "Grantor-First-Name",
               "type": "string"
            },
            "grantor-last-name": {
               "title": "Grantor-Last-Name",
               "type": "string"
            },
            "grantor-middle-name": {
               "title": "Grantor-Middle-Name",
               "type": "string"
            },
            "grantor-tax-number": {
               "title": "Grantor-Tax-Number",
               "type": "string"
            },
            "has-foreign-bank-affiliation": {
               "title": "Has-Foreign-Bank-Affiliation",
               "type": "string"
            },
            "has-foreign-institution-affiliation": {
               "title": "Has-Foreign-Institution-Affiliation",
               "type": "string"
            },
            "is-domestic": {
               "title": "Is-Domestic",
               "type": "boolean"
            },
            "legal-name": {
               "title": "Legal-Name",
               "type": "string"
            },
            "phone-number": {
               "title": "Phone-Number",
               "type": "string"
            },
            "tax-number": {
               "title": "Tax-Number",
               "type": "string"
            }
         },
         "required": [
            "id",
            "address",
            "business-nature",
            "email",
            "entity-officers",
            "entity-suitability",
            "entity-type",
            "foreign-institution",
            "grantor-birth-date",
            "grantor-email",
            "grantor-first-name",
            "grantor-last-name",
            "grantor-middle-name",
            "grantor-tax-number",
            "has-foreign-bank-affiliation",
            "has-foreign-institution-affiliation",
            "is-domestic",
            "legal-name",
            "phone-number",
            "tax-number"
         ],
         "title": "CustomerEntity",
         "type": "object"
      },
      "CustomerPerson": {
         "description": "Dataclass containing customer person information.",
         "properties": {
            "external-id": {
               "title": "External-Id",
               "type": "string"
            },
            "first-name": {
               "title": "First-Name",
               "type": "string"
            },
            "last-name": {
               "title": "Last-Name",
               "type": "string"
            },
            "citizenship-country": {
               "title": "Citizenship-Country",
               "type": "string"
            },
            "usa-citizenship-type": {
               "title": "Usa-Citizenship-Type",
               "type": "string"
            },
            "employment-status": {
               "title": "Employment-Status",
               "type": "string"
            },
            "marital-status": {
               "title": "Marital-Status",
               "type": "string"
            },
            "number-of-dependents": {
               "title": "Number-Of-Dependents",
               "type": "integer"
            },
            "occupation": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Occupation"
            },
            "middle-name": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Middle-Name"
            },
            "prefix-name": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Prefix-Name"
            },
            "suffix-name": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Suffix-Name"
            },
            "birth-country": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Birth-Country"
            },
            "birth-date": {
               "anyOf": [
                  {
                     "format": "date",
                     "type": "string"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Birth-Date"
            },
            "visa-expiration-date": {
               "anyOf": [
                  {
                     "format": "date",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Visa-Expiration-Date"
            },
            "visa-type": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Visa-Type"
            },
            "employer-name": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Employer-Name"
            },
            "job-title": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Job-Title"
            }
         },
         "required": [
            "external-id",
            "first-name",
            "last-name",
            "citizenship-country",
            "usa-citizenship-type",
            "employment-status",
            "marital-status",
            "number-of-dependents"
         ],
         "title": "CustomerPerson",
         "type": "object"
      },
      "CustomerSuitability": {
         "description": "Dataclass containing customer suitability information.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "integer"
            },
            "annual-net-income": {
               "title": "Annual-Net-Income",
               "type": "integer"
            },
            "covered-options-trading-experience": {
               "title": "Covered-Options-Trading-Experience",
               "type": "string"
            },
            "employment-status": {
               "title": "Employment-Status",
               "type": "string"
            },
            "futures-trading-experience": {
               "title": "Futures-Trading-Experience",
               "type": "string"
            },
            "liquid-net-worth": {
               "title": "Liquid-Net-Worth",
               "type": "integer"
            },
            "marital-status": {
               "title": "Marital-Status",
               "type": "string"
            },
            "net-worth": {
               "title": "Net-Worth",
               "type": "integer"
            },
            "number-of-dependents": {
               "title": "Number-Of-Dependents",
               "type": "integer"
            },
            "stock-trading-experience": {
               "title": "Stock-Trading-Experience",
               "type": "string"
            },
            "uncovered-options-trading-experience": {
               "title": "Uncovered-Options-Trading-Experience",
               "type": "string"
            },
            "customer-id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Customer-Id"
            },
            "employer-name": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Employer-Name"
            },
            "job-title": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Job-Title"
            },
            "occupation": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Occupation"
            },
            "tax-bracket": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Tax-Bracket"
            }
         },
         "required": [
            "id",
            "annual-net-income",
            "covered-options-trading-experience",
            "employment-status",
            "futures-trading-experience",
            "liquid-net-worth",
            "marital-status",
            "net-worth",
            "number-of-dependents",
            "stock-trading-experience",
            "uncovered-options-trading-experience"
         ],
         "title": "CustomerSuitability",
         "type": "object"
      },
      "EntityOfficer": {
         "description": "Dataclass containing entity officer information.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "external-id": {
               "title": "External-Id",
               "type": "string"
            },
            "first-name": {
               "title": "First-Name",
               "type": "string"
            },
            "last-name": {
               "title": "Last-Name",
               "type": "string"
            },
            "middle-name": {
               "title": "Middle-Name",
               "type": "string"
            },
            "prefix-name": {
               "title": "Prefix-Name",
               "type": "string"
            },
            "suffix-name": {
               "title": "Suffix-Name",
               "type": "string"
            },
            "address": {
               "$ref": "#/$defs/Address"
            },
            "birth-country": {
               "title": "Birth-Country",
               "type": "string"
            },
            "birth-date": {
               "format": "date",
               "title": "Birth-Date",
               "type": "string"
            },
            "citizenship-country": {
               "title": "Citizenship-Country",
               "type": "string"
            },
            "email": {
               "title": "Email",
               "type": "string"
            },
            "employer-name": {
               "title": "Employer-Name",
               "type": "string"
            },
            "employment-status": {
               "title": "Employment-Status",
               "type": "string"
            },
            "home-phone-number": {
               "title": "Home-Phone-Number",
               "type": "string"
            },
            "is-foreign": {
               "title": "Is-Foreign",
               "type": "boolean"
            },
            "job-title": {
               "title": "Job-Title",
               "type": "string"
            },
            "marital-status": {
               "title": "Marital-Status",
               "type": "string"
            },
            "mobile-phone-number": {
               "title": "Mobile-Phone-Number",
               "type": "string"
            },
            "number-of-dependents": {
               "title": "Number-Of-Dependents",
               "type": "integer"
            },
            "occupation": {
               "title": "Occupation",
               "type": "string"
            },
            "owner-of-record": {
               "title": "Owner-Of-Record",
               "type": "boolean"
            },
            "relationship-to-entity": {
               "title": "Relationship-To-Entity",
               "type": "string"
            },
            "tax-number": {
               "title": "Tax-Number",
               "type": "string"
            },
            "tax-number-type": {
               "title": "Tax-Number-Type",
               "type": "string"
            },
            "usa-citizenship-type": {
               "title": "Usa-Citizenship-Type",
               "type": "string"
            },
            "visa-expiration-date": {
               "format": "date",
               "title": "Visa-Expiration-Date",
               "type": "string"
            },
            "visa-type": {
               "title": "Visa-Type",
               "type": "string"
            },
            "work-phone-number": {
               "title": "Work-Phone-Number",
               "type": "string"
            }
         },
         "required": [
            "id",
            "external-id",
            "first-name",
            "last-name",
            "middle-name",
            "prefix-name",
            "suffix-name",
            "address",
            "birth-country",
            "birth-date",
            "citizenship-country",
            "email",
            "employer-name",
            "employment-status",
            "home-phone-number",
            "is-foreign",
            "job-title",
            "marital-status",
            "mobile-phone-number",
            "number-of-dependents",
            "occupation",
            "owner-of-record",
            "relationship-to-entity",
            "tax-number",
            "tax-number-type",
            "usa-citizenship-type",
            "visa-expiration-date",
            "visa-type",
            "work-phone-number"
         ],
         "title": "EntityOfficer",
         "type": "object"
      },
      "EntitySuitability": {
         "description": "Dataclass containing entity suitability information.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "annual-net-income": {
               "title": "Annual-Net-Income",
               "type": "integer"
            },
            "covered-options-trading-experience": {
               "title": "Covered-Options-Trading-Experience",
               "type": "string"
            },
            "entity-id": {
               "title": "Entity-Id",
               "type": "integer"
            },
            "futures-trading-experience": {
               "title": "Futures-Trading-Experience",
               "type": "string"
            },
            "liquid-net-worth": {
               "title": "Liquid-Net-Worth",
               "type": "integer"
            },
            "net-worth": {
               "title": "Net-Worth",
               "type": "integer"
            },
            "stock-trading-experience": {
               "title": "Stock-Trading-Experience",
               "type": "string"
            },
            "tax-bracket": {
               "title": "Tax-Bracket",
               "type": "string"
            },
            "uncovered-options-trading-experience": {
               "title": "Uncovered-Options-Trading-Experience",
               "type": "string"
            }
         },
         "required": [
            "id",
            "annual-net-income",
            "covered-options-trading-experience",
            "entity-id",
            "futures-trading-experience",
            "liquid-net-worth",
            "net-worth",
            "stock-trading-experience",
            "tax-bracket",
            "uncovered-options-trading-experience"
         ],
         "title": "EntitySuitability",
         "type": "object"
      }
   },
   "required": [
      "id",
      "first-name",
      "first-surname",
      "last-name",
      "address",
      "customer-suitability",
      "mailing-address",
      "is-foreign",
      "regulatory-domain",
      "usa-citizenship-type",
      "home-phone-number",
      "mobile-phone-number",
      "work-phone-number",
      "birth-date",
      "email",
      "external-id",
      "tax-number",
      "tax-number-type",
      "citizenship-country",
      "agreed-to-margining",
      "subject-to-tax-withholding",
      "agreed-to-terms",
      "ext-crm-id",
      "has-industry-affiliation",
      "has-listed-affiliation",
      "has-political-affiliation",
      "has-delayed-quotes",
      "has-pending-or-approved-application",
      "is-professional",
      "permitted-account-types",
      "created-at",
      "identifiable-type",
      "person"
   ]
}

Fields:
  • address (tastytrade.session.Address)

  • agreed_to_margining (bool)

  • agreed_to_terms (bool)

  • birth_country (str | None)

  • birth_date (datetime.date)

  • citizenship_country (str)

  • created_at (datetime.datetime)

  • customer_suitability (tastytrade.session.CustomerSuitability)

  • desk_customer_id (str | None)

  • email (str)

  • entity (tastytrade.session.CustomerEntity | None)

  • ext_crm_id (str)

  • external_id (str)

  • family_member_names (str | None)

  • first_name (str)

  • first_surname (str)

  • foreign_tax_number (str | None)

  • gender (str | None)

  • has_delayed_quotes (bool)

  • has_industry_affiliation (bool)

  • has_institutional_assets (str | None)

  • has_listed_affiliation (bool)

  • has_pending_or_approved_application (bool)

  • has_political_affiliation (bool)

  • home_phone_number (str)

  • id (str)

  • identifiable_type (str)

  • industry_affiliation_firm (str | None)

  • is_foreign (bool)

  • is_investment_adviser (bool | None)

  • is_professional (bool)

  • last_name (str)

  • listed_affiliation_symbol (str | None)

  • mailing_address (tastytrade.session.Address)

  • middle_name (str | None)

  • mobile_phone_number (str)

  • permitted_account_types (list[tastytrade.session.CustomerAccountType])

  • person (tastytrade.session.CustomerPerson)

  • political_organization (str | None)

  • prefix_name (str | None)

  • regulatory_domain (str)

  • second_surname (str | None)

  • signature_of_agreement (bool | None)

  • subject_to_tax_withholding (bool)

  • suffix_name (str | None)

  • tax_number (str)

  • tax_number_type (str)

  • usa_citizenship_type (str)

  • user_id (str | None)

  • visa_expiration_date (datetime.date | None)

  • visa_type (str | None)

  • work_phone_number (str)

pydantic model tastytrade.session.CustomerAccountMarginType(*, name: str, is_margin: bool)

Bases: TastytradeJsonDataclass

Dataclass containing margin information for a customer account type.

Show JSON schema
{
   "title": "CustomerAccountMarginType",
   "description": "Dataclass containing margin information for a customer account type.",
   "type": "object",
   "properties": {
      "name": {
         "title": "Name",
         "type": "string"
      },
      "is-margin": {
         "title": "Is-Margin",
         "type": "boolean"
      }
   },
   "required": [
      "name",
      "is-margin"
   ]
}

Fields:
  • is_margin (bool)

  • name (str)

pydantic model tastytrade.session.CustomerAccountType(*, name: str, description: str, is_tax_advantaged: bool, is_publicly_available: bool, has_multiple_owners: bool, margin_types: list[tastytrade.session.CustomerAccountMarginType])

Bases: TastytradeJsonDataclass

Dataclass containing information for a type of customer account.

Show JSON schema
{
   "title": "CustomerAccountType",
   "description": "Dataclass containing information for a type of customer account.",
   "type": "object",
   "properties": {
      "name": {
         "title": "Name",
         "type": "string"
      },
      "description": {
         "title": "Description",
         "type": "string"
      },
      "is-tax-advantaged": {
         "title": "Is-Tax-Advantaged",
         "type": "boolean"
      },
      "is-publicly-available": {
         "title": "Is-Publicly-Available",
         "type": "boolean"
      },
      "has-multiple-owners": {
         "title": "Has-Multiple-Owners",
         "type": "boolean"
      },
      "margin-types": {
         "items": {
            "$ref": "#/$defs/CustomerAccountMarginType"
         },
         "title": "Margin-Types",
         "type": "array"
      }
   },
   "$defs": {
      "CustomerAccountMarginType": {
         "description": "Dataclass containing margin information for a customer account type.",
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "is-margin": {
               "title": "Is-Margin",
               "type": "boolean"
            }
         },
         "required": [
            "name",
            "is-margin"
         ],
         "title": "CustomerAccountMarginType",
         "type": "object"
      }
   },
   "required": [
      "name",
      "description",
      "is-tax-advantaged",
      "is-publicly-available",
      "has-multiple-owners",
      "margin-types"
   ]
}

Fields:
  • description (str)

  • has_multiple_owners (bool)

  • is_publicly_available (bool)

  • is_tax_advantaged (bool)

  • margin_types (list[tastytrade.session.CustomerAccountMarginType])

  • name (str)

pydantic model tastytrade.session.CustomerEntity(*, id: str, address: Address, business_nature: str, email: str, entity_officers: list[tastytrade.session.EntityOfficer], entity_suitability: EntitySuitability, entity_type: str, foreign_institution: str, grantor_birth_date: str, grantor_email: str, grantor_first_name: str, grantor_last_name: str, grantor_middle_name: str, grantor_tax_number: str, has_foreign_bank_affiliation: str, has_foreign_institution_affiliation: str, is_domestic: bool, legal_name: str, phone_number: str, tax_number: str)

Bases: TastytradeJsonDataclass

Dataclass containing customer entity information.

Show JSON schema
{
   "title": "CustomerEntity",
   "description": "Dataclass containing customer entity information.",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "string"
      },
      "address": {
         "$ref": "#/$defs/Address"
      },
      "business-nature": {
         "title": "Business-Nature",
         "type": "string"
      },
      "email": {
         "title": "Email",
         "type": "string"
      },
      "entity-officers": {
         "items": {
            "$ref": "#/$defs/EntityOfficer"
         },
         "title": "Entity-Officers",
         "type": "array"
      },
      "entity-suitability": {
         "$ref": "#/$defs/EntitySuitability"
      },
      "entity-type": {
         "title": "Entity-Type",
         "type": "string"
      },
      "foreign-institution": {
         "title": "Foreign-Institution",
         "type": "string"
      },
      "grantor-birth-date": {
         "title": "Grantor-Birth-Date",
         "type": "string"
      },
      "grantor-email": {
         "title": "Grantor-Email",
         "type": "string"
      },
      "grantor-first-name": {
         "title": "Grantor-First-Name",
         "type": "string"
      },
      "grantor-last-name": {
         "title": "Grantor-Last-Name",
         "type": "string"
      },
      "grantor-middle-name": {
         "title": "Grantor-Middle-Name",
         "type": "string"
      },
      "grantor-tax-number": {
         "title": "Grantor-Tax-Number",
         "type": "string"
      },
      "has-foreign-bank-affiliation": {
         "title": "Has-Foreign-Bank-Affiliation",
         "type": "string"
      },
      "has-foreign-institution-affiliation": {
         "title": "Has-Foreign-Institution-Affiliation",
         "type": "string"
      },
      "is-domestic": {
         "title": "Is-Domestic",
         "type": "boolean"
      },
      "legal-name": {
         "title": "Legal-Name",
         "type": "string"
      },
      "phone-number": {
         "title": "Phone-Number",
         "type": "string"
      },
      "tax-number": {
         "title": "Tax-Number",
         "type": "string"
      }
   },
   "$defs": {
      "Address": {
         "description": "Dataclass containing customer address information.",
         "properties": {
            "city": {
               "title": "City",
               "type": "string"
            },
            "country": {
               "title": "Country",
               "type": "string"
            },
            "is-domestic": {
               "title": "Is-Domestic",
               "type": "boolean"
            },
            "is-foreign": {
               "title": "Is-Foreign",
               "type": "boolean"
            },
            "postal-code": {
               "title": "Postal-Code",
               "type": "string"
            },
            "state-region": {
               "title": "State-Region",
               "type": "string"
            },
            "street-one": {
               "title": "Street-One",
               "type": "string"
            },
            "street-two": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Street-Two"
            },
            "street-three": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Street-Three"
            }
         },
         "required": [
            "city",
            "country",
            "is-domestic",
            "is-foreign",
            "postal-code",
            "state-region",
            "street-one"
         ],
         "title": "Address",
         "type": "object"
      },
      "EntityOfficer": {
         "description": "Dataclass containing entity officer information.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "external-id": {
               "title": "External-Id",
               "type": "string"
            },
            "first-name": {
               "title": "First-Name",
               "type": "string"
            },
            "last-name": {
               "title": "Last-Name",
               "type": "string"
            },
            "middle-name": {
               "title": "Middle-Name",
               "type": "string"
            },
            "prefix-name": {
               "title": "Prefix-Name",
               "type": "string"
            },
            "suffix-name": {
               "title": "Suffix-Name",
               "type": "string"
            },
            "address": {
               "$ref": "#/$defs/Address"
            },
            "birth-country": {
               "title": "Birth-Country",
               "type": "string"
            },
            "birth-date": {
               "format": "date",
               "title": "Birth-Date",
               "type": "string"
            },
            "citizenship-country": {
               "title": "Citizenship-Country",
               "type": "string"
            },
            "email": {
               "title": "Email",
               "type": "string"
            },
            "employer-name": {
               "title": "Employer-Name",
               "type": "string"
            },
            "employment-status": {
               "title": "Employment-Status",
               "type": "string"
            },
            "home-phone-number": {
               "title": "Home-Phone-Number",
               "type": "string"
            },
            "is-foreign": {
               "title": "Is-Foreign",
               "type": "boolean"
            },
            "job-title": {
               "title": "Job-Title",
               "type": "string"
            },
            "marital-status": {
               "title": "Marital-Status",
               "type": "string"
            },
            "mobile-phone-number": {
               "title": "Mobile-Phone-Number",
               "type": "string"
            },
            "number-of-dependents": {
               "title": "Number-Of-Dependents",
               "type": "integer"
            },
            "occupation": {
               "title": "Occupation",
               "type": "string"
            },
            "owner-of-record": {
               "title": "Owner-Of-Record",
               "type": "boolean"
            },
            "relationship-to-entity": {
               "title": "Relationship-To-Entity",
               "type": "string"
            },
            "tax-number": {
               "title": "Tax-Number",
               "type": "string"
            },
            "tax-number-type": {
               "title": "Tax-Number-Type",
               "type": "string"
            },
            "usa-citizenship-type": {
               "title": "Usa-Citizenship-Type",
               "type": "string"
            },
            "visa-expiration-date": {
               "format": "date",
               "title": "Visa-Expiration-Date",
               "type": "string"
            },
            "visa-type": {
               "title": "Visa-Type",
               "type": "string"
            },
            "work-phone-number": {
               "title": "Work-Phone-Number",
               "type": "string"
            }
         },
         "required": [
            "id",
            "external-id",
            "first-name",
            "last-name",
            "middle-name",
            "prefix-name",
            "suffix-name",
            "address",
            "birth-country",
            "birth-date",
            "citizenship-country",
            "email",
            "employer-name",
            "employment-status",
            "home-phone-number",
            "is-foreign",
            "job-title",
            "marital-status",
            "mobile-phone-number",
            "number-of-dependents",
            "occupation",
            "owner-of-record",
            "relationship-to-entity",
            "tax-number",
            "tax-number-type",
            "usa-citizenship-type",
            "visa-expiration-date",
            "visa-type",
            "work-phone-number"
         ],
         "title": "EntityOfficer",
         "type": "object"
      },
      "EntitySuitability": {
         "description": "Dataclass containing entity suitability information.",
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "annual-net-income": {
               "title": "Annual-Net-Income",
               "type": "integer"
            },
            "covered-options-trading-experience": {
               "title": "Covered-Options-Trading-Experience",
               "type": "string"
            },
            "entity-id": {
               "title": "Entity-Id",
               "type": "integer"
            },
            "futures-trading-experience": {
               "title": "Futures-Trading-Experience",
               "type": "string"
            },
            "liquid-net-worth": {
               "title": "Liquid-Net-Worth",
               "type": "integer"
            },
            "net-worth": {
               "title": "Net-Worth",
               "type": "integer"
            },
            "stock-trading-experience": {
               "title": "Stock-Trading-Experience",
               "type": "string"
            },
            "tax-bracket": {
               "title": "Tax-Bracket",
               "type": "string"
            },
            "uncovered-options-trading-experience": {
               "title": "Uncovered-Options-Trading-Experience",
               "type": "string"
            }
         },
         "required": [
            "id",
            "annual-net-income",
            "covered-options-trading-experience",
            "entity-id",
            "futures-trading-experience",
            "liquid-net-worth",
            "net-worth",
            "stock-trading-experience",
            "tax-bracket",
            "uncovered-options-trading-experience"
         ],
         "title": "EntitySuitability",
         "type": "object"
      }
   },
   "required": [
      "id",
      "address",
      "business-nature",
      "email",
      "entity-officers",
      "entity-suitability",
      "entity-type",
      "foreign-institution",
      "grantor-birth-date",
      "grantor-email",
      "grantor-first-name",
      "grantor-last-name",
      "grantor-middle-name",
      "grantor-tax-number",
      "has-foreign-bank-affiliation",
      "has-foreign-institution-affiliation",
      "is-domestic",
      "legal-name",
      "phone-number",
      "tax-number"
   ]
}

Fields:
  • address (tastytrade.session.Address)

  • business_nature (str)

  • email (str)

  • entity_officers (list[tastytrade.session.EntityOfficer])

  • entity_suitability (tastytrade.session.EntitySuitability)

  • entity_type (str)

  • foreign_institution (str)

  • grantor_birth_date (str)

  • grantor_email (str)

  • grantor_first_name (str)

  • grantor_last_name (str)

  • grantor_middle_name (str)

  • grantor_tax_number (str)

  • has_foreign_bank_affiliation (str)

  • has_foreign_institution_affiliation (str)

  • id (str)

  • is_domestic (bool)

  • legal_name (str)

  • phone_number (str)

  • tax_number (str)

pydantic model tastytrade.session.CustomerPerson(*, external_id: str, first_name: str, last_name: str, citizenship_country: str, usa_citizenship_type: str, employment_status: str, marital_status: str, number_of_dependents: int, occupation: str | None = None, middle_name: str | None = None, prefix_name: str | None = None, suffix_name: str | None = None, birth_country: str | None = None, birth_date: date | str | None = None, visa_expiration_date: date | None = None, visa_type: str | None = None, employer_name: str | None = None, job_title: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing customer person information.

Show JSON schema
{
   "title": "CustomerPerson",
   "description": "Dataclass containing customer person information.",
   "type": "object",
   "properties": {
      "external-id": {
         "title": "External-Id",
         "type": "string"
      },
      "first-name": {
         "title": "First-Name",
         "type": "string"
      },
      "last-name": {
         "title": "Last-Name",
         "type": "string"
      },
      "citizenship-country": {
         "title": "Citizenship-Country",
         "type": "string"
      },
      "usa-citizenship-type": {
         "title": "Usa-Citizenship-Type",
         "type": "string"
      },
      "employment-status": {
         "title": "Employment-Status",
         "type": "string"
      },
      "marital-status": {
         "title": "Marital-Status",
         "type": "string"
      },
      "number-of-dependents": {
         "title": "Number-Of-Dependents",
         "type": "integer"
      },
      "occupation": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Occupation"
      },
      "middle-name": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Middle-Name"
      },
      "prefix-name": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Prefix-Name"
      },
      "suffix-name": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Suffix-Name"
      },
      "birth-country": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Birth-Country"
      },
      "birth-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Birth-Date"
      },
      "visa-expiration-date": {
         "anyOf": [
            {
               "format": "date",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Visa-Expiration-Date"
      },
      "visa-type": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Visa-Type"
      },
      "employer-name": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Employer-Name"
      },
      "job-title": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Job-Title"
      }
   },
   "required": [
      "external-id",
      "first-name",
      "last-name",
      "citizenship-country",
      "usa-citizenship-type",
      "employment-status",
      "marital-status",
      "number-of-dependents"
   ]
}

Fields:
  • birth_country (str | None)

  • birth_date (datetime.date | str | None)

  • citizenship_country (str)

  • employer_name (str | None)

  • employment_status (str)

  • external_id (str)

  • first_name (str)

  • job_title (str | None)

  • last_name (str)

  • marital_status (str)

  • middle_name (str | None)

  • number_of_dependents (int)

  • occupation (str | None)

  • prefix_name (str | None)

  • suffix_name (str | None)

  • usa_citizenship_type (str)

  • visa_expiration_date (datetime.date | None)

  • visa_type (str | None)

pydantic model tastytrade.session.CustomerSuitability(*, id: int, annual_net_income: int, covered_options_trading_experience: str, employment_status: str, futures_trading_experience: str, liquid_net_worth: int, marital_status: str, net_worth: int, number_of_dependents: int, stock_trading_experience: str, uncovered_options_trading_experience: str, customer_id: str | None = None, employer_name: str | None = None, job_title: str | None = None, occupation: str | None = None, tax_bracket: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing customer suitability information.

Show JSON schema
{
   "title": "CustomerSuitability",
   "description": "Dataclass containing customer suitability information.",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "integer"
      },
      "annual-net-income": {
         "title": "Annual-Net-Income",
         "type": "integer"
      },
      "covered-options-trading-experience": {
         "title": "Covered-Options-Trading-Experience",
         "type": "string"
      },
      "employment-status": {
         "title": "Employment-Status",
         "type": "string"
      },
      "futures-trading-experience": {
         "title": "Futures-Trading-Experience",
         "type": "string"
      },
      "liquid-net-worth": {
         "title": "Liquid-Net-Worth",
         "type": "integer"
      },
      "marital-status": {
         "title": "Marital-Status",
         "type": "string"
      },
      "net-worth": {
         "title": "Net-Worth",
         "type": "integer"
      },
      "number-of-dependents": {
         "title": "Number-Of-Dependents",
         "type": "integer"
      },
      "stock-trading-experience": {
         "title": "Stock-Trading-Experience",
         "type": "string"
      },
      "uncovered-options-trading-experience": {
         "title": "Uncovered-Options-Trading-Experience",
         "type": "string"
      },
      "customer-id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Customer-Id"
      },
      "employer-name": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Employer-Name"
      },
      "job-title": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Job-Title"
      },
      "occupation": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Occupation"
      },
      "tax-bracket": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Tax-Bracket"
      }
   },
   "required": [
      "id",
      "annual-net-income",
      "covered-options-trading-experience",
      "employment-status",
      "futures-trading-experience",
      "liquid-net-worth",
      "marital-status",
      "net-worth",
      "number-of-dependents",
      "stock-trading-experience",
      "uncovered-options-trading-experience"
   ]
}

Fields:
  • annual_net_income (int)

  • covered_options_trading_experience (str)

  • customer_id (str | None)

  • employer_name (str | None)

  • employment_status (str)

  • futures_trading_experience (str)

  • id (int)

  • job_title (str | None)

  • liquid_net_worth (int)

  • marital_status (str)

  • net_worth (int)

  • number_of_dependents (int)

  • occupation (str | None)

  • stock_trading_experience (str)

  • tax_bracket (str | None)

  • uncovered_options_trading_experience (str)

pydantic model tastytrade.session.EntityOfficer(*, id: str, external_id: str, first_name: str, last_name: str, middle_name: str, prefix_name: str, suffix_name: str, address: Address, birth_country: str, birth_date: date, citizenship_country: str, email: str, employer_name: str, employment_status: str, home_phone_number: str, is_foreign: bool, job_title: str, marital_status: str, mobile_phone_number: str, number_of_dependents: int, occupation: str, owner_of_record: bool, relationship_to_entity: str, tax_number: str, tax_number_type: str, usa_citizenship_type: str, visa_expiration_date: date, visa_type: str, work_phone_number: str)

Bases: TastytradeJsonDataclass

Dataclass containing entity officer information.

Show JSON schema
{
   "title": "EntityOfficer",
   "description": "Dataclass containing entity officer information.",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "string"
      },
      "external-id": {
         "title": "External-Id",
         "type": "string"
      },
      "first-name": {
         "title": "First-Name",
         "type": "string"
      },
      "last-name": {
         "title": "Last-Name",
         "type": "string"
      },
      "middle-name": {
         "title": "Middle-Name",
         "type": "string"
      },
      "prefix-name": {
         "title": "Prefix-Name",
         "type": "string"
      },
      "suffix-name": {
         "title": "Suffix-Name",
         "type": "string"
      },
      "address": {
         "$ref": "#/$defs/Address"
      },
      "birth-country": {
         "title": "Birth-Country",
         "type": "string"
      },
      "birth-date": {
         "format": "date",
         "title": "Birth-Date",
         "type": "string"
      },
      "citizenship-country": {
         "title": "Citizenship-Country",
         "type": "string"
      },
      "email": {
         "title": "Email",
         "type": "string"
      },
      "employer-name": {
         "title": "Employer-Name",
         "type": "string"
      },
      "employment-status": {
         "title": "Employment-Status",
         "type": "string"
      },
      "home-phone-number": {
         "title": "Home-Phone-Number",
         "type": "string"
      },
      "is-foreign": {
         "title": "Is-Foreign",
         "type": "boolean"
      },
      "job-title": {
         "title": "Job-Title",
         "type": "string"
      },
      "marital-status": {
         "title": "Marital-Status",
         "type": "string"
      },
      "mobile-phone-number": {
         "title": "Mobile-Phone-Number",
         "type": "string"
      },
      "number-of-dependents": {
         "title": "Number-Of-Dependents",
         "type": "integer"
      },
      "occupation": {
         "title": "Occupation",
         "type": "string"
      },
      "owner-of-record": {
         "title": "Owner-Of-Record",
         "type": "boolean"
      },
      "relationship-to-entity": {
         "title": "Relationship-To-Entity",
         "type": "string"
      },
      "tax-number": {
         "title": "Tax-Number",
         "type": "string"
      },
      "tax-number-type": {
         "title": "Tax-Number-Type",
         "type": "string"
      },
      "usa-citizenship-type": {
         "title": "Usa-Citizenship-Type",
         "type": "string"
      },
      "visa-expiration-date": {
         "format": "date",
         "title": "Visa-Expiration-Date",
         "type": "string"
      },
      "visa-type": {
         "title": "Visa-Type",
         "type": "string"
      },
      "work-phone-number": {
         "title": "Work-Phone-Number",
         "type": "string"
      }
   },
   "$defs": {
      "Address": {
         "description": "Dataclass containing customer address information.",
         "properties": {
            "city": {
               "title": "City",
               "type": "string"
            },
            "country": {
               "title": "Country",
               "type": "string"
            },
            "is-domestic": {
               "title": "Is-Domestic",
               "type": "boolean"
            },
            "is-foreign": {
               "title": "Is-Foreign",
               "type": "boolean"
            },
            "postal-code": {
               "title": "Postal-Code",
               "type": "string"
            },
            "state-region": {
               "title": "State-Region",
               "type": "string"
            },
            "street-one": {
               "title": "Street-One",
               "type": "string"
            },
            "street-two": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Street-Two"
            },
            "street-three": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Street-Three"
            }
         },
         "required": [
            "city",
            "country",
            "is-domestic",
            "is-foreign",
            "postal-code",
            "state-region",
            "street-one"
         ],
         "title": "Address",
         "type": "object"
      }
   },
   "required": [
      "id",
      "external-id",
      "first-name",
      "last-name",
      "middle-name",
      "prefix-name",
      "suffix-name",
      "address",
      "birth-country",
      "birth-date",
      "citizenship-country",
      "email",
      "employer-name",
      "employment-status",
      "home-phone-number",
      "is-foreign",
      "job-title",
      "marital-status",
      "mobile-phone-number",
      "number-of-dependents",
      "occupation",
      "owner-of-record",
      "relationship-to-entity",
      "tax-number",
      "tax-number-type",
      "usa-citizenship-type",
      "visa-expiration-date",
      "visa-type",
      "work-phone-number"
   ]
}

Fields:
  • address (tastytrade.session.Address)

  • birth_country (str)

  • birth_date (datetime.date)

  • citizenship_country (str)

  • email (str)

  • employer_name (str)

  • employment_status (str)

  • external_id (str)

  • first_name (str)

  • home_phone_number (str)

  • id (str)

  • is_foreign (bool)

  • job_title (str)

  • last_name (str)

  • marital_status (str)

  • middle_name (str)

  • mobile_phone_number (str)

  • number_of_dependents (int)

  • occupation (str)

  • owner_of_record (bool)

  • prefix_name (str)

  • relationship_to_entity (str)

  • suffix_name (str)

  • tax_number (str)

  • tax_number_type (str)

  • usa_citizenship_type (str)

  • visa_expiration_date (datetime.date)

  • visa_type (str)

  • work_phone_number (str)

pydantic model tastytrade.session.EntitySuitability(*, id: str, annual_net_income: int, covered_options_trading_experience: str, entity_id: int, futures_trading_experience: str, liquid_net_worth: int, net_worth: int, stock_trading_experience: str, tax_bracket: str, uncovered_options_trading_experience: str)

Bases: TastytradeJsonDataclass

Dataclass containing entity suitability information.

Show JSON schema
{
   "title": "EntitySuitability",
   "description": "Dataclass containing entity suitability information.",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "string"
      },
      "annual-net-income": {
         "title": "Annual-Net-Income",
         "type": "integer"
      },
      "covered-options-trading-experience": {
         "title": "Covered-Options-Trading-Experience",
         "type": "string"
      },
      "entity-id": {
         "title": "Entity-Id",
         "type": "integer"
      },
      "futures-trading-experience": {
         "title": "Futures-Trading-Experience",
         "type": "string"
      },
      "liquid-net-worth": {
         "title": "Liquid-Net-Worth",
         "type": "integer"
      },
      "net-worth": {
         "title": "Net-Worth",
         "type": "integer"
      },
      "stock-trading-experience": {
         "title": "Stock-Trading-Experience",
         "type": "string"
      },
      "tax-bracket": {
         "title": "Tax-Bracket",
         "type": "string"
      },
      "uncovered-options-trading-experience": {
         "title": "Uncovered-Options-Trading-Experience",
         "type": "string"
      }
   },
   "required": [
      "id",
      "annual-net-income",
      "covered-options-trading-experience",
      "entity-id",
      "futures-trading-experience",
      "liquid-net-worth",
      "net-worth",
      "stock-trading-experience",
      "tax-bracket",
      "uncovered-options-trading-experience"
   ]
}

Fields:
  • annual_net_income (int)

  • covered_options_trading_experience (str)

  • entity_id (int)

  • futures_trading_experience (str)

  • id (str)

  • liquid_net_worth (int)

  • net_worth (int)

  • stock_trading_experience (str)

  • tax_bracket (str)

  • uncovered_options_trading_experience (str)

class tastytrade.session.Session(login: str, password: str | None = None, remember_me: bool = False, remember_token: str | None = None, is_test: bool = False, two_factor_authentication: str | None = None, dxfeed_tos_compliant: bool = False)

Bases: object

Contains a local user login which can then be used to interact with the remote API.

Parameters:
  • login – tastytrade username or email

  • remember_me – whether or not to create a remember token to use instead of a password

  • password – tastytrade password to login; if absent, remember token is required

  • remember_token – previously generated token; if absent, password is required

  • is_test – whether to use the test API endpoints, default False

  • two_factor_authentication – if two factor authentication is enabled, this is the code sent to the user’s device

  • dxfeed_tos_compliant – whether to use the dxfeed TOS-compliant API endpoint for the streamer

async a_destroy() None

Sends a API request to log out of the existing session. This will invalidate the current session token and login.

async a_get_2fa_info() TwoFactorInfo

Gets the 2FA info for the current user.

async a_get_customer() Customer

Gets the customer dict from the API.

Returns:

a Tastytrade ‘Customer’ object in JSON format.

async a_validate() bool

Validates the current session by sending a request to the API.

Returns:

True if the session is valid and False otherwise.

async_client

httpx client for async requests

destroy() None

Sends a API request to log out of the existing session. This will invalidate the current session token and login.

URL for dxfeed websocket

get_2fa_info() TwoFactorInfo

Gets the 2FA info for the current user.

get_customer() Customer

Gets the customer dict from the API.

Returns:

a Tastytrade ‘Customer’ object in JSON format.

is_test

Whether this is a cert or real session

remember_token

A single-use token which can be used to login without a password

session_token

The session token used to authenticate requests

streamer_token

Auth token for dxfeed websocket

sync_client

httpx client for sync requests

user

The user dict returned by the API; contains basic user information

validate() bool

Validates the current session by sending a request to the API.

Returns:

True if the session is valid and False otherwise.

pydantic model tastytrade.session.TwoFactorInfo(*, is_active: bool, type: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing information about two-factor authentication.

Show JSON schema
{
   "title": "TwoFactorInfo",
   "description": "Dataclass containing information about two-factor authentication.",
   "type": "object",
   "properties": {
      "is-active": {
         "title": "Is-Active",
         "type": "boolean"
      },
      "type": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Type"
      }
   },
   "required": [
      "is-active"
   ]
}

Fields:
  • is_active (bool)

  • type (str | None)

pydantic model tastytrade.session.User(*, email: str, external_id: str, is_confirmed: bool, username: str, name: str | None = None, nickname: str | None = None)

Bases: TastytradeJsonDataclass

Dataclass containing information about a Tastytrade user.

Show JSON schema
{
   "title": "User",
   "description": "Dataclass containing information about a Tastytrade user.",
   "type": "object",
   "properties": {
      "email": {
         "title": "Email",
         "type": "string"
      },
      "external-id": {
         "title": "External-Id",
         "type": "string"
      },
      "is-confirmed": {
         "title": "Is-Confirmed",
         "type": "boolean"
      },
      "username": {
         "title": "Username",
         "type": "string"
      },
      "name": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Name"
      },
      "nickname": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Nickname"
      }
   },
   "required": [
      "email",
      "external-id",
      "is-confirmed",
      "username"
   ]
}

Fields:
  • email (str)

  • external_id (str)

  • is_confirmed (bool)

  • name (str | None)

  • nickname (str | None)

  • username (str)

Streamer

class tastytrade.streamer.AlertStreamer(session: Session, reconnect_args: tuple[Any, ...] = (), reconnect_fn: Callable[[...], Coroutine[Any, Any, None]] | None = None)

Bases: object

Used to subscribe to account-level updates (balances, orders, positions), public watchlist updates, quote alerts, and user-level messages. It should always be initialized as an async context manager, or by awaiting it, since the object cannot be fully instantiated without async.

Example usage:

from tastytrade import Account, AlertStreamer
from tastytrade.order import PlacedOrder

async with AlertStreamer(session) as streamer:
    accounts = Account.get_accounts(session)

    # updates to balances, orders, and positions
    await streamer.subscribe_accounts(accounts)
    # changes in public watchlists
    await streamer.subscribe_public_watchlists()
    # quote alerts configured by the user
    await streamer.subscribe_quote_alerts()

    async for order in streamer.listen(PlacedOrder):
        print(order)

Or:

streamer = await AlertStreamer(session)
base_url: str

The base url for the streamer websocket

async close() None

Closes the websocket connection and cancels the pending tasks.

async listen(alert_class: Type[T]) AsyncIterator[T]

Iterate over non-heartbeat messages received from the streamer, mapping them to their appropriate data class and yielding them.

This is designed to be friendly for type checking; the return type will be the same class you pass in.

Parameters:

alert_class – the type of alert to listen for, should be of AlertType

reconnect_args

Variable number of arguments to pass to the reconnect function

reconnect_fn

An async function to be called upon reconnection. The first argument must be of type AlertStreamer and will be a reference to the streamer object.

async subscribe_accounts(accounts: list[tastytrade.account.Account]) None

Subscribes to account-level updates (balances, orders, positions).

Parameters:

accounts – list of Account to subscribe to updates for

async subscribe_public_watchlists() None

Subscribes to public watchlist updates.

async subscribe_quote_alerts() None

Subscribes to quote alerts (which are configured at a user level).

async subscribe_user_messages(session: Session) None

Subscribes to user-level messages, e.g. new account creation.

token: str

The active session used to initiate the streamer or make requests

tastytrade.streamer.AlertType

List of all possible types to stream with the alert streamer

alias of Union[AccountBalance, PlacedComplexOrder, PlacedOrder, OrderChain, CurrentPosition, QuoteAlert, TradingStatus, UnderlyingYearGainSummary, Watchlist]

class tastytrade.streamer.DXLinkStreamer(session: ~tastytrade.session.Session, reconnect_args: tuple[typing.Any, ...] = (), reconnect_fn: ~typing.Callable[[...], ~typing.Coroutine[~typing.Any, ~typing.Any, None]] | None = None, ssl_context: ~ssl.SSLContext = <ssl.SSLContext object>)

Bases: object

A DXLinkStreamer object is used to fetch quotes or greeks for a given symbol or list of symbols. It should always be initialized as an async context manager, or by awaiting it, since the object cannot be fully instantiated without async.

Example usage:

from tastytrade import DXLinkStreamer
from tastytrade.dxfeed import Quote

# must be a production session
async with DXLinkStreamer(session) as streamer:
    subs = ['SPY']  # list of quotes to subscribe to
    await streamer.subscribe(Quote, subs)
    quote = await streamer.get_event(Quote)
    print(quote)

Or:

streamer = await DXLinkStreamer(session)
async close() None

Closes the websocket connection and cancels the heartbeat task.

async get_event(event_class: Type[U]) U

Using the existing subscription, pulls an event of the given type and returns it.

This is designed to be friendly for type checking; the return type will be the same class you pass in.

Parameters:

event_class – the type of alert to listen for, should be of EventType

get_event_nowait(event_class: Type[U]) U | None

Using the existing subscriptions, pulls an event of the given type and returns it. If the queue is empty None is returned.

This is designed to be friendly for type checking; the return type will be the same class you pass in.

Parameters:

event_class – the type of alert to listen for, should be of EventType

async listen(event_class: Type[U]) AsyncIterator[U]

Using the existing subscriptions, pulls events of the given type and yield returns them. Never exits unless there’s an error or the channel is closed.

This is designed to be friendly for type checking; the return type will be the same class you pass in.

Parameters:

event_class – the type of alert to listen for, should be of EventType

reconnect_args

Variable number of arguments to pass to the reconnect function

reconnect_fn

An async function to be called upon reconnection. The first argument must be of type DXLinkStreamer and will be a reference to the streamer object.

async subscribe(event_class: Type[Candle | Greeks | Profile | Quote | Summary | TheoPrice | TimeAndSale | Trade | Underlying], symbols: list[str]) None

Subscribes to quotes for given list of symbols. Used for recurring data feeds. For candles, use subscribe_candle() instead.

Parameters:
  • event_class – type of subscription to add, should be of EventType

  • symbols – list of symbols to subscribe for

async subscribe_candle(symbols: list[str], interval: str, start_time: datetime, extended_trading_hours: bool = False) None

Subscribes to candle data for the given list of symbols.

Parameters:
  • symbols – list of symbols to get data for

  • interval – the width of each candle in time, e.g. ’15s’, ‘5m’, ‘1h’, ‘3d’, ‘1w’, ‘1mo’

  • start_time – starting time for the data range

  • end_time – ending time for the data range

  • extended_trading_hours – whether to include extended trading

async unsubscribe(event_class: Type[Candle | Greeks | Profile | Quote | Summary | TheoPrice | TimeAndSale | Trade | Underlying], symbols: list[str]) None

Removes existing subscription for given list of symbols. For candles, use unsubscribe_candle() instead.

Parameters:
  • event_class – type of subscription to remove

  • symbols – list of symbols to unsubscribe from

async unsubscribe_all(event_class: Type[Candle | Greeks | Profile | Quote | Summary | TheoPrice | TimeAndSale | Trade | Underlying]) None

Unsubscribes to all events of the given event type.

Parameters:

event_class – type of event to unsubscribe from.

async unsubscribe_candle(ticker: str, interval: str | None = None, extended_trading_hours: bool = False) None

Removes existing subscription for a candle.

Parameters:
  • ticker – symbol to unsubscribe from

  • interval – candle width to unsubscribe from

  • extended_trading_hours – whether candle to unsubscribe from contains extended trading hours

tastytrade.streamer.EventType

List of all possible types to stream with the data streamer

alias of Union[Candle, Greeks, Profile, Quote, Summary, TheoPrice, TimeAndSale, Trade, Underlying]

pydantic model tastytrade.streamer.QuoteAlert(*, user_external_id: str, symbol: str, alert_external_id: str, expires_at: int, completed_at: datetime, created_at: datetime, triggered_at: datetime, field: str, operator: str, threshold: str, threshold_numeric: Decimal, dx_symbol: str)

Bases: TastytradeJsonDataclass

Dataclass that contains information about a quote alert

Show JSON schema
{
   "title": "QuoteAlert",
   "description": "Dataclass that contains information about a quote alert",
   "type": "object",
   "properties": {
      "user-external-id": {
         "title": "User-External-Id",
         "type": "string"
      },
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "alert-external-id": {
         "title": "Alert-External-Id",
         "type": "string"
      },
      "expires-at": {
         "title": "Expires-At",
         "type": "integer"
      },
      "completed-at": {
         "format": "date-time",
         "title": "Completed-At",
         "type": "string"
      },
      "created-at": {
         "format": "date-time",
         "title": "Created-At",
         "type": "string"
      },
      "triggered-at": {
         "format": "date-time",
         "title": "Triggered-At",
         "type": "string"
      },
      "field": {
         "title": "Field",
         "type": "string"
      },
      "operator": {
         "title": "Operator",
         "type": "string"
      },
      "threshold": {
         "title": "Threshold",
         "type": "string"
      },
      "threshold-numeric": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Threshold-Numeric"
      },
      "dx-symbol": {
         "title": "Dx-Symbol",
         "type": "string"
      }
   },
   "required": [
      "user-external-id",
      "symbol",
      "alert-external-id",
      "expires-at",
      "completed-at",
      "created-at",
      "triggered-at",
      "field",
      "operator",
      "threshold",
      "threshold-numeric",
      "dx-symbol"
   ]
}

Fields:
  • alert_external_id (str)

  • completed_at (datetime.datetime)

  • created_at (datetime.datetime)

  • dx_symbol (str)

  • expires_at (int)

  • field (str)

  • operator (str)

  • symbol (str)

  • threshold (str)

  • threshold_numeric (decimal.Decimal)

  • triggered_at (datetime.datetime)

  • user_external_id (str)

enum tastytrade.streamer.SubscriptionType(value)

Bases: str, Enum

This is an Enum that contains the subscription types for the alert streamer.

Member Type:

str

Valid values are as follows:

ACCOUNT = <SubscriptionType.ACCOUNT: 'account-subscribe'>
HEARTBEAT = <SubscriptionType.HEARTBEAT: 'heartbeat'>
PUBLIC_WATCHLISTS = <SubscriptionType.PUBLIC_WATCHLISTS: 'public-watchlists-subscribe'>
QUOTE_ALERTS = <SubscriptionType.QUOTE_ALERTS: 'quote-alerts-subscribe'>
USER_MESSAGE = <SubscriptionType.USER_MESSAGE: 'user-message-subscribe'>
pydantic model tastytrade.streamer.UnderlyingYearGainSummary(*, year: int, account_number: str, symbol: str, instrument_type: InstrumentType, fees: Decimal, commissions: Decimal, yearly_realized_gain: Decimal, realized_lot_gain: Decimal)

Bases: TastytradeJsonDataclass

Dataclass that contains information about the yearly gain or loss for an underlying

Show JSON schema
{
   "title": "UnderlyingYearGainSummary",
   "description": "Dataclass that contains information about the yearly gain\nor loss for an underlying",
   "type": "object",
   "properties": {
      "year": {
         "title": "Year",
         "type": "integer"
      },
      "account-number": {
         "title": "Account-Number",
         "type": "string"
      },
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "fees": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Fees"
      },
      "commissions": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Commissions"
      },
      "yearly-realized-gain": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Yearly-Realized-Gain"
      },
      "realized-lot-gain": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "string"
            }
         ],
         "title": "Realized-Lot-Gain"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "This is an :class:`~enum.Enum` that contains the valid types of instruments\nand their representation in the API.",
         "enum": [
            "Bond",
            "Cryptocurrency",
            "Currency Pair",
            "Equity",
            "Equity Offering",
            "Equity Option",
            "Fixed Income Security",
            "Future",
            "Future Option",
            "Index",
            "Liquidity Pool",
            "Unknown",
            "Warrant"
         ],
         "title": "InstrumentType",
         "type": "string"
      }
   },
   "required": [
      "year",
      "account-number",
      "symbol",
      "instrument-type",
      "fees",
      "commissions",
      "yearly-realized-gain",
      "realized-lot-gain"
   ]
}

Fields:
  • account_number (str)

  • commissions (decimal.Decimal)

  • fees (decimal.Decimal)

  • instrument_type (tastytrade.order.InstrumentType)

  • realized_lot_gain (decimal.Decimal)

  • symbol (str)

  • year (int)

  • yearly_realized_gain (decimal.Decimal)

Validators:
  • validate_price_effects » all fields

Utils

enum tastytrade.utils.PriceEffect(value)

This is an Enum that shows the sign of a price effect, since Tastytrade is apparently against negative numbers.

Member Type:

str

Valid values are as follows:

CREDIT = <PriceEffect.CREDIT: 'Credit'>
DEBIT = <PriceEffect.DEBIT: 'Debit'>
NONE = <PriceEffect.NONE: 'None'>
exception tastytrade.utils.TastytradeError

An internal error raised by the Tastytrade API.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

pydantic model tastytrade.utils.TastytradeJsonDataclass

A pydantic dataclass that converts keys from snake case to dasherized and performs type validation and coercion.

Show JSON schema
{
   "title": "TastytradeJsonDataclass",
   "description": "A pydantic dataclass that converts keys from snake case to dasherized\nand performs type validation and coercion.",
   "type": "object",
   "properties": {}
}

copy(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, update: Dict[str, Any] | None = None, deep: bool = False) Self

Returns a copy of the model.

!!! warning “Deprecated”

This method is now deprecated; use model_copy instead.

If you need include or exclude, use:

`python {test="skip" lint="skip"} data = self.model_dump(include=include, exclude=exclude, round_trip=True) data = {**data, **(update or {})} copied = self.model_validate(data) `

Args:

include: Optional set or mapping specifying which fields to include in the copied model. exclude: Optional set or mapping specifying which fields to exclude in the copied model. update: Optional dictionary of field-value pairs to override field values in the copied model. deep: If True, the values of fields that are Pydantic models will be deep-copied.

Returns:

A copy of the model with included, excluded and updated fields as specified.

classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self

Creates a new instance of the Model class with validated data.

Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.

!!! note

model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.

Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,

this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.

values: Trusted or pre-validated data dictionary.

Returns:

A new instance of the Model class with validated data.

model_copy(*, update: Mapping[str, Any] | None = None, deep: bool = False) Self

Usage docs: https://docs.pydantic.dev/2.10/concepts/serialization/#model_copy

Returns a copy of the model.

Args:
update: Values to change/add in the new model. Note: the data is not validated

before creating the new model. You should trust this data.

deep: Set to True to make a deep copy of the model.

Returns:

New model instance.

model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]

Usage docs: https://docs.pydantic.dev/2.10/concepts/serialization/#modelmodel_dump

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Args:
mode: The mode in which to_python should run.

If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.

include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,

“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.

Returns:

A dictionary representation of the model.

model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str

Usage docs: https://docs.pydantic.dev/2.10/concepts/serialization/#modelmodel_dump_json

Generates a JSON representation of the model using Pydantic’s to_json method.

Args:

indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,

“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.

Returns:

A JSON string representation of the model.

classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]

Generates a JSON schema for a model class.

Args:

by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of

GenerateJsonSchema with your desired modifications

mode: The mode in which to generate the schema.

Returns:

The JSON schema for the given model class.

classmethod model_parametrized_name(params: tuple[type[Any], ...]) str

Compute the class name for parametrizations of generic classes.

This method can be overridden to achieve a custom naming scheme for generic BaseModels.

Args:
params: Tuple of types of the class. Given a generic class

Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.

Returns:

String representing the new class where params are passed to cls as type variables.

Raises:

TypeError: Raised when trying to generate concrete names for non-generic models.

model_post_init(_BaseModel__context: Any) None

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: MappingNamespace | None = None) bool | None

Try to rebuild the pydantic-core schema for the model.

This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.

Args:

force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.

Returns:

Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.

classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self

Validate a pydantic model instance.

Args:

obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.

Raises:

ValidationError: If the object could not be validated.

Returns:

The validated model instance.

classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self

Usage docs: https://docs.pydantic.dev/2.10/concepts/json/#json-parsing

Validate the given JSON data against the Pydantic model.

Args:

json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.

Returns:

The validated Pydantic model.

Raises:

ValidationError: If json_data is not a JSON string or the object could not be validated.

classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self

Validate the given object with string data against the Pydantic model.

Args:

obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.

Returns:

The validated Pydantic model.

property model_extra: dict[str, Any] | None

Get extra fields set during validation.

Returns:

A dictionary of extra fields, or None if config.extra is not set to “allow”.

property model_fields_set: set[str]

Returns the set of fields that have been explicitly set on this model instance.

Returns:
A set of strings representing the fields that have been set,

i.e. that were not filled from defaults.

tastytrade.utils.get_future_fx_monthly(day: date | None = None) date

Gets the monthly expiration associated with the FX futures: /6E, /6A, etc. As far as I can tell, these expire on the first Friday prior to the second Wednesday.

Parameters:

day – date to check. If not provided defaults to current NY date.

Returns:

the associated monthly

tastytrade.utils.get_future_grain_monthly(day: date | None = None) date

Gets the monthly expiration associated with the grain futures: /ZC, /ZW, etc. According to CME, these expire on the Friday which precedes, by at least 2 business days, the last business day of the month.

Parameters:

day – date to check. If not provided defaults to current NY date.

Returns:

the associated monthly

tastytrade.utils.get_future_index_monthly(day: date | None = None) date

Gets the monthly expiration associated with the index futures: /ES, /RTY, /NQ, etc. According to CME, these expire on the last business day of the month.

Parameters:

day – date to check. If not provided defaults to current NY date.

Returns:

the associated monthly

tastytrade.utils.get_future_metal_monthly(day: date | None = None) date

Gets the monthly expiration associated with the metals futures: /GC, /SI, etc. According to CME, these expire on the 4th last business day of the month, unless that day occurs on a Friday or the day before a holiday, in which case they expire on the prior business day.

Parameters:

day – date to check. If not provided defaults to current NY date.

Returns:

the associated monthly

tastytrade.utils.get_future_oil_monthly(day: date | None = None) date

Gets the monthly expiration associated with the WTI oil futures: /CL and /MCL. According to CME, these expire 6 business days before the 25th day of the month, unless the 25th day is not a business day, in which case they expire 7 business days prior to the 25th day of the month.

Parameters:

day – date to check. If not provided defaults to current NY date.

Returns:

the associated monthly

tastytrade.utils.get_future_treasury_monthly(day: date | None = None) date

Gets the monthly expiration associated with the treasury futures: /ZN, /ZB, etc. According to CME, these expire the Friday before the 2nd last business day of the month. If this is not a business day, they expire 1 business day prior.

Parameters:

day – date to check. If not provided defaults to current NY date.

Returns:

the associated monthly

tastytrade.utils.get_tasty_monthly() date

Gets the monthly expiration closest to 45 days from the current date.

Returns:

the closest to 45 DTE monthly expiration

tastytrade.utils.get_third_friday(day: date | None = None) date

Gets the monthly expiration associated with the month of the given date, or the monthly expiration associated with today’s month.

Parameters:

day – date to check. If not provided defaults to current NY date.

Returns:

the associated monthly

tastytrade.utils.is_market_open_on(day: date | None = None) bool

Returns whether the market was/is/will be open at ANY point during the given day.

Parameters:

day – date to check. If not provided defaults to current NY date.

Returns:

whether the market opens on given day

tastytrade.utils.now_in_new_york() datetime

Gets the current time in the New York timezone.

Returns:

current time as datetime

tastytrade.utils.today_in_new_york() date

Gets the current date in the New York timezone.

Returns:

current date

tastytrade.utils.validate_response(response: Response) None

Checks if the given code is an error; if so, raises an exception.

Parameters:

response – response to check for errors

Watchlists

pydantic model tastytrade.watchlists.Pair(*, left_action: str, left_symbol: str, left_quantity: int, right_action: str, right_symbol: str, right_quantity: int)

Bases: TastytradeJsonDataclass

Dataclass that represents a specific pair in a pairs watchlist.

Show JSON schema
{
   "title": "Pair",
   "description": "Dataclass that represents a specific pair in a pairs watchlist.",
   "type": "object",
   "properties": {
      "left-action": {
         "title": "Left-Action",
         "type": "string"
      },
      "left-symbol": {
         "title": "Left-Symbol",
         "type": "string"
      },
      "left-quantity": {
         "title": "Left-Quantity",
         "type": "integer"
      },
      "right-action": {
         "title": "Right-Action",
         "type": "string"
      },
      "right-symbol": {
         "title": "Right-Symbol",
         "type": "string"
      },
      "right-quantity": {
         "title": "Right-Quantity",
         "type": "integer"
      }
   },
   "required": [
      "left-action",
      "left-symbol",
      "left-quantity",
      "right-action",
      "right-symbol",
      "right-quantity"
   ]
}

Fields:
  • left_action (str)

  • left_quantity (int)

  • left_symbol (str)

  • right_action (str)

  • right_quantity (int)

  • right_symbol (str)

pydantic model tastytrade.watchlists.PairsWatchlist(*, name: str, order_index: int, pairs_equations: list[tastytrade.watchlists.Pair])

Bases: TastytradeJsonDataclass

Dataclass that represents a pairs watchlist object.

Show JSON schema
{
   "title": "PairsWatchlist",
   "description": "Dataclass that represents a pairs watchlist object.",
   "type": "object",
   "properties": {
      "name": {
         "title": "Name",
         "type": "string"
      },
      "order-index": {
         "title": "Order-Index",
         "type": "integer"
      },
      "pairs-equations": {
         "items": {
            "$ref": "#/$defs/Pair"
         },
         "title": "Pairs-Equations",
         "type": "array"
      }
   },
   "$defs": {
      "Pair": {
         "description": "Dataclass that represents a specific pair in a pairs watchlist.",
         "properties": {
            "left-action": {
               "title": "Left-Action",
               "type": "string"
            },
            "left-symbol": {
               "title": "Left-Symbol",
               "type": "string"
            },
            "left-quantity": {
               "title": "Left-Quantity",
               "type": "integer"
            },
            "right-action": {
               "title": "Right-Action",
               "type": "string"
            },
            "right-symbol": {
               "title": "Right-Symbol",
               "type": "string"
            },
            "right-quantity": {
               "title": "Right-Quantity",
               "type": "integer"
            }
         },
         "required": [
            "left-action",
            "left-symbol",
            "left-quantity",
            "right-action",
            "right-symbol",
            "right-quantity"
         ],
         "title": "Pair",
         "type": "object"
      }
   },
   "required": [
      "name",
      "order-index",
      "pairs-equations"
   ]
}

Fields:
  • name (str)

  • order_index (int)

  • pairs_equations (list[tastytrade.watchlists.Pair])

async classmethod a_get_pairs_watchlist(session: Session, name: str) Self

Fetches a Tastytrade public pairs watchlist by name.

Parameters:
  • session – the session to use for the request.

  • name – the name of the pairs watchlist to fetch.

async classmethod a_get_pairs_watchlists(session: Session) list[typing_extensions.Self]

Fetches a list of all Tastytrade public pairs watchlists.

Parameters:

session – the session to use for the request.

classmethod get_pairs_watchlist(session: Session, name: str) Self

Fetches a Tastytrade public pairs watchlist by name.

Parameters:
  • session – the session to use for the request.

  • name – the name of the pairs watchlist to fetch.

classmethod get_pairs_watchlists(session: Session) list[typing_extensions.Self]

Fetches a list of all Tastytrade public pairs watchlists.

Parameters:

session – the session to use for the request.

pydantic model tastytrade.watchlists.Watchlist(*, name: str, watchlist_entries: list[dict[str, Any]] | None = None, group_name: str = 'default', order_index: int = 9999)

Bases: TastytradeJsonDataclass

Dataclass that represents a watchlist object (public or private), with functions to update, publish, modify and remove watchlists.

Show JSON schema
{
   "title": "Watchlist",
   "description": "Dataclass that represents a watchlist object (public or private),\nwith functions to update, publish, modify and remove watchlists.",
   "type": "object",
   "properties": {
      "name": {
         "title": "Name",
         "type": "string"
      },
      "watchlist-entries": {
         "anyOf": [
            {
               "items": {
                  "type": "object"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Watchlist-Entries"
      },
      "group-name": {
         "default": "default",
         "title": "Group-Name",
         "type": "string"
      },
      "order-index": {
         "default": 9999,
         "title": "Order-Index",
         "type": "integer"
      }
   },
   "required": [
      "name"
   ]
}

Fields:
  • group_name (str)

  • name (str)

  • order_index (int)

  • watchlist_entries (list[dict[str, typing.Any]] | None)

async classmethod a_get_private_watchlist(session: Session, name: str) Self

Fetches a user’s watchlist by name.

Parameters:
  • session – the session to use for the request.

  • name – the name of the watchlist to fetch.

async classmethod a_get_private_watchlists(session: Session) list[typing_extensions.Self]

Fetches a the user’s private watchlists.

Parameters:

session – the session to use for the request.

async classmethod a_get_public_watchlist(session: Session, name: str) Self

Fetches a Tastytrade public watchlist by name.

Parameters:
  • session – the session to use for the request.

  • name – the name of the watchlist to fetch.

async classmethod a_get_public_watchlists(session: Session, counts_only: bool = False) list[typing_extensions.Self]

Fetches a list of all Tastytrade public watchlists.

Parameters:
  • session – the session to use for the request.

  • counts_only – whether to only fetch the counts of the watchlists.

async classmethod a_remove_private_watchlist(session: Session, name: str) None

Deletes the named private watchlist.

Parameters:
  • session – the session to use for the request.

  • name – the name of the watchlist to delete.

async a_update_private_watchlist(session: Session) None

Updates the existing private remote watchlist.

Parameters:

session – the session to use for the request.

async a_upload_private_watchlist(session: Session) None

Creates a private remote watchlist identical to this local one.

Parameters:

session – the session to use for the request.

add_symbol(symbol: str, instrument_type: InstrumentType) None

Adds a symbol to the watchlist.

classmethod get_private_watchlist(session: Session, name: str) Self

Fetches a user’s watchlist by name.

Parameters:
  • session – the session to use for the request.

  • name – the name of the watchlist to fetch.

classmethod get_private_watchlists(session: Session) list[typing_extensions.Self]

Fetches a the user’s private watchlists.

Parameters:

session – the session to use for the request.

classmethod get_public_watchlist(session: Session, name: str) Self

Fetches a Tastytrade public watchlist by name.

Parameters:
  • session – the session to use for the request.

  • name – the name of the watchlist to fetch.

classmethod get_public_watchlists(session: Session, counts_only: bool = False) list[typing_extensions.Self]

Fetches a list of all Tastytrade public watchlists.

Parameters:
  • session – the session to use for the request.

  • counts_only – whether to only fetch the counts of the watchlists.

classmethod remove_private_watchlist(session: Session, name: str) None

Deletes the named private watchlist.

Parameters:
  • session – the session to use for the request.

  • name – the name of the watchlist to delete.

remove_symbol(symbol: str, instrument_type: InstrumentType) None

Removes a symbol from the watchlist.

update_private_watchlist(session: Session) None

Updates the existing private remote watchlist.

Parameters:

session – the session to use for the request.

upload_private_watchlist(session: Session) None

Creates a private remote watchlist identical to this local one.

Parameters:

session – the session to use for the request.