betting_combat.services.rounds_upcoming
The upcoming card for strategy 4’s live run: RoundsData.upcoming(card_date) (and
history) on the rounds data layer, before any fight of the card has a result.
UFCStats itself (which lists a card’s bouts, with their fight ids, before it starts) is behind a JavaScript bot wall and is never bypassed; its Greco1899 mirror holds finished events only. So the card is assembled from what is readable before it starts:
Kalshi the card's fights (``services.markets.discover_card``): both fighters' names, the live feed's scheduled rounds (``fight_length``), the 'ends before round k' markets it lists (rounds 4 and 5 only for a five-round fight), whether the feed has cancelled itWikipedia the event (its name and place in the stored 'List of UFC events') and its page's fight card: running order (main event first), segment, weight class, the champion marks and notes ('For the UFC Lightweight Championship')UFCStats the fighter table of the mirror (``ufcstats_fighter_tott``): each name to the fighter-table name the feature library resolves to its UFCStats fighter idPer bout (never a guess; anything else is excluded with a finding):
link each Kalshi fight to exactly one bout of the Wikipedia card (both fighters sharing a name word, either order: ``trading.rounds.link_fights``' rule); a Wikipedia bout without a Kalshi fight is kept for the card's contextnames each fighter's name as the fighter table spells it: the Wikipedia name, else Kalshi's, by the library's normalised name, else by the same letters without spaces ('Alateng Heili' = 'Alatengheili'); several fighters under one name are split by the library itself (weight class, then age: ``RawData``); a name found nowhere is a debutant (the library's ``name:<name>`` id) unless the table holds a fighter it resembles (a shared surname or two shared words, at a weight within one division) — then the bout is excluded as ambiguousweight UFCStats' text from Wikipedia's ('Women's Strawweight' -> "Women's Strawweight Bout"; a champion's mark or 'For the ... Championship' -> 'UFC <class> Title Bout', 'interim' -> 'UFC Interim <class> Title Bout'; 'Catchweight' -> 'Catch Weight Bout'); any other class is excludedrounds Kalshi's feed, Kalshi's rounds markets and the card (main event or title -> 5, else 3), which must agree wherever given; a Wikipedia-only bout takes the card's ruleids the fight id is not known before UFCStats lists the result: a stable stand-in, the first 16 hex digits of SHA-256('<date>|<fighter id>|<fighter id>') (sorted ids), and name_1 is the fighter with the smaller id. So the A/B orientation (``a_slot_of``) is a fixed function of the card date and the two fighters (a re-run after the card rebuilds the same rows) but is NOT the research's, which hashed UFCStats' id over UFCStats' result-ordered namesevent Wikipedia's name with the network prefix as UFCStats writes it ('UFC on ESPN: X' -> 'UFC Fight Night: X') and letters folded to ASCII; the place as UFCStats writes it (', U.S.' -> ', USA'); the event id 'upcoming<YYYYMMDD>'A bout excluded leaves the card’s context columns (n_bouts, card position) counting the
bouts kept; none of them is a model input.
Classes
CardEvent
The card’s event in Wikipedia’s list, in UFCStats’ spelling (ufcstats_event).
FighterTable
The mirror’s fighter table, indexed as the resolution reads it.
compact
compact(name: str) -> list[int]exact
exact(name: str) -> list[int]near
near(name: str, division: str | None) -> list[int]Fighters the name resembles: a shared last word, or two shared words, at a listed
weight within NEAR_LBS of the division (any weight when either is unknown).
KalshiBout
One Kalshi fight of the card, as the loader reads it.
of
of(fight: Fight) -> KalshiBoutResolution
What the loader made of a card: the card (None when nothing could be resolved), one
row per bout kept (RESOLUTION_COLUMNS), every bout excluded with its reason, and the
grouped findings.
StoreRoundsSource
trading.rounds.RoundsData on the rounds data layer: history = every stored
input as it stood before the card; upcoming = load_upcoming’s card (its findings
and excluded bouts kept in last and logged; the card stored in
rounds_upcoming_cards, from which the forward check rebuilds it).
history
history(card_date: dt.date) -> UfcTablesupcoming
upcoming(card_date: dt.date) -> UpcomingCard | NoneFunctions
ascii_fold
ascii_fold(s: str) -> strcard_event
card_event(list_json: str, card_date: dt.date) -> tuple[CardEvent | None, str]The card’s event in Wikipedia’s list (the scheduled or the past table): the one event on the card date, else the one a day either side; (None, why) otherwise.
card_from_row
card_from_row(row: Mapping[str, Any]) -> tuple[UpcomingCard, pd.DataFrame]A stored card back as the live engine received it, and its resolution rows
(fight_id, event_ticker, fighter_1, fighter_2, …).
card_row
card_row(res: Resolution, prepared_at: dt.datetime) -> dict[str, Any] | NoneA resolved card as a rounds_upcoming_cards row (None without a card).
excluded_frame
excluded_frame(excluded: Sequence[Mapping[str, Any]]) -> pd.DataFrameThe excluded bouts as UpcomingCard.excluded: event_ticker (None for a Wikipedia
bout no Kalshi fight was linked to), bout, reason.
fight_id_for
fight_id_for(card_date: dt.date, fighter_ids: Iterable[str]) -> strThe stand-in UFCStats fight id of an upcoming bout (16 hex digits, like UFCStats’).
fighter_rows
fighter_rows(store: RoundsStore, names: Iterable[str]) -> dict[str, list[list[str]]]The fighter table’s rows (CSV cells) of names, by normalised name, as stored now.
load_upcoming
load_upcoming(card_date: dt.date, store: RoundsStore, kalshi: KalshiRest, fetcher: PacedFetcher, tables: UfcTables | None = None) -> ResolutionThe card on card_date: Kalshi’s fights, the stored Wikipedia list, the event page
fetched now, the fighter table as of the card.
resolve_card
resolve_card(card_date: dt.date, kalshi: Sequence[KalshiBout], wiki: Sequence[Mapping[str, Any]] | None, event: CardEvent | None, tables: UfcTables, aliases: Mapping[str, str] | None = None) -> ResolutionThe card from its sources (see the module doc). tables: the UFC tables as they
stood before the card (tables_before); aliases: normalised name -> fighter id
(rounds_name_aliases).
resolve_name
resolve_name(table: FighterTable, spellings: Sequence[str], division: str | None, aliases: Mapping[str, str] | None = None) -> tuple[str | None, str](the name to list the fighter under, how it was found), or (None, why not), from ONE
fighter’s spellings (Wikipedia’s, then Kalshi’s). Each spelling is resolved on its own
(resolve_spelling) and they must agree — never a one-sided match:
- both fighter-table names: the same name;
- one a fighter-table name, the other refused as merely resembling it or a debutant: only when one spelling holds every word of the other (a compound surname, a suffix), else they are two different people (a late replacement, a stale source) and it is refused;
- both debutants: the same name, or one holding every word of the other;
- any spelling ambiguous or aliased to nothing usable: refused.
resolve_spelling
resolve_spelling(table: FighterTable, spelling: str, division: str | None, aliases: Mapping[str, str] | None = None) -> tuple[str | None, str, bool]One spelling: (the name to list the fighter under, how it was found, whether it is a fighter-table name), or (None, why not, False).
An alias (rounds_name_aliases: a spelling -> the UFCStats fighter id, or ‘name:resolve_card checks the library resolves that id from it). Then the
normalised name, then the letters without spaces; the hits of a method must all be one
fighter-table name (several fighters under it are split by the library), else the name is
ambiguous. A name found nowhere that resembles a table fighter is refused; one that
resembles none is a debutant.
title_of
title_of(bout: Mapping[str, Any]) -> tuple[bool, bool](a title bout, an interim title) from Wikipedia’s champion marks and notes.
ufcstats_event
ufcstats_event(name: str) -> strWikipedia’s event name as UFCStats writes it: footnotes removed, the broadcast-network prefix as ‘UFC Fight Night:’, letters folded to ASCII.
ufcstats_location
ufcstats_location(place: str) -> strWikipedia’s place as UFCStats writes it: a US place ends ’, USA’.
ufcstats_weight_class
ufcstats_weight_class(wiki: str, title: bool, interim: bool) -> str | NoneUFCStats’ WEIGHTCLASS text from Wikipedia’s class; None for a class not mapped.