DEV Community

Ken-Mutisya
Ken-Mutisya

Posted on

My weather model said 0%. The market said 90%. The market was right, because of rounding.

I run a small tool that prices Kalshi's daily temperature markets ("Will the low in Atlanta tomorrow be 49° to 50°?") against a weather forecast. For each bracket it computes a forecast probability and puts it next to the market's price. Where the two disagree, that's the interesting row.

On November 11 one row disagreed about as much as a row can:

Atlanta, daily low, bracket 49° to 50°
market:   90%
my model:  0%
observed low so far: 48.2°F
Enter fullscreen mode Exit fullscreen mode

The logic looked airtight. The low for the day had already reached 48.2°F. A low can only go down from there, so it can't end up between 49 and 50. Zero percent.

The market was pricing 90% with real money behind it. When a model says "impossible" and the market says "very likely," the model is usually the one that's wrong. Here it was.

Where 48.2 came from

The observations come from the free National Weather Service API (api.weather.gov/stations/{id}/observations). It returns two kinds of reading mixed together:

  • Hourly METAR reports. These carry the temperature to 0.1°C, and the response includes the raw METAR text in rawMessage.
  • 5-minute readings between the hourly reports. These are whole degrees Celsius, and rawMessage is empty.

48.2°F is exactly 9°C. The reading wasn't 48.2. It was "9", which means anything from 8.5°C to 9.5°C, or 47.3°F to 49.1°F. Converting to Fahrenheit made a rounded number look precise to a tenth of a degree.

So the observation didn't rule out the 49° bracket at all. The true low could have been 49.1°F. The market (which settles on the station's daily climate report, not on 5-minute snapshots) priced it that way.

The fix

Treat each 5-minute reading as a range, not a point. For a daily high, a reading only proves the high reached at least its lower bound. For a daily low, it only proves the low went at least as far down as its upper bound.

const obs = features
    .filter((f) => f.properties?.temperature?.value != null)
    .map((f) => {
        const c = f.properties.temperature.value;
        // Hourly METARs carry 0.1 C; 5-minute readings are whole degrees.
        const slack = f.properties.rawMessage ? 0 : 0.5;
        return { lo: (c - slack) * 9 / 5 + 32, hi: (c + slack) * 9 / 5 + 32 };
    });

const high = Math.max(...obs.map((o) => o.lo)); // proven high so far
const low  = Math.min(...obs.map((o) => o.hi)); // proven low so far
Enter fullscreen mode Exit fullscreen mode

With that change, the Atlanta reading of 9°C proves only that the low is at or below 49.1°F. The 49° to 50° bracket stays possible, and the forecast decides how likely it is.

The general lesson

Any time you convert units, check the precision of the source before you trust the decimals. 9 * 9/5 + 32 = 48.2 is correct arithmetic and still wrong. The extra digit came from the conversion, not from the thermometer.

The same thing happens elsewhere:

  • Prices rounded to the cent and then converted to another currency.
  • Timestamps stored to the minute and then compared to the second.
  • Percentages rounded for display and then summed.

The bug is never in the conversion. It's in treating the converted value as exact.


The tool is Kalshi Weather Markets on Apify: every open Kalshi temperature bracket with the market price, a forecast probability from NWS and NBM data, and the observed high or low so far. It now applies the fix above.

Top comments (0)