tastytrade.market_sessions¶
- class tastytrade.market_sessions.ExchangeType(value)¶
Bases:
StrEnumContains the valid exchanges to get futures market sessions for.
-
CFE =
'CFE'¶
-
CME =
'CME'¶
-
NYSE =
'Equity'¶
-
CFE =
- pydantic model tastytrade.market_sessions.MarketCalendar(*, half_days: list[date], holidays: list[date])¶
Bases:
TastytradeDataDataclass containing information about market holidays and shortened days.
Show JSON schema
{ "title": "MarketCalendar", "description": "Dataclass containing information about market holidays and shortened days.", "type": "object", "properties": { "market-half-days": { "items": { "format": "date", "type": "string" }, "title": "Market-Half-Days", "type": "array" }, "market-holidays": { "items": { "format": "date", "type": "string" }, "title": "Market-Holidays", "type": "array" } }, "required": [ "market-half-days", "market-holidays" ] }
-
pydantic model tastytrade.market_sessions.MarketSession(*, close_at: datetime | None =
None, close_at_ext: datetime | None =None, instrument_collection: str, open_at: datetime | None =None, start_at: datetime | None =None, next_session: MarketSessionSnapshot | None =None, previous_session: MarketSessionSnapshot | None =None, state: MarketStatus)¶ Bases:
TastytradeDataDataclass representing the current, next, and previous sessions.
Show JSON schema
{ "title": "MarketSession", "description": "Dataclass representing the current, next, and previous sessions.", "type": "object", "properties": { "close-at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Close-At" }, "close-at-ext": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Close-At-Ext" }, "instrument-collection": { "title": "Instrument-Collection", "type": "string" }, "open-at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Open-At" }, "start-at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Start-At" }, "next-session": { "anyOf": [ { "$ref": "#/$defs/MarketSessionSnapshot" }, { "type": "null" } ], "default": null }, "previous-session": { "anyOf": [ { "$ref": "#/$defs/MarketSessionSnapshot" }, { "type": "null" } ], "default": null }, "state": { "$ref": "#/$defs/MarketStatus" } }, "$defs": { "MarketSessionSnapshot": { "description": "Dataclass containing information about the upcoming or previous market session.", "properties": { "close-at": { "format": "date-time", "title": "Close-At", "type": "string" }, "close-at-ext": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Close-At-Ext" }, "instrument-collection": { "title": "Instrument-Collection", "type": "string" }, "open-at": { "format": "date-time", "title": "Open-At", "type": "string" }, "session-date": { "format": "date", "title": "Session-Date", "type": "string" }, "start-at": { "format": "date-time", "title": "Start-At", "type": "string" } }, "required": [ "close-at", "instrument-collection", "open-at", "session-date", "start-at" ], "title": "MarketSessionSnapshot", "type": "object" }, "MarketStatus": { "description": "Contains the valid market status values.", "enum": [ "Open", "Closed", "Pre-market", "Extended" ], "title": "MarketStatus", "type": "string" } }, "required": [ "instrument-collection", "state" ] }- Fields:¶
-
field next_session : MarketSessionSnapshot | None =
None(alias 'next-session')¶
-
field previous_session : MarketSessionSnapshot | None =
None(alias 'previous-session')¶
- field status : MarketStatus [Required] (alias 'state')¶
-
pydantic model tastytrade.market_sessions.MarketSessionSnapshot(*, close_at: datetime, close_at_ext: datetime | None =
None, instrument_collection: str, open_at: datetime, session_date: date, start_at: datetime)¶ Bases:
TastytradeDataDataclass containing information about the upcoming or previous market session.
Show JSON schema
{ "title": "MarketSessionSnapshot", "description": "Dataclass containing information about the upcoming or previous market session.", "type": "object", "properties": { "close-at": { "format": "date-time", "title": "Close-At", "type": "string" }, "close-at-ext": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Close-At-Ext" }, "instrument-collection": { "title": "Instrument-Collection", "type": "string" }, "open-at": { "format": "date-time", "title": "Open-At", "type": "string" }, "session-date": { "format": "date", "title": "Session-Date", "type": "string" }, "start-at": { "format": "date-time", "title": "Start-At", "type": "string" } }, "required": [ "close-at", "instrument-collection", "open-at", "session-date", "start-at" ] }- Fields:¶
- class tastytrade.market_sessions.MarketStatus(value)¶
Bases:
StrEnumContains the valid market status values.
-
CLOSED =
'Closed'¶
-
EXTENDED =
'Extended'¶
-
OPEN =
'Open'¶
-
PRE_MARKET =
'Pre-market'¶
-
CLOSED =
- async tastytrade.market_sessions.get_futures_holidays(session: Session, exchange: ExchangeType) MarketCalendar¶
Retrieves market calendar for half days and holidays for a futures exchange.
- Parameters:¶
- session: Session¶
active user session to use
- exchange: ExchangeType¶
exchange to fetch calendar for
- async tastytrade.market_sessions.get_market_holidays(session: Session) MarketCalendar¶
Retrieves market calendar for half days and holidays.
- async tastytrade.market_sessions.get_market_sessions(session: Session, exchanges: Iterable[ExchangeType]) list[MarketSession]¶
Retrieves a list of session timings for the given exchanges.