investfly.models.marketdata
Market data models
Class representing a security instrument that is traded in the market
Enum representing Security Type (STOCK, ETF, CRYPTO, FOREX, FUTURE, OPTION)
Class representing Price Quote
Enum of all valid fields on Quote object
Enum to represent BarInterval
Financial Fields supported by Invesfly
Future Product Enum. A few commented out since their contracts are not available.
Return (month_code, month_number) pairs in listed order.
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 passed anywhere a
Security is accepted — getQuote(future), getBars(future),
TradeOrder(security=future, ...), etc.
Return the last two digits of the expiry year, e.g. expiry 2026-03-20 -> 26.
Return the futures month code character from the symbol.
Handles both one-digit and two-digit year formats:
'ESU3'->'U''ESU23'->'U'
Inherited Members
Right of an option contract: CALL or PUT
Calendar date when an option contract expires (1-indexed month and day)
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.
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.
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.
Black-Scholes pricer for European-style stock/ETF options.
Annualized realized volatility of daily log returns.
Falls back to MIN_IMPLIED_VOL when the input is too short or has zero variance. Inputs are oldest-to-newest closing prices (matching Bar order convention).
Time-to-expiry in calendar years, with a minimum of 1/365 to keep BS well-defined.
Black-Scholes price + Greeks for a European option.
Greeks scaling:
- delta in [-1, 1] per share (multiply by 100 for per-contract risk).
- theta is per-year; divide by 365 for per-day theta.
- vega is per 1.00 of vol (multiply by 0.01 for per-1%-vol).
- rho is per 1.00 of rate (multiply by 0.01 for per-1%-rate). These conventions match common quant texts; UI/runtime can rescale as needed.
Find the strike whose Black-Scholes delta is closest to the target.
Search is a coarse grid scan with a refinement step. Strike grid is anchored at the
nearest multiple of strikeStep around spot and bounded at +-3 sigma * sqrt(T) from
spot, which is wide enough for typical 30-60 DTE selections and avoids unstable
far-OTM delta extrapolation.
Black-Scholes Greeks bundle returned alongside the theoretical premium.
Theoretical price + Greeks for a single contract.