Reject a ChoppinessIndex period of one - #9727
Open
mkzung wants to merge 1 commit into
Open
Conversation
ComputeNextValue divides by Math.Log10(_period). At a period of one that divisor is zero, so the double is infinite and the cast to decimal throws OverflowException on the first update after warm-up. The constructor accepts the value, so the failure lands on the data rather than on the call that is wrong. Beta, Correlation, Covariance and ValueAtRisk all reject a period their formula cannot use, with the same message shape.
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.
Description
ChoppinessIndexnow rejects a period below two in its constructor.Related Issue
Closes #9724
Motivation and Context
ComputeNextValuedivides byMath.Log10(_period). At a period of one that divisor is zero, so the double is infinite and the cast to decimal throwsOverflowExceptionon the first update after warm-up. The constructor took the value without complaint, so the failure landed on the data rather than on the call that was wrong.ValueAtRisk,Beta,CorrelationandCovariancealready reject a period their formula cannot use, with one message shape between them. This uses the same sentence.Requires Documentation Change
No.
How Has This Been Tested?
ChoppinessIndexTests.PeriodBelowMinimumThrows, copied fromValueAtRiskTests.PeriodBelowMinimumThrows.Keeping the test and reverting only
Indicators/ChoppinessIndex.cs:with the source in place:
The red run reports no exception at all at construction, which is the defect.
Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>