C.W.K.
Stream
Lesson 01 of 05 · published

Every Quote Is an Observation

~11 min · provenance, observation-data, metadata, trust

Level 0Open Gate
0 XP0/36 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete
"A price isn't a fact about the world. It's a fact about what one source said, at one moment. Store it that way."

Market data is observation data

It's tempting to think of a stock price as a number — the price. But there's no such thing as "the" price sitting in the world waiting to be read. There's what a particular provider reported, for a particular market date, at a particular fetch time. Keep encodes exactly that humility: every quote and FX row is an observation, and it records four things alongside the value — the market date it applies to, the fetch time it was retrieved, the source that provided it, and the provider ticker used. The number is never stored naked.

Why the metadata is not optional

Each piece of provenance answers a question you will eventually need:

  • Market date — is this today's close, or last Friday's, because the market's been shut over a long weekend?
  • Fetch time — how old is this observation right now? Was it pulled five seconds ago or five hours ago?
  • Source — did this come from the primary provider, or from a confirmed fallback? Those may differ slightly, and you deserve to know which you're looking at.
  • Provider ticker — which symbol at that provider produced it? Ticker conventions differ between sources, and a mismatch here is a whole class of subtle bug.

Strip any of these away and the value gets more trustworthy-looking and less trustworthy in fact.

Provenance is part of the datum, not decoration around it. A value you can't source, date, and age is a value you can't reason about. The metadata isn't a nice-to-have you bolt on for debugging — it's what turns a bare number into something a careful person is allowed to trust.

The calm this buys

This ties straight back to the north star. Because every number carries its own provenance, Keep never has to pretend an old value is fresh or hide where something came from. It can simply show you: "this price, from this source, as of this date, this many minutes old." That honesty is what lets the surface stay calm — you're never being shown a confident number that's secretly stale, so you never get the nasty surprise that trains you to distrust the whole tool.

This is the same shape as the whole architecture. Observation-with-provenance is the market-data version of a pattern you've already seen: cash is stored with a source tag, fallbacks announce themselves, history is dated and append-only. Keep keeps saying the same thing in different places — a value and the story of where it came from travel together, always.

Code

The number never travels alone·python
# NOT this — a bare price loses the story the moment it's stored.
price = 187.42

# This — an observation carries its own provenance.
quote = {
    "value": 187.42,
    "market_date": "2026-07-24",     # the trading day it's for
    "fetched_at":  "2026-07-24T20:11:03Z",
    "source":      "massive",         # primary, or a confirmed fallback?
    "provider_ticker": "TICK",        # the symbol at that provider
}

# Every downstream reader can now answer 'how old? from where?'
# without guessing — the metadata is inseparable from the value.

External links

Exercise

Take any external value your code fetches — a price, a weather reading, an exchange rate, an API result. List the provenance you'd need to store WITH it to reason about its trustworthiness later (source, timestamp, which identifier, which endpoint). Then describe a specific bug that would occur if you stored only the bare value and lost one of those fields.
Hint
The classic bug: you store just the number, then weeks later can't tell whether it's fresh or stale, or which of two providers gave it. Ticker/identifier mismatches are especially nasty — the value looks right and belongs to the wrong thing. Provenance is how you catch that.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.