SHARPRFI
Will anybody score in the first inning, and is the posted price worth taking?
The first inning is its own betting market: NRFI if neither team scores, YRFI if someone does. SHARPRFI prices every game on the slate both ways. Two engines estimate the chance of a run, a Poisson model and a batter by batter simulation, and the headline is their average. I built it with Francisco Nevarez, whose simulation is the second engine.
Both engines were calibrated so that league-average inputs give 49.05%, the share of games from 2023 to 2025 with a first inning run. Everything a matchup does is measured as distance from that.
Built with
- Next.js 16
- React 19
- TypeScript
- Tailwind v4
- Vercel KV
- MLB Stats API
- Baseball Savant
- Open-Meteo
Free to use, no account. It prices games on MLB game days, so the slate is empty in the off-season.
The screens
Redrawn for this site from the real product, in its own type and colours, with sample data.
Everything it does
38 features in 7 areas, written from the code.
The daily slate
One table of every MLB game on the day, ranked by the side you are betting.
7 features
- A probability and a price for every game
- Each game shows the model's chance of a first-inning run to two decimals, and beside it the break-even odds for that bet. There is no sportsbook feed, so you compare the threshold with your own book.
- NRFI and YRFI from one model
- A toggle in the header switches every view between the two sides of the bet: probabilities, odds, sort order, result colours, the accent (green for YRFI, red for NRFI) and the methodology copy. The API returns the YRFI probability and the NRFI view takes its complement, so the two sides always sum to 100%.
- Today and tomorrow
- Two date tabs, anchored to the Pacific calendar day so the slate does not change over while west coast games are still to be played.
- Upcoming, in progress, settled
- Games are grouped by status and sorted within each group by the active side's probability. A game that is still being played moves to Settled as soon as its first inning is decided.
- Probability colour scale
- Percentages are coloured on a nine-step red to green scale fitted to the range the model produces (44 to 60% for YRFI, 45 to 62% for NRFI), so greener always means a stronger case for the active side.
- Weather and first pitch in the row
- Each row shows temperature, wind and start time. Wind under 5 mph reads Calm, the seven parks flagged as roofed read Roof, and a failed weather lookup shows a dash.
- Desktop table and mobile cards
- The desktop view is a fixed-width nine-column table. On a phone each game becomes a card with the same fields, and the controls collapse to matched pills.
Matchup breakdown
Tap any row or card and it opens in place to show how the number was built.
6 features
- Both engines side by side
- A Models section shows the Poisson probability with each team's expected runs, and the simulation's probability with its expected runs and hits for the inning. A badge marks that each contributes half of the headline.
- A starter card per half inning
- Each half shows the opposing starter's FIP, strikeout rate, barrel rate and the expected runs they lead to. A badge says whether he is confirmed, estimated from fallback inputs, or still TBD.
- The posted lineup
- When a batting order is posted, the card lists the first five hitters with their adjusted on-base rate and plate appearances. When it is not, the card says the team's season on-base rate is being used and shows that figure.
- Factor chips
- Each factor shows the multiplier it applied, an arrow for its direction and a short description. Pitcher and lineup descriptions change with the size of the effect in five bands, for FIP from "excellent run prevention" to "run-prone FIP", and orange marks a push toward scoring while blue marks a pull away from it.
- Park and weather card
- The venue with its park multiplier, the temperature and the wind. A park more than 5% from average is labelled with the percentage, and wind of 10 mph or more is described as blowing in, blowing out or a crosswind for that park.
- Units follow your preferences
- The breakdown describes temperature and wind in Celsius and km/h when those are selected, without changing the model's inputs.
Pricing a bet
The model gives a threshold. This part answers whether the price you are being offered clears it.
5 features
- Break-even odds
- The Bet at price is rounded toward the bettor on both sides, so a price shown as "or better" never loses at the stated probability: 61% reads -156, where -157 would need 61.09%. Even money displays as +100.
- Bet value calculator
- Inside each matchup you can enter your book's odds and get the implied probability, the model's probability and the expected value per unit staked. This layer is adapted from Francisco Nevarez's model.
- A banded verdict
- The calculator labels the price in four bands by expected value per unit: bet at +0.05 or better, slight +EV above zero, pass down to -0.05, and no bet below that.
- Built for a phone keypad
- American odds are split into a plus or minus toggle and a number field, because numeric keypads on phones have no sign key. A number under 100 is rejected with a hint, and the empty field shows the fair value.
- American or decimal
- A preference switches every Bet at price between American and decimal odds.
Marking uncertainty
The table says when a number rests on missing or provisional inputs.
6 features
- Estimate marker
- A tilde in front of the percentage means a probable starter is still TBD, or a named starter is running on league-average fallback stats because a feed had nothing for him.
- No price without a starter
- Break-even odds are hidden only when a probable starter is unannounced. A named starter with partial data still gets a price, with the estimate marker.
- Lineups picked up when they post
- Before a batting order exists the model uses the team's season on-base rate, and a league-average hitter in the simulation. Once the order is posted it is read on the next refresh, and the screen tells you to check back 30 to 60 minutes before first pitch.
- Roofs treated as neutral
- Seven parks flagged as roofed or retractable have weather switched off, because the roof state is not known in advance.
- Postponed games drop out
- Postponed, cancelled and suspended games are removed from the slate. A delayed game stays in progress, and an unrecognised status is treated as upcoming so nothing is settled by mistake.
- A list of what the model misses
- The methodology page ends with seven stated gaps, including bullpen usage and opener strategies, umpires, day and night splits, in-game weather changes, and the simulation not seeing weather at all.
Results and refresh
5 features
- First-inning result pills
- Each game shows RUN, NO RUN, IP while the first is being played, or a dash before it starts. The pill is green when the active side won and red when it lost, so the same RUN is green in YRFI mode and red in NRFI mode.
- Settled the moment it is decided
- A run in the top of the first marks the game RUN straight away, without waiting for the bottom half. NO RUN needs both halves on the line score.
- Automatic refresh
- The slate is fetched again every five minutes in the background, and the screen re-renders every minute so clocks stay current without another request.
- Manual refresh that skips the cache
- The Refresh button asks the server to recompute the slate, bypassing the five-minute cached response. The status bar shows when the numbers were generated and how many games are on.
- Loading and failure states
- A skeleton with an elapsed-seconds counter shows while a slate loads. A failed request shows the error with a Retry button, and a day with no games says so.
Preferences
Saved in the browser and applied everywhere.
4 features
- Temperature and wind units
- Fahrenheit or Celsius, mph or km/h, applied to the table, the cards and the breakdown text.
- Time zone
- First pitch times follow the device by default, with ten named zones to choose from, from Hawaii to Sydney.
- Remembered between visits
- Units, odds format, time zone and the NRFI or YRFI choice are kept in local storage. A first-time visitor lands on YRFI.
- A panel that fits the screen
- On desktop the preferences open as a popover under the button. On a phone they open as a centred dialog with a Close button, and Escape or a click outside closes either.
Methodology page
A second tab that explains the model in full, with the formulas typeset.
5 features
- Why this bet
- The page opens with the reasoning for the active side: for YRFI, that books can shade the popular NRFI price, and for NRFI, that starter quality drives the first inning.
- Every factor, with its formula
- A table lists the eight inputs to expected runs, each with its formula and a sentence on why it is damped the way it is. The phone layout also names each factor's data source.
- Both engines and the blend explained
- The Poisson steps, the simulation's rules, and the conversion to break-even odds are each written out, with the backtest figures that decided the blend.
- Formulas that fit a phone
- The equations are set with KaTeX, with shorter mobile versions of the long ones so they stay on screen without sideways scrolling.
- Sources linked
- MLB Stats API, Baseball Savant, FanGraphs and Open-Meteo are each credited with what they supply.
The math
The formulas are the ones the code runs, and each chart is computed from them.
01
Stabilize the inputs
Early season numbers are mostly noise, so every input is pulled toward league average by a sample-size prior before it is used. A pitcher's FIP is read as if he had thrown 45 more innings of league-average ball. On March 15 that prior counts 1.75 times as much, easing in a straight line to normal by July 1.
stat = avg + (raw − avg) × n / (n + k)
FIP 3.80, k = 45 IP · K% .230, k = 150 BF · OBP .310, k = 600 PA
From July 1Mid MarchWeight on a pitcher's own FIP by innings pitched, in March and from July on. 02
Build a run rate
Expected first inning runs for each half starts from a league base rate and scales by the matchup: the opposing pitcher's FIP and strikeout rate, the lineup's on-base rate and its top of the order, the park and the weather. Most factors are damped by an exponent, and the strikeout factor is clamped to 0.85 to 1.15, so no one input runs away with it. The top five hitters are weighted 1, 1, 1, 0.672 and 0.366, the chance each one bats in the first.
λ = 0.3371 × clamp(fip · k · barrel · obp · top · park · weather, 0.55, 1.55)
fip = (FIP / 3.80)0.55 obp = (OBP / .310)0.70 park = PF0.5
0.3371 = −ln(0.5095) / 2
03
Price the inning
With a run rate for each half, a scoreless half is the Poisson chance of zero, and NRFI needs both halves to stay scoreless. The calculator runs the model's own formulas. Barrel rate and top of the order are held at league average.
P(0 runs) = e−λ
P(NRFI) = e−λ home × e−λ away
Top of the 1st
λ 0.337 · scoreless 71.4%Bottom of the 1st
λ 0.337 · scoreless 71.4%NRFI51.0%Break-even −103YRFI49.0%Break-even +104The Poisson engine on its own. On the site its answer is averaged with the simulation's. 04
Simulate it
The second engine plays each half inning out ten thousand times. A hitter's chance of reaching comes from his wOBA, regressed toward .310 by plate appearances, adjusted for platoon and park, and scaled by what the pitcher allows. Hits split 65% singles, 20% doubles, 3% triples and 12% home runs, and runners move by fixed rules. Each game is seeded with its own ID, so the same inputs always give the same answer.
P(reach) = clamp(wOBA × 1.2333 × OBP allowed / .313 × √PF, 0.05, 0.95)
05
Check it
Backtested over 1,344 games of the 2026 season, the blend scored a Brier of 0.2447, better than either engine alone. There are two catches. A constant 50% guess always scores 0.2500, so the edge is small. And the backtest reads season stats that include games played after each prediction, so these scores are flattering.
.240.245.250.255.260Blend.2447Simulation.2463Poisson.2476Always 50%.2500Sim with streaks.2538Original script.2577Brier score by variant. Lower is better. 06
Read the price
Break-even odds come straight from the model, and a posted line becomes expected value per unit staked. Expected value of +0.05 per unit or more reads as a bet and anything else above zero as slight +EV. Zero down to -0.05 is a pass, and below that is no bet.
break-even = −100p / (1 − p) if p ≥ .5, else +100(1 − p) / p
EV = p × profit − (1 − p)
Under the hood
The work nobody using it sees.
- 01
Two engines, averaged
The headline probability is the simple average of a Poisson model and a batter-level Monte Carlo simulation, and one constant in lib/model-config.ts sets which engine ships. The Poisson model sees weather and contact quality but reduces a lineup to on-base rates, while the simulation plays through the posted batting order and ignores weather.
- 02
The Poisson engine
Expected first-inning runs for each half start at 0.3371 and are multiplied by factors for FIP, strikeout rate, barrel rate, team on-base rate, the top of the order, park and weather. Most carry an exponent below one (0.55 for FIP, 0.35 for barrels, 0.70 for on-base, 0.45 for the top of the order, 0.50 for park and weather), the strikeout factor is clamped to between 0.85 and 1.15, and the product is clamped to between 0.55 and 1.55.
- 03
A baseline checked against outcomes
The chance of a run is one minus the chance that both halves score zero, and 0.3371 is the per-half rate that makes a neutral game come out at 49.05%: 3,575 of the 7,290 completed regular-season games from 2023 to 2025, the pitch clock years, had a first-inning run. The repo's lessons file records the rule behind it: in a multiplicative model, check the neutral baseline against outcomes before tuning weights.
- 04
Shrinkage that eases through the season
Each Poisson input rate is pulled toward league average by n / (n + k), with k set per stat: 45 innings for FIP, 150 batters faced for strikeout rate, 50 innings for Statcast rates, 600 plate appearances for team on-base rate and 180 for top-of-order hitters. Those k values are multiplied by 1.75 on March 15 and fall linearly to 1.00 by July 1, so April samples are trusted less.
- 05
Weighting the top of the order
The first five hitters are weighted by the chance each one bats in the first inning: 1 for the first three, 0.672 for the fourth and 0.366 for the fifth, from a binomial on a 0.69 out rate. Their weighted on-base rate is compared with the team's, the ratio is capped between 0.90 and 1.12, and fewer than three usable hitters leaves the factor neutral.
- 06
The simulation engine
Contributed by Francisco Nevarez and adapted for the site. Each batter's reach probability comes from season wOBA shrunk by plate appearances, a platoon adjustment against the starter's hand, the starter's on-base rate allowed and the square root of the park factor, and each half inning is played 10,000 times with a random generator seeded by the game's id, so the same inputs always return the same number.
- 07
Changes to the contributed model
The adaptation made the opposing pitcher affect reach probability, simulated all nine hitters where the original stopped at four, and advanced runners on walks only when forced.
- 08
Calibrating the simulation
Runners advance station to station, with no steals, errors or wild pitches, which undercounts scoring: uncalibrated, the simulation gave about 40% league-wide. One constant, 1.2333, found by binary search, scales reach probability so league-average inputs reproduce the observed base rate, and the methodology page states that this compensates in aggregate and does so for no individual matchup.
- 09
Park and weather
Park factors for all 30 stadiums are a hand-maintained table of FanGraphs run factors, and each stadium also has coordinates and the compass bearing its outfield faces, so a wind direction can be resolved as in, out or across for that park. The forecast is read for the hour nearest first pitch, in UTC on both sides; wind counts only at 10 mph or more and temperature only below 55 or above 80 degrees.
- 10
Three free data feeds, reconciled per game
The MLB Stats API supplies the schedule, probable starters, pitcher and team season lines, the live game feed, line scores and handedness. Baseball Savant supplies barrel and hard-hit rates as a CSV and Open-Meteo supplies hourly weather, from its forecast endpoint or from its archive for past dates, and none of the three needs a key.
- 11
FIP from components
FIP is computed in the app from home runs, walks, hit batters, strikeouts and innings, with a 3.10 constant.
- 12
Lineups from the live feed
The schedule endpoint's lineup data was not reliable before games, so batting orders come from each game's live feed. For the simulation only starters are taken, by batting-order codes that are whole hundreds, so a substitute listed in the same slot is left out.
- 13
Building the slate
One API route builds the whole slate on request: weather per venue, stats per pitcher and team, and lineups per game are fetched in parallel, and handedness is looked up in batches of up to 100 players. The finished response is cached in Vercel KV for five minutes under a versioned key, and there is no scheduled job.
- 14
Cache lifetimes per source
Season stat lines revalidate every five minutes, weather every thirty and handedness daily. The schedule, lineups and line scores are never cached.
- 15
Guarding the Statcast cache
The Savant CSV is parsed with two sets of column names, and is cached for twelve hours only if it has at least 300 rows and 100 valid ones. A short or malformed download is discarded, so a bad file cannot sit in the cache giving every pitcher league-average values.
- 16
Failing toward neutral
A missing starter, stat line or Statcast row becomes league average and is flagged as estimated, a failed weather call becomes 72 degrees with no wind, an unknown venue gets a park factor of 1.00, and an empty lineup becomes a league-average hitter. A failure of the route itself returns an error that the screen shows with a Retry button.
- 17
The backtest
A script replays a date range through both engines and reports the Brier score, the gap between average prediction and actual rate, and five calibration bins. Over 1,344 games from 2026-03-26 to 2026-07-05 the blend scored 0.2447 with a calibration gap of +1.2%, the simulation alone 0.2463 (+3.5%) and the Poisson model alone 0.2476 (-1.1%).
- 18
A backtest that can be interrupted
The script checkpoints each date to disk so an interrupted run resumes, and it backs off and retries when an API answers 429. It keeps regular-season games only, which leaves out the All-Star Game and the postseason.
- 19
What the backtest rejected
The contributed model's win-streak multipliers were tested in the same run and scored 0.2538 with a calibration gap of +7.8%, so they are switched off by a constant, and the contributed script reproduced as coded scored 0.2577 with a gap of -10.3%. The script can also compare alternative early-season shrinkage schedules against the current one.
- 20
The backtest's weaknesses
The script requests each pitcher's and team's season line, and the Savant season file, as they stand when the script runs, so a prediction for an April game uses stats that include later games. Its Poisson lineup factor is also a plain average of the first three hitters where the live model weights five, and since a constant 50% guess always scores 0.2500, the blend's 0.2447 is a small edge.
- 21
Tests and deployment
Jest covers the library code in nine test files: the Poisson math, the simulation, game status and result logic, mode switching, the breakdown multipliers, the Savant parser, the KV wrapper, weather and the MLB client. The app is Next.js on Vercel, and the KV wrapper falls back to an in-memory store for local work and strips wrapping quotes from its environment values, which can otherwise break the KV client at runtime.