Skip to content

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#276
hvkc wants to merge 1 commit intotastyware:masterfrom
hvkc:master

Conversation

@hvkc
Copy link
Copy Markdown

@hvkc hvkc commented Oct 16, 2025

Summary

Fixes a Pydantic validation error when fetching certain futures contracts that don't include the closing-only-date field in API responses.

Problem

When attempting to load instrument data for futures contracts like /1OZZ5 (1oz gold futures) using Future.get(), the SDK raises a Pydantic validation error because the API response is missing the required closing-only-date field.

Solution

Changed the closing_only_date field in the Future class from a required field to an optional field with a default value of None.

Changes

  • Modified tastytrade/instruments.py line 872: closing_only_date: dateclosing_only_date: Optional[date] = None

Testing

  • Ran make lint - All checks passed ✓
  • Ran make test - 126 tests passed, 96.46% coverage (exceeds 95% requirement) ✓
  • No new test failures introduced
  • Baseline test failures remain unchanged (unrelated to this fix)

🤖 Generated with Claude Code

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]>
@Graeme22
Copy link
Copy Markdown
Member

Python 3.9 support just got dropped so I added this with the date | None = None syntax. Thanks anyway!

@Graeme22 Graeme22 closed this Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants