Skip to content

[BUG] error when displaying very short candlestick plots (length 2 or 3) #556

Description

@hartes-us

Requirements (place an x in each of the [ ])**

  • [x ] I realize finplot is not a web lib. (Hint: it's native!)
  • [x ] I've read the snippets and not found what I'm looking for.
  • [x ] I've searched for any related issues and avoided creating a duplicate issue.
  • [x ] I've updated finplot (pip install -U finplot).
  • [x ] I've supplied the required data to run my code below.

Describe the bug

when plotting three candles I get the error:
IndexError: index 1749462450000000000 is out of bounds for axis 0 with size 3

I could track it down to:

try exact match before approximate match

if all(xs.isin(ts)):
    exact = datasrc.index[ts].to_list()
    if len(exact) == len(ts):
        return exact

in def _pdtime2index(ax, ts, any_end=False, require_time=False):

specifically,

xs
0 1749462450000000000
1 1749462450000000000
2 1749462455000000000
Name: datetime, dtype: int64

and

ts
0 1749462450000000000
1 1749462451000000000
2 1749462452000000000
3 1749462453000000000
4 1749462454000000000
5 1749462455000000000
dtype: int64

so xs is in ts but taking ts as index doesn't seem to make sense. For "normal" operation I never trigger a breakpoint in the exact match function. I would try to fix it but honestly cannot understand the intention.
If I comment out the part for checking for exact match everything seems to work.

Reproducible in:

OS: debian bookworm
finplot version: latest
pyqtgraph version: 0.13.7
pyqt version: 6.8.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions