tastytrade.market_data¶
- class tastytrade.market_data.ClosePriceType(value)¶
Bases:
StrEnumContains possible statuses for close prices.
-
FINAL =
'Final'¶
-
INDICATIVE =
'Indicative'¶
-
PRELIMINARY =
'Preliminary'¶
-
REGULAR =
'Regular'¶
-
UNKNOWN =
'Unknown'¶
-
FINAL =
- class tastytrade.market_data.ExchangeType(value)¶
Bases:
StrEnumContains 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'¶
-
BOND =
- pydantic model tastytrade.market_data.Instrument(*, symbol: str, instrument_type: InstrumentType, instrument_key: InstrumentKey, underlying_instrument: str, root_symbol: str, exchange: ExchangeType)¶
Bases:
TastytradeDataDataclass 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')¶
- pydantic model tastytrade.market_data.InstrumentKey(*, symbol: str, instrument_type: InstrumentType)¶
Bases:
TastytradeDataDataclass 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" ] }- field instrument_type : InstrumentType [Required] (alias 'instrument-type')¶
-
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:
TastytradeDataDataclass 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" ] }- field close_price_type : ClosePriceType [Required] (alias 'close-price-type')¶
-
field instrument : Instrument | None =
None¶
- field instrument_type : InstrumentType [Required] (alias 'instrument-type')¶
- field prev_close_price_type : ClosePriceType [Required] (alias 'prev-close-price-type')¶
- async tastytrade.market_data.get_market_data(session: Session, symbol: str, instrument_type: InstrumentType) MarketData¶
Get market data for the given 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