investfly.models.marketdata

Securities, quotes, bars, futures, options, financials, and news.

@dataclass(frozen=True, eq=True)
class Security:

Class representing a security instrument that is traded in the market

symbol: str

Security Symbol

securityType: SecurityType

Security Type

class SecurityType(builtins.str, enum.Enum):

Enum representing Security Type (STOCK, ETF, CRYPTO, FOREX, FUTURE, OPTION)

@dataclass(frozen=True)
class MarketHours:

Opening and closing times for one market session.

def sessionOpenDateTime(self, asOf: datetime.datetime) -> Optional[datetime.datetime]:

Return the open datetime of the regular session containing asOf, or None if outside session.

@dataclass
class Quote:

Class representing Price Quote

class QuoteField(builtins.str, enum.Enum):

Enum of all valid fields on Quote object

class Bar(typing.TypedDict):

One OHLCV market-data bar.

class BarInterval(builtins.str, enum.Enum):

Enum to represent BarInterval

class BarsGroup:

Bars grouped by their source security and interval.

@dataclass
class StockNews:

A dated news article and its source metadata.

class FinancialField(builtins.str, enum.Enum):

Financial Fields supported by Invesfly

class FutureProduct(builtins.str, enum.Enum):

Future Product Enum. A few commented out since their contracts are not available.

def getMonths(self) -> List[tuple[str, int]]:

Return (month_code, month_number) pairs in listed order.

@staticmethod
def fromSymbol( symbol: str) -> Optional[FutureProduct]:

Resolve a product code or concrete contract symbol (e.g. ESM26) to FutureProduct.

class FutureType(builtins.str, enum.Enum):

Enum representing high-level future product categories.

A specific futures contract (e.g., ESM25) for product ES expiring June 2025.

Extends Security with contract-specific metadata. Instances are created by the platform via StrategyDataService.listFutures(); strategy developers do not construct these directly.

Since Future is a Security, it can be used anywhere a concrete contract security is accepted, such as getQuote(future) and TradeOrder(security=future, ...). Historical strategy bars are exposed at the product level as continuous futures series, not as individual contract bars.

def getYear(self) -> int:

Return the last two digits of the expiry year, e.g. expiry 2026-03-20 -> 26.

def getFullYear(self) -> int:

Return the full 4-digit expiry year.

def getMonth(self) -> str:

Return the futures month code character from the symbol.

Handles both one-digit and two-digit year formats:

  • 'ESU3' -> 'U'
  • 'ESU23' -> 'U'
Inherited Members
Security
symbol
securityType
class OptionType(builtins.str, enum.Enum):

Right of an option contract: CALL or PUT

@dataclass(frozen=True, eq=True)
class OptionExpiry:

Calendar date when an option contract expires (1-indexed month and day)

def toExpirySymbol(self) -> str:

OCC YYMMDD form used in option symbols.

@dataclass(frozen=True, eq=True)
class StockOption:

OCC-style listed equity/ETF option contract.

OCC option symbol: TICKER + YYMMDD + C/P + strike*1000 (8 digits, zero-padded). Example: AAPL260117C00200000 => AAPL call expiring 2026-01-17 with $200 strike.

@dataclass
class OptionQuote:

Snapshot of an option contract quote with optional Greeks.

Greeks may be vendor-provided (Tradier/TastyTrade) or computed locally via the synthetic Black-Scholes pricer. Consumers should treat None as "not available" rather than zero.

@dataclass
class OptionChain:

Option chain snapshot for a single underlying + expiration date.

Calls and puts are stored separately so consumers can iterate one side without filtering. The underlyingPrice/asOfTimestamp pair is preserved for IV/Greeks recomputation when those are not vendor-provided.