Tokens & markets3 min read

Choosing a Historical Crypto Price Observation

Select historical price observations with clear at-or-before, nearest or interval rules, and prevent future prices from leaking into past reports.

Editorial illustration accompanying choosing a historical crypto price observation.

Overview

When translating these concepts into an integration, keep the scope described by the wallet history api with the result. The examples in wallet transaction history and smart contract event logs show how the same distinction affects neighbouring data questions.

A timestamp rarely matches a market observation exactly. Historical pricing therefore needs a selection rule, a maximum acceptable age and a clear policy for missing evidence.

Choose the time relationship

At-or-before avoids using information observed after a cutoff. Nearest can select a later observation and must say so. An interval average answers a different question from either point selection. Store both the requested instant and the selected observation time, including the timezone and precision.

Worked example: a gap around noon

A report cutoff is 12:00. Available observations are 11:58 and 12:01. At-or-before selects 11:58 if its age is acceptable. Nearest selects 12:01 because it is closer, but introduces future information relative to the cutoff. Neither method should be disguised as an exact observation at noon.

Make missingness actionable

Define a maximum staleness threshold and return unavailable when no observation qualifies. Test illiquid assets, suspended markets and a pair created after the requested date. Do not forward-fill indefinitely. Preserve the selection rule with exports and derived valuations so a later reviewer can reproduce the number without guessing which latest price was used.

A practical acceptance test

For a noon cutoff, provide observations at 11:58 and 12:01. Assert different selections for at-or-before and nearest rules, and retain the selected timestamp. Tighten the staleness limit until neither earlier observation qualifies. The application must expose missing evidence rather than secretly switch to the future observation or today’s latest price.

Questions about the topic

Frequently asked questions

Is nearest always appropriate for historical reports?

No. It may use a later observation and violate a no-look-ahead policy.

Should a missing price become zero?

No. Missing and observed zero have different meanings.

Standards & technical documentation

Further reading

{{TODO: author name}}

Practical explanations of blockchain data, software integration and the context behind a record.

About Indexbase
← Back to all articles

Build with better context.

Get an update when private beta opens.

Form setup in progress. Nothing entered here is sent or saved. {{TODO: endpoint}} See the full form and email alternative.