Repository navigation
Compare indicators against TA-Lib reference data - #536
Merged
Merged
Conversation
Add internal/talibcompat, which checks each indicator that has a TA-Lib counterpart against TA-Lib output computed with the same parameters. testdata/generate.py produces two 300-bar datasets: a random walk, and one rounded to a 0.5 tick so that ties occur. It writes the OHLCV inputs and the TA-Lib outputs to CSV. Only the generator needs TA-Lib; the Go test reads the CSV with the standard library, so the module stays free of external dependencies. Each test case records how it compares: a scale factor where the library returns a ratio and TA-Lib a percentage (#533), a warm-up bar where EMA seeding differs (#535), or a skip that links the issue tracking a known difference (#520, #521-#532, #534). Add ./internal/... to INDICATOR_BASE so that task runs these tests and the existing internal/apiconsistency tests, which it did not run before. Include README changes that task regenerates from earlier commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #536 +/- ##
==========================================
- Coverage 91.78% 91.75% -0.03%
==========================================
Files 240 240
Lines 7835 7835
==========================================
- Hits 7191 7189 -2
- Misses 551 553 +2
Partials 93 93 ☔ 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
Adds
internal/talibcompat, a test package that checks each indicator with a TA-Lib counterpart against TA-Lib output computed with the same parameters. TA-Lib serves as the reference implementation for indicator math.testdata/generate.pybuilds two seeded 300-bar OHLCV datasets and writes the inputs plus the TA-Lib reference outputs to CSV:walk: a random walk whose prices practically never repeat;ticks: prices rounded to a 0.5 tick, so equal highs, lows and closes occur and tie handling is exercised.talibcompat_test.goreads the CSVs with the standard library and compares 72 cases (about 100 outputs) per dataset, with a relative tolerance of 1e-8.pip install ta-lib==0.8.3 numpy). The Go module and CI stay dependency-free, and the CSVs are committed (about 630 KB).How known differences are recorded
Each case states how it compares, so every intentional difference is explicit in one place:
scalefromBarskipResolving one of those issues means removing its
skipline. I checked that every skipped case currently fails when unskipped. The one exception is IBS onwalk, which has no bar where high equals low.Two passing cases,
AtrWithRmaandSuperTrendWithRma, show that the existingNewAtrWithMa/NewSuperTrendWithMaextension points already match TA-Lib exactly with Wilder's smoothing (relevant to #526 and #527).Other changes
taskfile.yml: adds./internal/...toINDICATOR_BASE. Without it,task(and so CI) ran neither this package nor the existinginternal/apiconsistencytests. Both pass.trend/README.md,momentum/README.md: line-number updates thattask docsregenerates from earlier commits (Keep a 0 in the first MovingMin and MovingMax window #516, Report the completed TD Sequential countdown #517).Test plan
task(fmt, lint, test with-race, docs) passes locallywalk🤖 Generated with Claude Code