tastyware / tastytrade

An unofficial, sync/async Python SDK for Tastytrade!
https://tastyworks-api.rtfd.io
MIT License
126 stars 43 forks source link

Pydantic Validation Error when Running get_market_metrics() #112

Closed joshuabuildsthings closed 1 year ago

joshuabuildsthings commented 1 year ago

Describe the bug

ValidationError Traceback (most recent call last)
Cell In[3], line 3
      1 from tastytrade.metrics import get_market_metrics
----> 3 metrics =  get_market_metrics(session, 'spy')
      5 display(metrics)

File ~\AppData\Roaming\Python\Python310\site-packages\tastytrade\metrics.py:114, in get_market_metrics(session, symbols)
    110 validate_response(response)
    112 data = response.json()['data']['items']
--> 114 return [MarketMetricInfo(**entry) for entry in data]

File ~\AppData\Roaming\Python\Python310\site-packages\tastytrade\metrics.py:114, in <listcomp>(.0)
    110 validate_response(response)
    112 data = response.json()['data']['items']
--> 114 return [MarketMetricInfo(**entry) for entry in data]

File lib\site-packages\pydantic\main.py:341, in pydantic.main.BaseModel.__init__()

ValidationError: 1 validation error for MarketMetricInfo
liquidity-running-state -> updated-at
  field required (type=value_error.missing)

How to reproduce

from tastytrade.metrics import get_market_metrics

metrics =  get_market_metrics(session, 'spy')

display(metrics)
Graeme22 commented 1 year ago

Thanks for opening an issue! Were you using a production or certification session?

joshuabuildsthings commented 1 year ago

@Graeme22 - Thanks for the rapid response! I was using a production session. Debug output confirmed I was properly connected.

I swapped this library out for the "official" Python SDK and was able to make the request & pull the data.

Graeme22 commented 1 year ago

Gotcha. It's fixed in the master branch if you want to do a local install. It'll be in the next release as well. Cheers