Skip to content

Multi-venue P1+P2: VenueAdapter extraction and Kalshi+Polymarket aggregation#7

Open
xymeow wants to merge 6 commits into
mainfrom
codex/multi-venue-p1-p2
Open

Multi-venue P1+P2: VenueAdapter extraction and Kalshi+Polymarket aggregation#7
xymeow wants to merge 6 commits into
mainfrom
codex/multi-venue-p1-p2

Conversation

@xymeow

@xymeow xymeow commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Lands the first two phases of the multi-venue roadmap PRD (docs/multi-venue-roadmap-prd.zh-CN.md), retiring the World Cup-specific assumptions now that the tournament is over. No firmware changes — the device keeps receiving the same pkbar/ticker/alert commands.

P1 — VenueAdapter extraction (pure refactor)

  • New tools/stackchan_venues.py: VenueQuote normalized model (probabilities 0–1, USD), VenueAdapter contract (discover/quotes/metadata), KalshiVenueAdapter first implementation. Contract doc: docs/venue-adapter-api.zh-CN.md.
  • Watcher Kalshi fetch delegates to the adapter; all 194 pre-existing tests pass unmodified.

P2 — Polymarket read-only aggregation

  • PolymarketVenueAdapter on the Gamma API (no auth; 15s minimum poll interval, 30s default).
  • Probability bar aggregates a liquidity-weighted mid across venues via probability_bar.polymarket, with equal-weight fallback when liquidity is unreported and silent single-venue degradation when a platform is down.
  • venue_divergence informational alert at ≥8pt cross-venue gaps (10-min cooldown); Kalshi goal signals corroborated by a same-direction Polymarket jump within 90s upgrade to a dual-venue high-confidence callout.

Config and tooling

  • market-pairing agent skill + trimmed three-source candidate fetcher.
  • config/pairing_registry.json: three agent-proposed, human-unconfirmed MLB pairings (verified live against Kalshi/Polymarket/ESPN: names, start times, and quotes all agree).
  • Example watchlist documents the new sections; fixture discovery repointed at KXEPLGAME for the EPL season. Known P0 gap noted in the release notes: fixture pairing must learn to skip Kalshi's draw market before EPL kickoff.
  • Bilingual 1.7.0 release notes; configuration/development/README cross-references refreshed.

Also carries two small pending fixes from the previous branch (per-connection close in the device HTTP server; tournament-winner market resolution).

Testing

  • python3 -m unittest discover -s tools -p 'test_*.py': 225 tests pass (194 pre-existing unmodified + 31 new for adapters, aggregation, divergence, corroboration, config parsing).
  • node --test mod behavior tests: 2/2 pass.
  • Live end-to-end smoke: Kalshi 44/56 + Polymarket 44.5/55.5 → aggregated pkbar 44/56 for Dodgers @ Phillies (Jul 20), no false divergence.

🤖 Generated with Claude Code

xymeow and others added 6 commits July 15, 2026 18:36
The World Cup final's Kalshi market is the outright winner event
(KXMENWORLDCUP-26), which lists all 48 teams as separate markets — so
event_markets rejected it with "only supports exactly two mutually-exclusive
team markets". Once the bracket reaches the final, the eliminated teams
settle and only the two finalists stay "active", so narrow markets to the
live ones before the two-market check. Verified end-to-end: resolving the
KXMENWORLDCUP URL now yields Spain vs Argentina and matches ESPN event 760517.

Normal two-market advance events are unaffected (len==2 skips the filter).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The watchdog timeout closed the connection and then the rejection it caused
in the in-flight #handle chain closed the same connection again — a
double close on one socket. Guard with a closeOnce() flag so a connection is
closed at most once regardless of which path (watchdog vs handler rejection)
fires first.

Found while auditing our own socket usage before attributing the recurring
tcpReceive UAF to the SDK. (The vendored listener is byte-identical to the
stock Moddable listen.js apart from the promise-observation guards.)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… (P1+P2)

P1: new stackchan_venues.py holds the VenueQuote normalized model
(probabilities 0-1, USD money) and the VenueAdapter contract, with
KalshiVenueAdapter as the first implementation. The watcher's Kalshi
fetch now goes through the adapter; snapshot parsing and all 194
existing tests are unchanged.

P2: PolymarketVenueAdapter reads the Gamma API (no auth, 15s minimum
poll). The probability bar renders a liquidity-weighted mid across
venues when probability_bar.polymarket maps its sides onto a Gamma
market, falling back to equal weights without liquidity data and to
single-venue rendering when a platform is down (log-only). Venues
disagreeing by 8+ points emit an informational venue_divergence alert;
a Kalshi goal signal corroborated by a same-direction Polymarket jump
within 90s upgrades to a dual-venue, high-confidence callout.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds the multi-venue roadmap PRD, the market-pairing agent skill
(three-source candidate fetcher plus pairing workflow), and a first
pairing_registry.json with three agent-proposed, human-unconfirmed
MLB pairings (Dodgers-Phillies x2, Pirates-Yankees). The example
watchlist documents the new polymarket and probability_bar.polymarket
sections and points fixture discovery at KXEPLGAME for the Premier
League season.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…se notes

Fixes the VenueAdapter contract as docs/venue-adapter-api.zh-CN.md per
the roadmap's P1 exit criteria, documents multi-venue aggregation in
both configuration guides, adds the bilingual 1.7.0 release notes, and
refreshes README/getting-started/development cross-references.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Xiaoyi He <xymeow@users.noreply.github.com>
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.

1 participant