Spaces:
Runtime error
Runtime error
| from __future__ import annotations | |
| from dataclasses import asdict, dataclass | |
| from typing import Any | |
| class UnderlyingQuote: | |
| symbol: str | |
| current_price: float | None | |
| open: float | None | |
| high: float | None | |
| low: float | None | |
| volume: int | None | |
| timestamp: str | |
| data_type: str | |
| short_name: str = "" | |
| def to_dict(self) -> dict[str, Any]: | |
| return asdict(self) | |
| class OptionContract: | |
| contract_symbol: str | |
| option_type: str | |
| expiration: str | |
| strike: float | |
| bid: float | None | |
| ask: float | None | |
| mid: float | None | |
| last_price: float | None | |
| volume: int | None | |
| open_interest: int | None | |
| implied_volatility: float | None | |
| in_the_money: bool | |
| days_to_expiration: int | |
| liquidity_warnings: list[str] | |
| def to_dict(self) -> dict[str, Any]: | |
| return asdict(self) | |
| class OptionChain: | |
| symbol: str | |
| expiration: str | |
| underlying_price: float | None | |
| calls: list[OptionContract] | |
| puts: list[OptionContract] | |
| def to_dict(self) -> dict[str, Any]: | |
| return { | |
| "symbol": self.symbol, | |
| "expiration": self.expiration, | |
| "underlying_price": self.underlying_price, | |
| "calls": [contract.to_dict() for contract in self.calls], | |
| "puts": [contract.to_dict() for contract in self.puts], | |
| } | |
| class VolSnapshot: | |
| symbol: str | |
| current_price: float | None | |
| realized_volatility: dict[str, float | None] | |
| atm_iv_by_expiration: dict[str, float | None] | |
| iv_rv_spread_by_expiration: dict[str, float | None] | |
| term_structure_slope: float | None | |
| skew_by_expiration: dict[str, float | None] | |
| def to_dict(self) -> dict[str, Any]: | |
| return asdict(self) | |