Skip to content

#777 Add event_type_ids market filter for simulation - #857

Open
niallsemple wants to merge 1 commit into
betcode-org:masterfrom
niallsemple:777-event-type-ids-simulation-filter
Open

#777 Add event_type_ids market filter for simulation#857
niallsemple wants to merge 1 commit into
betcode-org:masterfrom
niallsemple:777-event-type-ids-simulation-filter

Conversation

@niallsemple

Copy link
Copy Markdown

Closes #777

What

Adds event_type_ids support to simulation via listener_kwargs, the equivalent of the live streaming market_filter:

stream = BetfairHistoricalStream(
    file_path=file_path,
    listener_kwargs={"event_type_ids": ["7"]},  # horse racing only
)

Markets whose marketDefinition.eventTypeId does not match are excluded from processing entirely — no cache creation, no strategy calls, faster simulations when working with multi-sport event files.

How

  • HistoricListener accepts a new optional event_type_ids kwarg (list of ids, ints or strings)
  • FlumineMarketStream normalises ids to strings (Betfair definitions use strings) and skips non-matching markets on first sight of their marketDefinition
  • Excluded market ids are remembered, so subsequent updates that arrive without a marketDefinition stay filtered
  • Guarded with an isinstance check so the filter only activates when a real list is passed — zero impact on existing behaviour when unset

Verification

  • 5 new tests: matching/non-matching filter, exclusion persistence without definitions, no-filter passthrough, int→string normalisation, listener init
  • Full suite: 1021 passed (1016 existing + 5 new)
  • Functional check against the bundled PRO-1.170258213 historical file: ["7"] → 1 market processed, ["1"] → 0 markets, no filter → 1 market
  • Docs updated in docs/quickstart.md (listener kwargs section)

HistoricListener now accepts event_type_ids (e.g. ["7"] for horse
racing) and FlumineMarketStream excludes non-matching markets from
processing entirely, the simulation equivalent of the live streaming
market_filter. Exclusions are remembered so subsequent updates without
a marketDefinition stay filtered. Includes 5 new tests and docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for event_type_ids to market_filter for simulation

1 participant