Repository: OpenBB-finance/OpenBBTerminal
File: openbb_platform/core/openbb_core/provider/standard_models/options_snapshots.py (Python)

Code before:


class OptionsSnapshotsData(Data):
    """Options Snapshots Data."""

    underlying_symbol: str = Field(description="Ticker symbol of the underlying asset.")
    contract_symbol: str = Field(description="Symbol of the options contract.")
    expiration: dateType = Field(description="Expiration date of the options contract.")
    dte: Optional[int] = Field(
        default=None,
        description="Number of days to expiration of the options contract.",
    )
    strike: float = Field(
        description="Strike price of the options contract.",
        json_schema_extra={"x-unit_measurement": "currency"},
    )
    option_type: str = Field(description="The type of option.")
    volume: Optional[int] = Field(
        default=None,
        description=DATA_DESCRIPTIONS.get("volume", ""),
    )
    open_interest: Optional[int] = Field(
        default=None,
        description="Open interest at the time.",
    )
    last_price: Optional[float] = Field(
        default=None,
        description="Last trade price at the time.",
        json_schema_extra={"x-unit_measurement": "currency"},
    )
    last_size: Optional[int] = Field(
        default=None,
        description="Lot size of the last trade.",
    )
    last_timestamp: Optional[datetime] = Field(
        default=None,
        description="Timestamp of the last price.",
    )
    open: Optional[float] = Field(
        default=None,
        description=DATA_DESCRIPTIONS.get("open", ""),
        json_schema_extra={"x-unit_measurement": "currency"},
    )
    high: Optional[float] = Field(
        default=None,
        description=DATA_DESCRIPTIONS.get("high", ""),
        json_schema_extra={"x-unit_measurement": "currency"},
    )
    low: Optional[float] = Field(
        default=None,
        description=DATA_DESCRIPTIONS.get("low", ""),

Review comment (suggestion):
Altough the `reference.json` seems to be well generated (default should be `null`, I believe) this syntax feels weird to me.
Should this be `Optional[List[int]` (and then defaults to `None`)? If we look at the 2nd part of the union it doesn't make sense: `List[None]` ([None,None, None]) - it's possible but odd 

Code after:


class OptionsSnapshotsData(Data):
    """Options Snapshots Data."""

    underlying_symbol: List[str] = Field(
        description="Ticker symbol of the underlying asset."
    )
    contract_symbol: List[str] = Field(description="Symbol of the options contract.")
    expiration: List[dateType] = Field(
        description="Expiration date of the options contract."
    )
    dte: List[Union[int, None]] = Field(
        default_factory=list,
        description="Number of days to expiration of the options contract.",
    )
    strike: List[float] = Field(
        description="Strike price of the options contract.",
        json_schema_extra={"x-unit_measurement": "currency"},
    )
    option_type: List[str] = Field(description="The type of option.")
    volume: List[Union[int, None]] = Field(
        default_factory=list,
        description=DATA_DESCRIPTIONS.get("volume", ""),
    )
    open_interest: List[Union[int, None]] = Field(
        default_factory=list,
        description="Open interest at the time.",
    )
    last_price: List[Union[float, None]] = Field(
        default_factory=list,
        description="Last trade price at the time.",
        json_schema_extra={"x-unit_measurement": "currency"},
    )
    last_size: List[Union[int, None]] = Field(
        default_factory=list,
        description="Lot size of the last trade.",
    )
    last_timestamp: List[Union[datetime, None]] = Field(
        default_factory=list,
        description="Timestamp of the last price.",
    )
    open: List[Union[float, None]] = Field(
        default_factory=list,
        description=DATA_DESCRIPTIONS.get("open", ""),
        json_schema_extra={"x-unit_measurement": "currency"},
    )
    high: List[Union[float, None]] = Field(
        default_factory=list,
        description=DATA_DESCRIPTIONS.get("high", ""),
        json_schema_extra={"x-unit_measurement": "currency"},