Tianhao Zhang

Case study 4 · Data quality

A deal analysis tool, and the 214 prices nobody had checked

A local tool ranks resale offers by net margin. The top offer looked like +$107; the store pages showed prices far above what the tool used. I traced why and added a live price check.

214offer-store rows priced from one listed number
0of them checked before the fix
$249.99 vs $399+listed vs. real price on the top item
393automated tests passing

Python · Chrome extension · REST API · Claude Code

Context

I built a local tool that reads resale offers from a buying group's official API every 20 minutes. For each offer and each store that sells the item, it works out the net margin: payout, minus the store price, plus card rewards, card-linked offers and cashback. The best offers rise to the top of one list.

Problem

On Nov 20 the top offer was a tablet showing about +$107. A check of the real store pages showed why that was wrong. The tool had priced it at $249.99. Amazon and Walmart sold it for $399, Target for $399.99, Staples from $429 and Sam's Club for $439. The payout was $355, so it was $44 below the lowest store price, before tax, rewards and cashback.

The cause was in the data, not the math. The partner API gives one retail_price per offer, which can be one store's sale price or an early holiday price. The tool had used that one number as the price at every store. All 214 offer-store rows in that day's data worked this way, and none had been checked against a store.

What I changed

  • When the tool checks stock on a store page, it now also reads the price, from a fixed spot on each of the five main stores.
  • It refuses unclear prices: a price range, several prices in one block, or a non-dollar price gives no price at all rather than a guess.
  • If the store price differs from the listed price by more than $1, the margin is recomputed with the store price. Offers that now lose money drop out of the list on their own.
  • A store price counts for 6 hours. If a later check cannot read the page, the last checked price stays, so the row never falls back to the wrong number.
  • Every row shows either "store price $X, checked at HH:MM" or "price not checked". Unchecked rows rank below checked ones, and the tool asks for the top rows to be checked first.
StorePrice the tool usedPrice on the store pagePayoutGap with listed priceGap with store price
Amazon$249.99$399.00$355.00+$105.01−$44.00
Walmart$249.99$399.00$355.00+$105.01−$44.00
Target$249.99$399.99$355.00+$105.01−$44.99
Staples$249.99from $429.00$355.00+$105.01−$74.00
Sam's Club$249.99$439.00$355.00+$105.01−$84.00
Manual price comparison for one tablet offer, Nov 20, 2026: store prices were read by hand from the store pages that day, not taken from the tool. "Gap" is payout minus price only, before sales tax, card rewards and cashback; the tool's full margin model includes those.
Partner API
offers and payouts, every 20 min
→
Margin model
card rewards, card-linked offers, cashback
→
Price check
read the store page; recompute if the gap is over $1
→
Ranked list
checked first, unchecked labelled
Data flow. The highlighted step is the one added after the 214-row finding.

Guard rails

  • The tool never clicks purchase, payment or subscribe buttons. A test fails if it tries.
  • Offer data from this buying group comes from its official API, under its limit of 100 requests a minute, with backoff after errors.
  • API keys stay on the machine, encrypted, and are never printed or sent to a web page.
  • Outside traffic is logged, with a daily cap.

Results

393 automated tests pass across 14 suites (Nov 20, 2026), including the new price check. The ranking now reflects prices someone can actually pay, and an unchecked number is visible as unchecked instead of looking like a fact.

What I would do next

Track how often the listed price and the store price disagree, by store and by category, to see where the partner data is least reliable.

Built with Claude Code: I set the goal, wrote the rules and the checks, and decided what counts as done; Claude Code wrote the code and the tests; a second model reviewed them.

Next: Running many AI work sessions from one inbox →