.ib.feed: only set `feed_is_live` after first quote

Move `feed_is_live.set()` to after receiving the first valid
quote instead of setting early on venue-closed path. Prevents
sampler registration when no live data expected.

Also,
- drop redundant `.set()` call in quote iteration loop
- add TODO note about sleeping until venue opens vs forever
- init `first_quote: dict` early for consistency

(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
refresh_annots
Gud Boi 2026-01-30 18:50:26 -05:00
parent f73b981173
commit 48493e50b0
1 changed files with 7 additions and 5 deletions

View File

@ -1115,6 +1115,7 @@ async def stream_quotes(
con: Contract = details.contract
first_ticker: Ticker|None = None
first_quote: dict[str, Any] = {}
timeout: float = 1.6
with trio.move_on_after(timeout) as quote_cs:
@ -1167,15 +1168,14 @@ async def stream_quotes(
first_quote,
))
# it's not really live but this will unblock
# the brokerd feed task to tell the ui to update?
feed_is_live.set()
# block and let data history backfill code run.
# XXX obvi given the venue is closed, we never expect feed
# to come up; a taskc should be the only way to
# terminate this task.
await trio.sleep_forever()
#
# ^^XXX^^TODO! INSTEAD impl a `trio.sleep()` for the
# duration until the venue opens!!
# ?TODO, we could instead spawn a task that waits on a feed
# to start and let it wait indefinitely..instead of this
@ -1199,6 +1199,9 @@ async def stream_quotes(
'Rxed init quote:\n'
f'{pformat(first_quote)}'
)
# signal `.data.feed` layer that mkt quotes are LIVE
feed_is_live.set()
cs: trio.CancelScope|None = None
startup: bool = True
iter_quotes: trio.abc.Channel
@ -1252,7 +1255,6 @@ async def stream_quotes(
# tick.
ticker = await iter_quotes.receive()
quote = normalize(ticker)
feed_is_live.set()
fqme: str = quote['fqme']
await send_chan.send({fqme: quote})