Repository navigation
fix(grid): use Wilder ATR for adaptive grid bounds (inline, no new dependency) - #387
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
_compute_atr averaged true range with rolling(period, min_periods=1).mean(), an SMA that also returned a value after a single bar. Compute Wilder's RMA-smoothed ATR with fin-primitives instead, return 0.0 until period bars exist so the existing range fallback applies, and keep the pandas path when the package is unavailable. Signed-off-by: Matthew Charles Busel <mattbusel@gmail.com>
bf67059 to
e69cf37
Compare
|
Thanks for identifying the SMA-vs-Wilder ATR issue and for the clear disclosure about maintaining
Please also run the complete repository CI/DCO/security checks after updating the branch. Once those changes are in place, we can review the revised implementation again. |
Seed with the mean of the first period true ranges, then Wilder's RMA over the full frame. Validate OHLC columns, skip non-finite bars, log when ATR is unavailable, and keep the 0.0 warmup so the range/min-width fallback applies. Removes fin-primitives from requirements.txt and requirements.lock. Signed-off-by: Matthew Charles Busel <mattbusel@gmail.com>
|
Thanks for the detailed review. Revised in 94eee13:
|
|
|
Thanks for the quick and thorough revision. I reviewed
I also ran the updated One remaining documentation item: please update the PR title/body details where necessary, especially the current description that still says the implementation uses The latest head currently only shows the SonarCloud checks. Once the full repository CI/DCO/security/coverage checks have run successfully and the PR description is current, this should be ready for final approval and merge. |
|
Thanks for checking it locally. I've updated the title and description to cover the inline Wilder implementation and the latest test results. The Backend CI, Security CI, DCO and REUSE runs on 94eee13 show |



The adaptive grid sized its bounds from a simple moving average of true range, not Wilder's ATR, so the bounds reacted differently from the ATR traders see on their charts. This PR implements Wilder ATR inline in
grid_runtime.py, with no new dependency.What changes
_compute_atrseeds with the mean of the firstperiodtrue ranges (the first TR is high - low), then applies Wilder's RMA,atr = (atr*(period-1) + tr)/period, over the full frame. There is no window truncation.periodvalid bars returns 0.0, as before, so the existing range/min-width fallback takes over.Tests (
tests/test_grid_runtime.py, 14 tests)periodTRs.period - 1, exactlyperiod, and a long history (period*10 + 37) that uses the full frame.adaptiveBounds: false).All grid-related test files: 92 passed.
ruff check app scripts testsis clean, bandit reports nothing on the module, and both commits are signed off for DCO.Rollback: revert the PR. There are no data or config changes.