ib_venue_closures: gap detection for "legacy mkts" #71
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "ib_venue_closures"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
Extension to #62 but for the
ibbackend now with sane exchange calendar processing of expected valid venue closure time-gaps.Add a new
piker.brokers.ib.venuesmod which defines a buncha new helpers to aid with this, namely ais_venue_closore()which we use in the.api.Client.bars()to guard against any actual invalid non-closure gaps.venues
Hi-level deats,
add a new
.ib.venues.is_venue_closure()which compares gaps againstContractDetails.tradingSessions()converted topendulum.Intervals from which we then extract to.start/.end.time(): pendulum.Timevalues.also ensure classify any gap spanning is considered valid by checking it via the
exchange_calendarslib in a new.venues.has_holiday().also, use the new
.venues.is_venue_open(), factored from orig logic in.ib.feed.stream_quotes(), to determine whether to wait for a first live quote during live data bootup.NOTE, any such invalid gaps-cases we now expect to
breakpoint()insideClient.bars()- since it should never hit if GFI’s data is legit (which is should be).SO, if you’re using the ib backend do watch out for this and report it!!
🙏
Also includes a few other
ibspecific (backfiller machinery) improvements/reorgs:dropping (well, commenting for now) recursive bar requests on frame-duration mismatches where previously
Client.bars()would be re-invoked (from within itself) to attempt a max duration of data retrieval,asynciorequests.piker.data/.tsplayers.use of
ContractDetails.timeZoneIdfor all dts/durations so any introspecting human can grok what datum is what vs. the chart’s time x-axis is showing.move the
Client.bars()default paramstart_dt: str(a value in ISO 8601 format, as required by the IB api) to a new_iso8601_epoch_in_est: strmod level var so it can be easily accessed outside the method (if ever).moved the gpt5 written
parse_trading_hours()routine generated by@guilleinto new.ib.venuesmod as well.uppercase
Crypto.symbolforPAXOScontracts in.find_contracts(), though now we’re getting a weird new API error..ib_asyncabout possibly which should be shortly in follow up to this PR, > Error 10299, reqId 141: Expected what to show is > AGGTRADES, please use that instead of TRADES., > contract: Crypto(conId=479624278, symbol=‘BTC’, > exchange=‘PAXOS’, currency=‘USD’, > localSymbol=‘BTC.USD’, tradingClass=‘BTC’)Before this lands,
ib_async(closing #68)?Integrate `exchange_calendars` lib to detect market holidays in gap-checking logic via new `.ib.venues.has_holiday()` helper! The `.ib.venues` impl deats, - add a new `has_holiday()` using `xcals.get_calendar()` and friends for sanity checking a venue's holiday closure-gaps. * final holiday detection-check is basically, `(cash_gap := (next_open - prev_close)) > period` - include `time_step_s` param to `is_venue_closure()` for boundary tolerance checks. * let's us expand closure-time checks to include `+/-time_step_s` "off-by-one-`timeframe`-sample" edge case ranges. - add real docstring to `has_weekend()`. In `.ib.api` refine usage for ^ changes, - move `is_venue_open()` call + tz-convert outside gap check - use a walrus to capture `has_closure_gap` from `is_venue_closure()` - add a `not has_closure_gap` condition to the mismatched-duration/short-frame warning block to avoid needless warns. - keep duration-based "short-frame" log as `.error()` but toss in a bp so (somone can) umask to figure out wtf is going on.. * we should **never** really hit this path unless there's a valid bug or data issue with IB/GFIS! * keep recursion path masked-out just leave a `breakpoint()` for now. Also some logger updates, - import `get_logger()` from top-level `piker.log` vs `.ib._util` which was always kinda wrong.. - change `NonShittyIB._logger` to use `__name__` vs literal. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code8e89943a9eto341a584cea341a584ceatob2b180428bb2b180428bto50011d33efib_venue_closures: gap detection for "legacy mkts"to ib_venue_closures: gap detection for "legacy mkts"50011d33eftod17e6ab5d9ib_venue_closures: gap detection for "legacy mkts"to ib_venue_closures: gap detection for "legacy mkts"