.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-coderefresh_annots
parent
f73b981173
commit
48493e50b0
|
|
@ -1115,6 +1115,7 @@ async def stream_quotes(
|
||||||
|
|
||||||
con: Contract = details.contract
|
con: Contract = details.contract
|
||||||
first_ticker: Ticker|None = None
|
first_ticker: Ticker|None = None
|
||||||
|
first_quote: dict[str, Any] = {}
|
||||||
|
|
||||||
timeout: float = 1.6
|
timeout: float = 1.6
|
||||||
with trio.move_on_after(timeout) as quote_cs:
|
with trio.move_on_after(timeout) as quote_cs:
|
||||||
|
|
@ -1167,15 +1168,14 @@ async def stream_quotes(
|
||||||
first_quote,
|
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.
|
# block and let data history backfill code run.
|
||||||
# XXX obvi given the venue is closed, we never expect feed
|
# XXX obvi given the venue is closed, we never expect feed
|
||||||
# to come up; a taskc should be the only way to
|
# to come up; a taskc should be the only way to
|
||||||
# terminate this task.
|
# terminate this task.
|
||||||
await trio.sleep_forever()
|
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
|
# ?TODO, we could instead spawn a task that waits on a feed
|
||||||
# to start and let it wait indefinitely..instead of this
|
# to start and let it wait indefinitely..instead of this
|
||||||
|
|
@ -1199,6 +1199,9 @@ async def stream_quotes(
|
||||||
'Rxed init quote:\n'
|
'Rxed init quote:\n'
|
||||||
f'{pformat(first_quote)}'
|
f'{pformat(first_quote)}'
|
||||||
)
|
)
|
||||||
|
# signal `.data.feed` layer that mkt quotes are LIVE
|
||||||
|
feed_is_live.set()
|
||||||
|
|
||||||
cs: trio.CancelScope|None = None
|
cs: trio.CancelScope|None = None
|
||||||
startup: bool = True
|
startup: bool = True
|
||||||
iter_quotes: trio.abc.Channel
|
iter_quotes: trio.abc.Channel
|
||||||
|
|
@ -1252,7 +1255,6 @@ async def stream_quotes(
|
||||||
# tick.
|
# tick.
|
||||||
ticker = await iter_quotes.receive()
|
ticker = await iter_quotes.receive()
|
||||||
quote = normalize(ticker)
|
quote = normalize(ticker)
|
||||||
feed_is_live.set()
|
|
||||||
fqme: str = quote['fqme']
|
fqme: str = quote['fqme']
|
||||||
await send_chan.send({fqme: quote})
|
await send_chan.send({fqme: quote})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue