tastytrade.market_data

class tastytrade.market_data.ClosePriceType(value)

Bases: StrEnum

Contains possible statuses for close prices.

FINAL = 'Final'
INDICATIVE = 'Indicative'
PRELIMINARY = 'Preliminary'
REGULAR = 'Regular'
UNKNOWN = 'Unknown'
class tastytrade.market_data.ExchangeType(value)

Bases: StrEnum

Contains the valid exchanges to fetch data for.

BOND = 'Bond'
CBOE = 'CBOED'
CFE = 'CFE'
CME = 'CME'
CRYPTO = 'Cryptocurrency'
EQUITY_OFFERING = 'Equity Offering'
NYSE = 'Equity'
SMALL = 'Smalls'
UNKNOWN = 'Unknown'
pydantic model tastytrade.market_data.Instrument(*, symbol: str, instrument_type: InstrumentType, instrument_key: InstrumentKey, underlying_instrument: str, root_symbol: str, exchange: ExchangeType)

Bases: TastytradeData

Dataclass containing information about an instrument.

Show JSON schema
{
   "title": "Instrument",
   "description": "Dataclass containing information about an instrument.",
   "type": "object",
   "properties": {
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "instrument-key": {
         "$ref": "#/$defs/InstrumentKey"
      },
      "underlying-instrument": {
         "title": "Underlying-Instrument",
         "type": "string"
      },
      "root-symbol": {
         "title": "Root-Symbol",
         "type": "string"
      },
      "exchange": {
         "$ref": "#/$defs/ExchangeType"
      }
   },
   "$defs": {
      "ExchangeType": {
         "description": "Contains the valid exchanges to fetch data for.",
         "enum": [
            "CME",
            "CFE",
            "Equity",
            "Smalls",
            "CBOED",
            "Bond",
            "Cryptocurrency",
            "Equity Offering",
            "Unknown"
         ],
         "title": "ExchangeType",
         "type": "string"
      },
      "InstrumentKey": {
         "description": "Dataclass containing an instrument key.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            }
         },
         "required": [
            "symbol",
            "instrument-type"
         ],
         "title": "InstrumentKey",
         "type": "object"
      },
      "InstrumentType": {
         "description": "Contains the valid types of instruments and 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",
      "instrument-key",
      "underlying-instrument",
      "root-symbol",
      "exchange"
   ]
}

Fields:
field exchange : ExchangeType [Required]
field instrument_key : InstrumentKey [Required] (alias 'instrument-key')
field instrument_type : InstrumentType [Required] (alias 'instrument-type')
field root_symbol : str [Required] (alias 'root-symbol')
field symbol : str [Required]
field underlying_instrument : str [Required] (alias 'underlying-instrument')
pydantic model tastytrade.market_data.InstrumentKey(*, symbol: str, instrument_type: InstrumentType)

Bases: TastytradeData

Dataclass containing an instrument key.

Show JSON schema
{
   "title": "InstrumentKey",
   "description": "Dataclass containing an instrument key.",
   "type": "object",
   "properties": {
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      }
   },
   "$defs": {
      "InstrumentType": {
         "description": "Contains the valid types of instruments and 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"
   ]
}

Fields:
field instrument_type : InstrumentType [Required] (alias 'instrument-type')
field symbol : str [Required]
pydantic model tastytrade.market_data.MarketData(*, symbol: str, instrument_type: InstrumentType, updated_at: datetime, bid_size: Decimal, ask_size: Decimal, mark: Decimal, close_price_type: ClosePriceType, summary_date: date, prev_close_date: date, prev_close_price_type: ClosePriceType, halt_start_time: int, halt_end_time: int, ask: Decimal | None = None, beta: Decimal | None = None, bid: Decimal | None = None, close: Decimal | None = None, day_open: Decimal | None = None, day_high: Decimal | None = None, day_low: Decimal | None = None, day_close: Decimal | None = None, day_high_price: Decimal | None = None, day_low_price: Decimal | None = None, dividend_amount: Decimal | None = None, dividend_frequency: Decimal | None = None, high_limit_price: Decimal | None = None, instrument: Instrument | None = None, last: Decimal | None = None, last_mkt: Decimal | None = None, last_ext: Decimal | None = None, last_trade_time: int | None = None, low_limit_price: Decimal | None = None, mid: Decimal | None = None, open: Decimal | None = None, prev_close: Decimal | None = None, prev_day_close: Decimal | None = None, trading_halted: bool | None = None, trading_halted_reason: str | None = None, volume: Decimal | None = None, year_low_price: Decimal | None = None, year_high_price: Decimal | None = None, open_interest: Decimal | None = None)

Bases: TastytradeData

Dataclass containing life market data for a symbol.

Show JSON schema
{
   "title": "MarketData",
   "description": "Dataclass containing life market data for a symbol.",
   "type": "object",
   "properties": {
      "symbol": {
         "title": "Symbol",
         "type": "string"
      },
      "instrument-type": {
         "$ref": "#/$defs/InstrumentType"
      },
      "updated-at": {
         "format": "date-time",
         "title": "Updated-At",
         "type": "string"
      },
      "bid-size": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            }
         ],
         "title": "Bid-Size"
      },
      "ask-size": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            }
         ],
         "title": "Ask-Size"
      },
      "mark": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            }
         ],
         "title": "Mark"
      },
      "close-price-type": {
         "$ref": "#/$defs/ClosePriceType"
      },
      "summary-date": {
         "format": "date",
         "title": "Summary-Date",
         "type": "string"
      },
      "prev-close-date": {
         "format": "date",
         "title": "Prev-Close-Date",
         "type": "string"
      },
      "prev-close-price-type": {
         "$ref": "#/$defs/ClosePriceType"
      },
      "halt-start-time": {
         "title": "Halt-Start-Time",
         "type": "integer"
      },
      "halt-end-time": {
         "title": "Halt-End-Time",
         "type": "integer"
      },
      "ask": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Ask"
      },
      "beta": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Beta"
      },
      "bid": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Bid"
      },
      "close": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Close"
      },
      "day-open": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Day-Open"
      },
      "day-high": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Day-High"
      },
      "day-low": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Day-Low"
      },
      "day-close": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Day-Close"
      },
      "day-high-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Day-High-Price"
      },
      "day-low-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Day-Low-Price"
      },
      "dividend-amount": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Dividend-Amount"
      },
      "dividend-frequency": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Dividend-Frequency"
      },
      "high-limit-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "High-Limit-Price"
      },
      "instrument": {
         "anyOf": [
            {
               "$ref": "#/$defs/Instrument"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "last": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Last"
      },
      "last-mkt": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Last-Mkt"
      },
      "last-ext": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Last-Ext"
      },
      "last-trade-time": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Last-Trade-Time"
      },
      "low-limit-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Low-Limit-Price"
      },
      "mid": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Mid"
      },
      "open": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Open"
      },
      "prev-close": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Prev-Close"
      },
      "prev-day-close": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Prev-Day-Close"
      },
      "trading-halted": {
         "anyOf": [
            {
               "type": "boolean"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Trading-Halted"
      },
      "trading-halted-reason": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Trading-Halted-Reason"
      },
      "volume": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Volume"
      },
      "year-low-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Year-Low-Price"
      },
      "year-high-price": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Year-High-Price"
      },
      "open-interest": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Open-Interest"
      }
   },
   "$defs": {
      "ClosePriceType": {
         "description": "Contains possible statuses for close prices.",
         "enum": [
            "Final",
            "Indicative",
            "Preliminary",
            "Regular",
            "Unknown"
         ],
         "title": "ClosePriceType",
         "type": "string"
      },
      "ExchangeType": {
         "description": "Contains the valid exchanges to fetch data for.",
         "enum": [
            "CME",
            "CFE",
            "Equity",
            "Smalls",
            "CBOED",
            "Bond",
            "Cryptocurrency",
            "Equity Offering",
            "Unknown"
         ],
         "title": "ExchangeType",
         "type": "string"
      },
      "Instrument": {
         "description": "Dataclass containing information about an instrument.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            },
            "instrument-key": {
               "$ref": "#/$defs/InstrumentKey"
            },
            "underlying-instrument": {
               "title": "Underlying-Instrument",
               "type": "string"
            },
            "root-symbol": {
               "title": "Root-Symbol",
               "type": "string"
            },
            "exchange": {
               "$ref": "#/$defs/ExchangeType"
            }
         },
         "required": [
            "symbol",
            "instrument-type",
            "instrument-key",
            "underlying-instrument",
            "root-symbol",
            "exchange"
         ],
         "title": "Instrument",
         "type": "object"
      },
      "InstrumentKey": {
         "description": "Dataclass containing an instrument key.",
         "properties": {
            "symbol": {
               "title": "Symbol",
               "type": "string"
            },
            "instrument-type": {
               "$ref": "#/$defs/InstrumentType"
            }
         },
         "required": [
            "symbol",
            "instrument-type"
         ],
         "title": "InstrumentKey",
         "type": "object"
      },
      "InstrumentType": {
         "description": "Contains the valid types of instruments and 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",
      "updated-at",
      "bid-size",
      "ask-size",
      "mark",
      "close-price-type",
      "summary-date",
      "prev-close-date",
      "prev-close-price-type",
      "halt-start-time",
      "halt-end-time"
   ]
}

Fields:
field ask : Decimal | None = None
field ask_size : Decimal [Required] (alias 'ask-size')
field beta : Decimal | None = None
field bid : Decimal | None = None
field bid_size : Decimal [Required] (alias 'bid-size')
field close : Decimal | None = None
field close_price_type : ClosePriceType [Required] (alias 'close-price-type')
field day_close : Decimal | None = None (alias 'day-close')
field day_high : Decimal | None = None (alias 'day-high')
field day_high_price : Decimal | None = None (alias 'day-high-price')
field day_low : Decimal | None = None (alias 'day-low')
field day_low_price : Decimal | None = None (alias 'day-low-price')
field day_open : Decimal | None = None (alias 'day-open')
field dividend_amount : Decimal | None = None (alias 'dividend-amount')
field dividend_frequency : Decimal | None = None (alias 'dividend-frequency')
field halt_end_time : int [Required] (alias 'halt-end-time')
field halt_start_time : int [Required] (alias 'halt-start-time')
field high_limit_price : Decimal | None = None (alias 'high-limit-price')
field instrument : Instrument | None = None
field instrument_type : InstrumentType [Required] (alias 'instrument-type')
field last : Decimal | None = None
field last_ext : Decimal | None = None (alias 'last-ext')
field last_mkt : Decimal | None = None (alias 'last-mkt')
field last_trade_time : int | None = None (alias 'last-trade-time')
field low_limit_price : Decimal | None = None (alias 'low-limit-price')
field mark : Decimal [Required]
field mid : Decimal | None = None
field open : Decimal | None = None
field open_interest : Decimal | None = None (alias 'open-interest')
field prev_close : Decimal | None = None (alias 'prev-close')
field prev_close_date : date [Required] (alias 'prev-close-date')
field prev_close_price_type : ClosePriceType [Required] (alias 'prev-close-price-type')
field prev_day_close : Decimal | None = None (alias 'prev-day-close')
field summary_date : date [Required] (alias 'summary-date')
field symbol : str [Required]
field trading_halted : bool | None = None (alias 'trading-halted')
field trading_halted_reason : str | None = None (alias 'trading-halted-reason')
field updated_at : datetime [Required] (alias 'updated-at')
field volume : Decimal | None = None
field year_high_price : Decimal | None = None (alias 'year-high-price')
field year_low_price : Decimal | None = None (alias 'year-low-price')
async tastytrade.market_data.get_market_data(session: Session, symbol: str, instrument_type: InstrumentType) MarketData

Get market data for the given symbol.

Parameters:
session: Session

active session to use

symbol: str

symbol to get data for

instrument_type: InstrumentType

type of instrument for the symbol

async tastytrade.market_data.get_market_data_by_type(session: Session, cryptocurrencies: Iterable[str] | None = None, equities: Iterable[str] | None = None, futures: Iterable[str] | None = None, future_options: Iterable[str] | None = None, indices: Iterable[str] | None = None, options: Iterable[str] | None = None) list[MarketData]

Get market data for the given symbols grouped by instrument type. Combined limit across all types is 100.

Parameters:
session: Session

active session to use

cryptocurrencies: Iterable[str] | None = None

list of cryptocurrencies to fetch

equities: Iterable[str] | None = None

list of equities to fetch

futures: Iterable[str] | None = None

list of futures to fetch

future_options: Iterable[str] | None = None

list of future options to fetch

indices: Iterable[str] | None = None

list of indices to fetch

options: Iterable[str] | None = None

list of options to fetch