Closed punitarani closed 4 months ago
Can you elaborate on what pydantic support would entail? Is the proposal to simply validate each piece of data as it comes in?
Yes validation and the functions would return an object instead of the raw json response.
For example:
class OptionChain(BaseModel):
symbol: Optional[str] = None
status: Optional[str] = None
underlying: Optional[Underlying] = None
strategy: Optional[Strategy] = None
interval: Optional[float] = None
isDelayed: Optional[bool] = None
isIndex: Optional[bool] = None
daysToExpiration: Optional[float] = None
interestRate: Optional[float] = None
underlyingPrice: Optional[float] = None
volatility: Optional[float] = None
callExpDateMap: Optional[Dict[str, OptionContractMap]] = None
putExpDateMap: Optional[Dict[str, OptionContractMap]] = None
def get_option_chain(...) -> OptionChain:
...
path = '/marketdata/v1/chains'
data = self._get_request(path, params)
return OptionChain.model_validate(data.json())
I see the appeal but I'm closing this as WON'T FIX for a few reasons:
Are there plans to add pydantic support?
We can easily generate the models from the OpenAPI spec. Models: https://gist.github.com/punitarani/5d12b575a7a07d850790e121fda8a65b
Pydantic model validation time is negligible.
Options Chain API call times
Options Chain Pydantic Validation Times: