tastyware / tastytrade

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

Make additional market metrics optional #105

Closed Mytak closed 1 year ago

Mytak commented 1 year ago

Description

Related issue(s)

Fixes ...

Pre-merge checklist

Please note that, in order to pass the tests, you'll need to set up your Tastytrade credentials as repository secrets on your local fork. Read more at CONTRIBUTING.md.

Graeme22 commented 1 year ago

Thanks for this, can you post the code that didn't work for you?

Also, please make sure to follow the steps in CONTRIBUTING.md to run the tests on your fork.

Mytak commented 1 year ago

Thanks for this, can you post the code that didn't work for you?

Also, please make sure to follow the steps in CONTRIBUTING.md to run the tests on your fork.

Here is the code:

ticker = ' LLYVK' self.session = ProductionSession(self.user, self.password) // Valid user and password extracted from keyring metrics = tastytrade.metrics.get_market_metrics(self.session, ticker)

Here is the error:

File "/home/user/.local/lib/python3.10/site-packages/tastytrade/metrics.py", line 114, in get_market_metrics return [MarketMetricInfo(entry) for entry in data] File "/home/user/.local/lib/python3.10/site-packages/tastytrade/metrics.py", line 114, in return [MarketMetricInfo(entry) for entry in data] File "pydantic/main.py", line 341, in pydantic.main.BaseModel.init pydantic.error_wrappers.ValidationError: 13 validation errors for MarketMetricInfo implied-volatility-index field required (type=value_error.missing) implied-volatility-index-5-day-change field required (type=value_error.missing) tos-implied-volatility-index-rank field required (type=value_error.missing) tw-implied-volatility-index-rank field required (type=value_error.missing) tos-implied-volatility-index-rank-updated-at field required (type=value_error.missing) implied-volatility-index-rank-source field required (type=value_error.missing) implied-volatility-updated-at field required (type=value_error.missing) liquidity-rating field required (type=value_error.missing) option-expiration-implied-volatilities field required (type=value_error.missing) beta field required (type=value_error.missing) corr-spy-3month field required (type=value_error.missing) price-earnings-ratio field required (type=value_error.missing) earnings-per-share field required (type=value_error.missing)

Sorry for the missing checks, I added the secrets TT_USENAME and TT_PASSWORD as described in CONTRIBUTING.md but the checks did not run. I could not find out how to activate them on my fork ... any advice is appreciated

Mytak commented 1 year ago

Some additional information: I am trying to get the iv_rank of the ticker LLYVK and I just saw in the tastytrade platform that iv_rank is not available ...

Graeme22 commented 1 year ago

Did you go to the "Actions" page and enable actions for your fork? If so, you should be able to trigger the test manually from the "Actions" page, and from now on it'll run automatically whenever you make changes.

Mytak commented 1 year ago

After enabling manual workflow triggering, I ran the checks and got the following errors:

Checks.txt

The errors do not seem to be related to my code changes

Graeme22 commented 1 year ago

Ah! Nice catch. Tests don't work for people who only have one TT account... Oops! I'll fix that

Graeme22 commented 1 year ago

Please check out the latest commit and try again.

Mytak commented 1 year ago

OK, now the checks ran successfully.