Make closing_only_date optional in Future class#276
Closed
hvkc wants to merge 1 commit intotastyware:masterfrom
hvkc:master
Closed
Make closing_only_date optional in Future class#276hvkc wants to merge 1 commit intotastyware:masterfrom hvkc:master
hvkc wants to merge 1 commit intotastyware:masterfrom
hvkc:master
Conversation
The closing-only-date field is not always present in API responses for certain futures contracts (e.g., /1OZZ5 1oz gold futures). This change makes the field optional to prevent Pydantic validation errors when the field is missing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Member
|
Python 3.9 support just got dropped so I added this with the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a Pydantic validation error when fetching certain futures contracts that don't include the
closing-only-datefield in API responses.Problem
When attempting to load instrument data for futures contracts like
/1OZZ5(1oz gold futures) usingFuture.get(), the SDK raises a Pydantic validation error because the API response is missing the requiredclosing-only-datefield.Solution
Changed the
closing_only_datefield in theFutureclass from a required field to an optional field with a default value ofNone.Changes
tastytrade/instruments.pyline 872:closing_only_date: date→closing_only_date: Optional[date] = NoneTesting
make lint- All checks passed ✓make test- 126 tests passed, 96.46% coverage (exceeds 95% requirement) ✓🤖 Generated with Claude Code