You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WS: _OrderbookIterator yields silently-empty Orderbook when manager has no book #257
After a gap-triggered remove_by_sid + resubscribe (or in the stale-sid race in a sibling issue), get(ticker) can return None between snapshot teardown and the new snapshot landing in the manager. The iterator hides this as a fully-empty book — a strategy reading bid/ask sees 0-depth, indistinguishable from a real market with no liquidity, and may place orders against an empty book.
asyncdef__anext__(self) ->Orderbook:
awaitself._stream.__anext__()
book=self._mgr.get(self._ticker)
ifbookisNone:
# This shouldn't happen after snapshot, but handle gracefullyreturnOrderbook(ticker=self._ticker)
returnbook
Recommended fix
Raise a KalshiSequenceGapError (or a dedicated KalshiOrderbookUnavailable) instead of returning an empty book; or skip the yield (continue) and wait for the next delta which is necessarily preceded by the resync snapshot. The inline comment already admits this "shouldn't happen" — the recovery path makes it possible.
Activity