Skip to content

Event matching fails: Kalshi uses 'at' separator but code splits on 'vs' #3

Description

@buildkit-ai

Bug

KalshiAdapter.searchMarkets() fails to match any Kalshi events to Shipp games because of two issues in the event title parsing logic at src/adapters/kalshi.ts:162-170.

Problem 1: Wrong separator

The code splits event titles on "vs":

const [eventHome, eventAway] = eventTitle.split('vs')

But Kalshi NBA event titles use "at" as the separator:

Milwaukee at New Orleans
Denver at Portland
LA Clippers at Los Angeles L

Since "vs" never appears, split('vs') returns the full title as element 0 and undefined as element 1. The match check then fails for every event.

Problem 2: Home/away order is reversed

The destructuring assumes [home, away], but the "X at Y" format means away at home — so the correct destructuring should be [away, home].

Problem 3: Name format mismatch

Even with the correct separator and order, Shipp returns full team names (e.g., "Milwaukee Bucks", "New Orleans Pelicans") while Kalshi titles use city-only names (e.g., "Milwaukee", "New Orleans"). The current startsWith comparison happens to handle this correctly ("milwaukee bucks".startsWith("milwaukee") → true), but cleanName() doesn't strip team mascots, so this is fragile.

Reproduction

./index.ts value-bet --game 01KHT4DVTP874NMCEVJVP3ERYA

Logs show:

Kalshi checking event title: Milwaukee at New Orleans
...
No event matches, falling back to market search
Found 0 markets for Milwaukee Bucks @ New Orleans Pelicans

The fallback market search (lines 191-216) also returns 0 because it searches by full team name using includes(), which won't find "new orleans pelicans" in Kalshi market titles that only say "New Orleans".

Suggested fix

  1. Split on multiple separators (" vs ", " at ", " @ ")
  2. Correct the destructuring order for "at" / "@" formats (away at home)
  3. Consider normalizing team names to city-only to improve matching reliability across data sources

Environment

  • alph-bot v0.1.0-alpha
  • Kalshi production API (api.elections.kalshi.com)
  • Sport: NBA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions