Use `.ib.venues.is_venue_open()` in `.feed`
In `.ib.feed.stream_quotes()` specifically that is since time-range checking code was moved to the new sub-mod. Deats, - drop import of old `is_current_time_in_range()` from `._util` - change `get_bars()` sig: `end_dt`/`start_dt` to `datetime|None` - comment-out `breakpoint()` in `open_history_client()` Styling, - add multiline style to conditionals and tuple unpacks - fix type annotation: `Contract|None` vs `Contract | None` - fix backticks in comment: `ib_insync` vs `ib_async` (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codecont_hist_fixes
parent
ba575d93ea
commit
f502851999
|
|
@ -69,9 +69,9 @@ from .api import (
|
|||
Contract,
|
||||
RequestError,
|
||||
)
|
||||
from .venues import is_venue_open
|
||||
from ._util import (
|
||||
data_reset_hack,
|
||||
is_current_time_in_range,
|
||||
)
|
||||
from .symbols import get_mkt_info
|
||||
|
||||
|
|
@ -203,7 +203,8 @@ async def open_history_client(
|
|||
latency = time.time() - query_start
|
||||
if (
|
||||
not timedout
|
||||
# and latency <= max_timeout
|
||||
# and
|
||||
# latency <= max_timeout
|
||||
):
|
||||
count += 1
|
||||
mean += latency / count
|
||||
|
|
@ -219,8 +220,10 @@ async def open_history_client(
|
|||
)
|
||||
if (
|
||||
end_dt
|
||||
and head_dt
|
||||
and end_dt <= head_dt
|
||||
and
|
||||
head_dt
|
||||
and
|
||||
end_dt <= head_dt
|
||||
):
|
||||
raise DataUnavailable(
|
||||
f'First timestamp is {head_dt}\n'
|
||||
|
|
@ -278,7 +281,7 @@ async def open_history_client(
|
|||
start_dt
|
||||
):
|
||||
# TODO! rm this once we're more confident it never hits!
|
||||
breakpoint()
|
||||
# breakpoint()
|
||||
raise RuntimeError(
|
||||
f'OHLC-bars array start is gt `start_dt` limit !!\n'
|
||||
f'start_dt: {start_dt}\n'
|
||||
|
|
@ -298,7 +301,7 @@ async def open_history_client(
|
|||
# TODO: it seems like we can do async queries for ohlc
|
||||
# but getting the order right still isn't working and I'm not
|
||||
# quite sure why.. needs some tinkering and probably
|
||||
# a lookthrough of the ``ib_insync`` machinery, for eg. maybe
|
||||
# a lookthrough of the `ib_insync` machinery, for eg. maybe
|
||||
# we have to do the batch queries on the `asyncio` side?
|
||||
yield (
|
||||
get_hist,
|
||||
|
|
@ -421,14 +424,13 @@ _failed_resets: int = 0
|
|||
|
||||
|
||||
async def get_bars(
|
||||
|
||||
proxy: MethodProxy,
|
||||
fqme: str,
|
||||
timeframe: int,
|
||||
|
||||
# blank to start which tells ib to look up the latest datum
|
||||
end_dt: str = '',
|
||||
start_dt: str|None = '',
|
||||
end_dt: datetime|None = None,
|
||||
start_dt: datetime|None = None,
|
||||
|
||||
# TODO: make this more dynamic based on measured frame rx latency?
|
||||
# how long before we trigger a feed reset (seconds)
|
||||
|
|
@ -482,7 +484,8 @@ async def get_bars(
|
|||
dt_duration,
|
||||
) = await proxy.bars(
|
||||
fqme=fqme,
|
||||
# XXX TODO! lol we're not using this..
|
||||
# XXX TODO! LOL we're not using this and IB dun
|
||||
# support it anyway..
|
||||
# start_dt=start_dt,
|
||||
end_dt=end_dt,
|
||||
sample_period_s=timeframe,
|
||||
|
|
@ -756,7 +759,12 @@ async def _setup_quote_stream(
|
|||
# XXX since this is an `asyncio.Task`, we must use
|
||||
# tractor.pause_from_sync()
|
||||
|
||||
caccount_name, client = get_preferred_data_client(accts2clients)
|
||||
(
|
||||
_account_name,
|
||||
client,
|
||||
) = get_preferred_data_client(
|
||||
accts2clients,
|
||||
)
|
||||
contract = (
|
||||
contract
|
||||
or
|
||||
|
|
@ -1091,14 +1099,9 @@ async def stream_quotes(
|
|||
)
|
||||
|
||||
# is venue active rn?
|
||||
venue_is_open: bool = any(
|
||||
is_current_time_in_range(
|
||||
start_dt=sesh.start,
|
||||
end_dt=sesh.end,
|
||||
venue_is_open: bool = is_venue_open(
|
||||
con_deats=details,
|
||||
)
|
||||
for sesh in details.tradingSessions()
|
||||
)
|
||||
|
||||
init_msg = FeedInit(mkt_info=mkt)
|
||||
|
||||
# NOTE, tell sampler (via config) to skip vlm summing for dst
|
||||
|
|
|
|||
Loading…
Reference in New Issue