Add IdlePeriod() to PringsSpecialK - #422
Merged
Merged
Conversation
Every other indicator in this library exposes IdlePeriod() so callers know how many leading values to skip before the output channel starts yielding real data. PringsSpecialK never did, even though ComputeWithContext already computes exactly this value internally as maxIdle to align its SMA(ROC(...)) branches -- it just never exposed it. Callers had no way to know how many leading dates correspond to its (500+ period) warm-up. Expose that same computation as IdlePeriod(), and update TestPringsSpecialKComputeBasicOutput to call it instead of hand-reconstructing an equivalent value from unrelated Sma/Roc instances, and add a direct IdlePeriod test. Fixes #418 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #422 +/- ##
==========================================
- Coverage 92.31% 92.29% -0.03%
==========================================
Files 229 229
Lines 7276 7278 +2
==========================================
Hits 6717 6717
- Misses 472 474 +2
Partials 87 87 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Closes #418.
What was missing
Every other indicator in this library implements
IdlePeriod() int(the subject of the consistency sweep in #413) so a caller knows how many leading values to skip before the output channel starts yielding real data.PringsSpecialKdidn't, even thoughComputeWithContextalready computes exactly this value internally:used to align every other SMA(ROC(...)) branch to the slowest one. Without an exposed
IdlePeriod(), a generic caller (e.g. the indicator registry in #416) has no way to know how many leading dates correspond to its warm-up — which, with the default periods, is 724.Its own test already worked around this by reconstructing an equivalent value from unrelated standalone
Sma/Rocinstances rather than calling a method on the type itself — a sign the type should expose it.Fix
TestPringsSpecialKComputeBasicOutputnow callsIdlePeriod()on the actual instance instead of hand-reconstructing the number from a throwawaySma(530)/Roc(195)pair (which happened to total the same value only because(530-1)+195 == 194+530) — it already passed before this change and still does, confirming the new method's value matches what that test independently expected all along. AddedTestPringsSpecialKIdlePeriodas a direct check.Test plan
go test -race -cover ./momentum/...— 92.4% coveragego vet,staticcheck,gosecclean onmomentum/(an unrelated pre-existingrevivefinding inrvi.go, a file this PR doesn't touch, is untouched)go build ./...and the fullINDICATOR_BASEtest suite (asset,backtest,cmd,helper,momentum,strategy,trend,volatility,volume) pass🤖 Generated with Claude Code