Fix IB 0.0 sentinel handling and add warnings to quote response#7
Merged
Conversation
Treat 0.0 as an IB sentinel value for price fields (bid, ask, last). IB returns 0.0 during off-hours when market data is unavailable; no exchange-traded instrument trades at $0.00. This fix ensures the delayed/delayed_frozen fallback cascade triggers instead of showing a nonsensical $0.00 price. Changes: - Add reject_zero parameter to _to_float_or_none() for price field handling - Apply reject_zero=True to bid, ask, last in _ticker_to_quote() - Apply reject_zero=True to underlying price lookups in option_chain() - Add test cases for zero sentinel detection and fallback triggering Additionally, add warnings to JSON response envelope so clients can programmatically access warning messages alongside stderr output. Co-authored-by: Bryce Bjork <brycedbjork@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Treat 0.0 as an IB sentinel value for price fields (bid, ask, last). IB returns 0.0 during off-hours when market data is unavailable; no exchange-traded instrument trades at $0.00. This ensures the delayed/delayed_frozen fallback cascade triggers instead of showing a nonsensical $0.00 price.
Additionally adds warnings to the JSON response envelope so clients can programmatically access warning messages alongside stderr output.
Changes
reject_zeroparameter to_to_float_or_none()to filter 0.0 sentinel for price fieldsreject_zero=Trueto bid, ask, last in_ticker_to_quote()reject_zero=Trueto underlying price lookups inoption_chain()warningsfield to quote JSON response🤖 Generated with Claude Code