What this app is
BaseballSniper watches Major League Baseball games and judges the late
innings with a win-expectancy model. Kalshi lists a game-winner
market for every MLB game (series KXMLBGAME — two markets per game,
one per team). When a game is late and one side's win expectancy
clears the certainty bar, the play is to buy that side at its market
ask and ride it to the final out.
This first wave is a paper recorder. It runs the full loop —
score feed, instrument, gates, market matching — and records every
would-be play and every skip, then scores them all to the final score.
No order is ever sent: paper mode is locked ON in the code for this
wave, and the app contains no order-placement code at all. The record it
builds is the evidence a later live-arming decision will stand on.
The instrument — win expectancy
Baseball has no clock. The state of a game is the inning (and
which half — who is batting), the outs, the runners on base, and the run
differential. The instrument turns that state into a win probability for
the home team:
- Run expectancy. A published base-out run-expectancy matrix
(the RE24 table, from 2010–2015 MLB data) says how many runs the batting
team is expected to score from any base-out state — 0.481 with the bases
empty and nobody out, 2.292 with the bases loaded and nobody out, and
so on for all 24 states.
- Runs still to come. Each side's remaining scoring is built
half-inning by half-inning: the current half is priced by the matrix,
every later half at the league-average rate (~0.48 runs). The home
team does not bat in the bottom of the 9th (or later) when it already
leads — that state is a certain win, and the model says so exactly.
- The distribution. Runs in each remaining half-inning are
drawn as an independent Poisson at that half's expectancy, and the
totals are convolved exactly — so the skew of real scoring (most
halves score 0 or 1; big innings are rare) is priced honestly. A
game still tied after the last home at-bat goes to extra innings,
where the home team wins about 53% — the model prices the tie at
that rate instead of pretending it away.
The full model, its sources and its known simplifications (no
pitcher/bullpen quality, no lineup or park effects, no pinch-running of
the numbers by hand) are written down in the app's INSTRUMENT.md. The
calibration plan is evidence-first: the recorder's own scored states are
compared against the market's prices and the final outcomes, bucket by
bucket, before the bar or the model constants are tuned.
When it plays — and when it sits out
- Late inning (a setting, default the 7th): before that, no
state is judged, however lopsided — baseball is too volatile early.
- Certainty bar (a setting, default 0.90): the leading side's
win expectancy must reach it. A 3-run lead entering the 9th clears it
easily; a 1-run lead with the bases loaded in the 7th does not — that
is the whole point of judging states instead of scores.
- Max ask (a setting, default 0.99): the leader's market ask
must not exceed it. One play per game — the first state that clears
the bar is the recorded play.
- Every refusal is recorded as a skip with the full game state
and, once the game ends, what the leader did anyway — so each rule's
own scoreboard builds itself on the dashboard's breakdown views.
The controls
Start Recorder / Stop Recorder
The small button in the Balance card drives the kill switch and
nothing else. Stop sets it and recording pauses from the next cycle;
Start clears it. Settlements of already-recorded plays always continue —
the kill switch never traps a record.
Min balance floor — and the latch
The floor is the app's hard stop, inherited from the sniper family and
kept armed even in the recorder wave so the plumbing is proven before
money moves. The balance is the sum of all shards of the shared
Kalshi account. If cash falls below the floor, the app latches:
it stays stopped until you press RE-ARM on the dashboard. If the floor
is unset (0) it self-initializes to the current balance the first time
it is read; a floor you type in is never overwritten.
Max bid amount
The most one play may cost (default $1.00). Contracts =
floor(max bid ÷ ask), so at a 99¢ ask a $1 bid buys exactly one
contract. The fee estimate on each record uses Kalshi's published
fee schedule for this series (quadratic taker fees).
Certainty bar / Late inning / Max ask
The instrument's three dials, described above. All are settings —
change them on the dashboard and the next cycle judges by the new
values; every change is written to the settings log with its author.
Per-team toggles
Every team on a game card has a switch reading Enabled or
Disabled. Disable a team and any game it plays in sits out —
silently, with one recorded skip — until you enable it again. A play
recorded before the flip still settles normally.
Kill switch vs the STOP file
Two different brakes. The kill switch is the everyday control:
it pauses new recordings. The STOP file (a file named STOP in the
app directory) is the break-glass halt: everything stops, settlements
included, until the file is removed.
Paper mode — locked
Paper mode is ON and cannot be turned off in this wave: the
settings store refuses the change in code. Live arming is a separate
later build, on the owner's decision, standing on this recorder's
evidence.
Instance guard
Two copies of this app must never act on the same account at once.
Every would-be play carries a client order id that names it —
this copy's instance name (the Instance name setting, default
UAT), the market ticker, the game's start and a pass number — so the
same play sent twice is the same order, and each copy's orders are
recognisable on the account. At boot and on a slow cadence the worker
reads the account's recent orders: an order carrying this app's
prefix with a different instance's name means another copy is
live, so this copy stands down (STOOD DOWN banner, activity
line) and resumes on its own once the other copy has been quiet for
half an hour. Orders from the other apps on the shared account carry
their own prefixes and are never mistaken for another copy of this
one. In the recorder wave the guard is plumbing and display — paper
records are never blocked by it.
The rails
- No orders exist. This build has no order-placement code
path; the authenticated Kalshi client is read-only by construction
(balance, positions, orders — GET only, allowlisted paths).
- The balance floor is the stop. Armed and latching even in
the recorder wave, so it is proven before it is needed.
- Fail closed. A game state the feed cannot fully show (outs
or bases unknown, a delay) is never judged — it is recorded as an
incomplete-state skip. If the balance cannot be read, nothing is
recorded as a play.
- One play per game. The first bar-clearing state is the
play; later states of the same game are never re-judged.
- Settings are authoritative. Every behaviour value lives in
the app's own database, is re-read every worker cycle, and every
change is written to the settings log with its author.
- The account is shared. WeatherEdge, Edge15, CryptoSniper
and this app read one Kalshi account; the balance figures here are
the whole account, all shards summed, with the positions split shown
by owner.
- Season-aware. December is the off-season: the scoreboard
carries scheduled fixtures and the series lists no open markets. The
recorder watches, records nothing, and sleeps — by design.
Reading the dashboard
- Banner: what the recorder is doing right now, in plain
words — paper recording, kill switch, floor latch, STOP file, or
stood down — with the reason under it. The status line under the
banner is the newest thing the worker did.
- Balance (all shards): Cash, Positions (the current market
value of everything open on the shared account, from the positions
read — never guessed) and Total; the split line under them says
whose positions they are — Baseball, WeatherEdge, Edge15, or Other —
and the floor line shows the floor and whether cash is above it,
below it, or latched.
- Cash — snapshots: the recorded cash curve with the floor
drawn dashed across it.
- Today's tiles: plays recorded today, wins, losses, win
rate and the would-be net (paper — no money moved), plus the three
tuning gauges: Not decided (the leader's win expectancy sat
under your bar — the gauge for the certainty bar), No market
(no Kalshi market matched the game) and Too expensive (the ask
sat over your max). Every tile is a door: click it for the records
behind the number, including what the leader did anyway in each
scored skip and what backing it would have netted.
- Watching: today's games with the live state — inning,
outs, base runners (◆ on base, ◇ empty), the score, each side's win
expectancy, the market asks, the recorded play when there is one,
and each team's Enabled/Disabled switch. Click a team name for its
page: games seen, times backed, record, would-be net.
- History: every recorded play with the state it was judged
in. The grid pages — 50, 100 or 500 rows at a time, or All — with the
same pager above and below it naming the page count. Click any row
for the full record, client order id included.
- Recent Skips: every refusal, with the reason in plain
words, the full game state, and — once the game is final — whether
the leader won anyway.
- Settings: the controls above, applied the moment you
change them — no restart. The settings log records who changed what,
when.
Version history
- v1 — the recorder wave: the win-expectancy instrument
(RE24-based, documented in INSTRUMENT.md), the ESPN score feed, the
KXMLBGAME market matching, would-be plays and skips recorded and
scored to settlement, the balance floor and latch, per-team
Enabled/Disabled toggles, the single-instance guard plumbing, and
paper mode locked ON. Ships in the off-season and sleeps until the
games return.