Skip to content

Index ATR prices by position for point-and-figure box sizes - #704

Open
xvruipeng-cyber wants to merge 1 commit into
matplotlib:masterfrom
xvruipeng-cyber:fix/atr-position-index
Open

xvruipeng-cyber wants to merge 1 commit into
matplotlib:masterfrom
xvruipeng-cyber:fix/atr-position-index

Conversation

@xvruipeng-cyber

@xvruipeng-cyber xvruipeng-cyber commented Oct 22, 2026 •

Copy link
Copy Markdown

Summary

Fixes #686.

_calculate_atr documents list inputs and indexes them by position. Point & Figure passes df.High, df.Low, and df.Close, which are Series on a DatetimeIndex. On pandas 2 that integer lookup warned and fell back to position. On pandas 3 it raises KeyError, so box_size='atr' cannot build a chart. Renko already passes arrays, and integer indexing on an array is positional.

The function now converts highs, lows, and closes with numpy.asarray before the loop, so both callers use positions and keep the same true-range values.

Test plan

  • pytest -o addopts= tests/test_atr.py: a 2-bar ATR on a datetime-indexed Series, a ndarray, and a list all return 3
  • Plot an existing point-and-figure sample with box_size='atr' on pandas 3

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.

Bug Report:

1 participant