Skip to content

Reject a ChoppinessIndex period of one - #9727

Open
mkzung wants to merge 1 commit into
QuantConnect:masterfrom
mkzung:bug-9724-choppiness-index-period-one
Open

Reject a ChoppinessIndex period of one#9727
mkzung wants to merge 1 commit into
QuantConnect:masterfrom
mkzung:bug-9724-choppiness-index-period-one

Conversation

@mkzung

@mkzung mkzung commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Description

ChoppinessIndex now rejects a period below two in its constructor.

Related Issue

Closes #9724

Motivation and Context

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 took the value without complaint, so the failure landed on the data rather than on the call that was wrong.

ValueAtRisk, Beta, Correlation and Covariance already 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 from ValueAtRiskTests.PeriodBelowMinimumThrows.

Keeping the test and reverting only Indicators/ChoppinessIndex.cs:

Failed!  Failed: 1, Passed: 11, Total: 12

with the source in place:

Passed!  Failed: 0, Passed: 12, Total: 12

The red run reports no exception at all at construction, which is the defect.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChoppinessIndex throws OverflowException at a period of one

1 participant