Fix: min/max price filters on OptionsChainInput are never validated (#32)#33
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #33 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 52 52
Lines 2284 2293 +9
=========================================
+ Hits 2284 2293 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
MarketDataDev02
approved these changes
Jun 8, 2026
# Conflicts: # src/tests/test_input_types.py
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.
Fix: min/max price filters on
OptionsChainInputare never validatedCloses #32
Problem
OptionsChainInputdeclared amodel_validatormeant to enforcemin ≤ maxonthe bid/ask price filters, but the check never ran. It reused the date-only
helper
_validate_min_max_dates, which compares the two values only when bothpass
check_is_date(...). Bid/ask filters arefloat, so the comparison wasskipped entirely and an inverted range was accepted silently:
This sent obviously invalid requests to the API instead of rejecting them
client-side, defeating the purpose of the validator. There was also a typo in
the local variable (
params_typles).Changes
exceptions.py— introduced a common baseMinMaxValidationError, withtwo specialized subclasses sharing it:
MinMaxValueValidationError— numeric ranges.MinMaxDateValidationError— date ranges (previously a direct subclass ofBaseMarketdataException; now also catchable asMinMaxValidationError).input_types/base.py— added a numeric-aware helper_validate_min_max_value(min_param, max_param)that raisesMinMaxValueValidationErrorwhen both bounds are set andmin > max. Theexisting
_validate_min_max_datesis kept for genuine date ranges.input_types/options.py—OptionsChainInput.validate_inputnow uses_validate_min_max_valuefor the(min_bid, max_bid)and(min_ask, max_ask)pairs, and fixed the
params_typles→params_tuplestypo.Why a separate helper instead of reusing the date helper
Date filters can be
datetime.dateor strings in several formats, so they needthe
check_is_dategating. Price filters are plain numbers and just need adirect
min > maxcomparison. Keeping the two helpers separate avoidsoverloading one path and keeps each validation intent explicit.
Scope note
min_open_interest,min_volume,max_bid_ask_spread, andmax_bid_ask_spread_pcthave nomin/maxcounterpart in the model, so there areno other ordered numeric pairs to validate.