Skip to content

Fix QuestDB BookQuest IndexError when depth exceeds book levels (#1042)#1110

Open
dimitryLMEX wants to merge 1 commit into
bmoscon:masterfrom
LMEXofficial:fix/questdb-bookquest-indexerror
Open

Fix QuestDB BookQuest IndexError when depth exceeds book levels (#1042)#1110
dimitryLMEX wants to merge 1 commit into
bmoscon:masterfrom
LMEXofficial:fix/questdb-bookquest-indexerror

Conversation

@dimitryLMEX
Copy link
Copy Markdown

@dimitryLMEX dimitryLMEX commented May 26, 2026

Problem

BookQuest.__call__ iterates range(self.depth) unconditionally for both bids and asks. When the order book has fewer levels than self.depth, calling book.book.bids.index(i) raises an IndexError.

Closes #1042.

Fix

Clamp the iteration range using min(self.depth, len(...)) for both sides before building the field list:

bid_depth = min(self.depth, len(book.book.bids))
ask_depth = min(self.depth, len(book.book.asks))

This is a minimal, non-breaking change — when the book is fully populated the behaviour is identical to before.

Testing

Verified with flake8 cryptofeed/backends/quest.py (no warnings).

🤖 Generated with Claude Code

bmoscon#1042)

When self.depth is greater than the number of available bid or ask levels,
calling book.book.bids.index(i) raises an IndexError. Fix by clamping the
iteration range to min(self.depth, len(...)) for both bids and asks.
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.

quest backend receiving book with less depth that specified and crash

1 participant