fix(technical): snap missing fib start_date to the date nearest start_date - #7583
Open
Bortlesboat wants to merge 3 commits into
Open
fix(technical): snap missing fib start_date to the date nearest start_date#7583Bortlesboat wants to merge 3 commits into
Bortlesboat wants to merge 3 commits into
Conversation
…date calculate_fib_levels looked up the nearest index entry for end_date when start_date was missing from the index, collapsing the retracement span to a single date and returning identical Fibonacci levels with a misleading warning. Look up start_date instead.
Contributor
|
Hi @Bortlesboat, thanks for the PR. Can you please check the #7489 to verify if the issue still exists there? The technical extension has been refactored, so lots of the code has changed upstream. Thanks! |
Contributor
Author
|
Hi @deeleeramone, thanks for the pointer — just re-checked against current The bug is still there: So any |
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.
Why
calculate_fib_levelsinopenbb_technical/helpers.pyhandles astart_datethat isn't in the index by snapping to the nearest available date — but the lookup searches forend_dateinstead ofstart_date(a copy-paste from the end-date branch right below it):So any start date that isn't an exact index entry (a weekend or holiday — easy to hit since the index is trading days) silently collapses the retracement to the end date. Reproduction on a 60-business-day frame with a Saturday
start_date:Every Fibonacci level comes back equal to the same price, and the warning reports the wrong "nearest" date, so the result looks plausible unless you inspect it.
What
One-line fix: look up
start_datein theget_indexercall. With the fix, the same input snaps to Friday 2024-01-05 and the retracement spans the full range.Added a regression test (
test_calculate_fib_levels_snaps_missing_start_date_to_nearest) that pins the snapped date, the preserved end date, and a non-zero span; it fails on current develop and passes with the fix. All 10 tests intest_technical_helpers.pypass;blackandruffclean.