tastyware / tastytrade

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

get_market_metrics() Validation Error #87

Closed cdsmith1963 closed 1 year ago

cdsmith1963 commented 1 year ago

Receiving Validation Error when using get_market_metrics(). See error log/dump below. Unfortunately I'm not a pedantic expert and wasn't able to do much debugging/digging to figure out what was going on. Did tastytrade possibly alter the MarketMetricInfo() data structure?


ValidationError Traceback (most recent call last) ~\Documents\StockMachine\TWBot\vertical.py in 45 dfQuotes = asyncio.run(getOptions.getQuotes(session, underList)) 46 print(dfQuotes) ---> 47 symbolInfo = metrics.get_market_metrics(session=session, symbols=['SPY']) 48 print(symbolInfo) 49 sys.exit()

~\anaconda3-new\lib\site-packages\tastytrade\metrics.py in get_market_metrics(session, symbols) 112 data = response.json()['data']['items'] 113 --> 114 return [MarketMetricInfo(**entry) for entry in data] 115 116

~\anaconda3-new\lib\site-packages\tastytrade\metrics.py in (.0) 112 data = response.json()['data']['items'] 113 --> 114 return [MarketMetricInfo(**entry) for entry in data] 115 116

~\anaconda3-new\lib\site-packages\pydantic\main.cp39-win_amd64.pyd in pydantic.main.BaseModel.init()

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

How to reproduce Post your code so the source of the problem can be identified: symbolInfo = metrics.get_market_metrics(session=session, symbols=['SPY']) print(symbolInfo)

session variable is a ProductionSession object and works successfully using several other modules activities (e.g. get_accounts(session)).