Document HMA's math.Round period-derivation as a variant choice - #486
Merged
Conversation
Reference HMA implementations disagree on whether to truncate or round period/2 and sqrt(period) when deriving WMA1/WMA3 sub-periods. This documents the current math.Round-based behavior as a deliberate, internally consistent choice rather than a bug, to help anyone diffing this library's HMA output against another platform's. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xv4stuAb6WuQ8rPZ4cupLp
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #486 +/- ##
==========================================
+ Coverage 92.05% 92.10% +0.05%
==========================================
Files 231 231
Lines 7603 7603
==========================================
+ Hits 6999 7003 +4
+ Misses 521 517 -4
Partials 83 83 ☔ 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.
Summary
trend/hma.go's use ofmath.Roundfor bothperiod/2andsqrt(period)when deriving the WMA1/WMA3 sub-periods is a deliberate, internally consistent choice, not a bug.period/2rather than rounding it, most roundsqrt(period)), which can explain small output differences for odd period values when comparing this library's HMA against another platform's.trend/hma.go.Test plan
go build ./...go vet ./...gofmt -l trend/hma.go(clean; pre-existing unrelated gofmt findings elsewhere in the repo are untouched by this change)go test ./...(all packages pass, zero fixture changes)git diffconfirms only comments were added/changed🤖 Generated with Claude Code
https://claude.ai/code/session_01Xv4stuAb6WuQ8rPZ4cupLp