# A Safer Data Model for Crypto Price Widgets: Quotes, Scenarios and Costs

> Source: <https://dev.to/li_eisen_791108fcf808176b/a-safer-data-model-for-crypto-price-widgets-quotes-scenarios-and-costs-26im>
> Published: 2026-12-01 10:37:07+00:00

**Recommendation:** Tag each computed value with its kind and assumptions and validate inputs separately from parsing, so a blank field never becomes a valid zero or a scenario output is mistaken for a market quote.
More in the playbook "Verifying model output": <https://wpnews.pro/playbooks/output-verification>

A price widget can show a current market value, a projected value and a purchase estimate within a few pixels of one another. All three may use the same currency symbol. They are still different kinds of data.

This matters when you build crypto research interfaces: a number calculated from a slider must not silently become an executable quote.

*Disclosure: I work with Zoomex. The Zoomex pages linked below are examples and further reading. This is an independent design example, not a description of Zoomex's production implementation. AI assisted with drafting and code review.*

Start with the meaning of the value before choosing a chart library.

| Value | What it represents | Context the UI needs | 
|---|---|---|
| Market observation | A value received from a data source | Asset, quote currency, venue, product and timestamp | 
| Scenario output | A calculation using stated assumptions | Starting value, growth assumption, time unit and horizon | 
| Purchase estimate | An illustration of an order's cost or quantity | Side, available quote, fees and expiry | 

A last-traded price is not necessarily the price at which a new order can fill. A spot balance is also different from a derivatives position, even if both screens include BTC in the name.

Keep these distinctions in the data model. A shared variable named “price” makes it too easy to send a scenario output to a component that expects a market observation. Prefer separate objects with an explicit kind, currency and timestamp. In a typed application, use a discriminated union so components can narrow the object before displaying it.

For a simple constant-rate illustration:

**scenario value = starting value × (1 + growth rate per period) ^ number of periods**

The period on both sides must match. A 5% annual assumption over two years is not a 5% monthly assumption over 24 months.

Here is a deliberately small JavaScript implementation. It accepts numeric inputs that have already been parsed by the form. It does not estimate a statistically likely return.

```
function projectScenario({ start, growthPercent, periods }) {
  if (typeof start !== 'number' ||
      !Number.isFinite(start) || start <= 0) {
    throw new RangeError('start must be a positive finite number');
  }

  if (typeof growthPercent !== 'number' ||
      !Number.isFinite(growthPercent) ||
      growthPercent < -100 || growthPercent > 100) {
    throw new RangeError('growthPercent must be between -100 and 100');
  }

  if (!Number.isSafeInteger(periods) || periods < 0 || periods > 50) {
    throw new RangeError('periods must be an integer from 0 to 50');
  }

  const value = start * (1 + growthPercent / 100) ** periods;
  if (!Number.isFinite(value)) {
    throw new RangeError('scenario exceeds the numeric range');
  }

  return { kind: 'scenario', value, start, growthPercent, periods };
}

const example = projectScenario({
  start: 100,
  growthPercent: 5, // per year in this example
  periods: 2      // years
});

console.log(example.value.toFixed(2)); // 110.25
```

The bounds are application choices, not claims about possible market movements. A real design should explain its own input limits.

JavaScript's [Number.isFinite](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite) does not coerce a numeric string into a number. Keep parsing and validation separate. In particular, do not let a blank field become a valid zero merely because a conversion function accepts it.

As a real-world example of a scenario interface, Zoomex's [Bitcoin Price Prediction page](https://www.zoomex.com/en/price-prediction/bitcoin) exposes a growth input and labels its outputs as hypothetical. The general implementation question is whether every chart, table and label agrees on what the chosen input means. A correct formula does not rescue an ambiguous time horizon.

The 110.25 example checks ordinary compounding. It is not enough on its own.

Useful cases for this function include:

For decimal inputs, compare calculated results with an appropriate tolerance rather than assuming every decimal fraction has an exact binary representation. The [MDN Number reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) explains that representation. For actual balances and settlement, use an agreed precision model, explicit rounding rules and suitable decimal or integer representations; this chart example is not settlement arithmetic.

Even if a scenario looks plausible, it does not answer how a transaction works.

A purchase flow needs to make the product, funding route, applicable charges and custody choice clear. The [How to Buy Bitcoin guide](https://www.zoomex.com/en/how-to-buy/bitcoin) is a separate process reference; it should not be treated as proof that any forecast will occur.

For developers, the practical separation is straightforward:

Do not invent fee assumptions from a public chart. Read the terms of the actual product and quote service being integrated.

A green line, a precise dollar value and the word “expected” can make a toy calculation look like a promise. A disclaimer in the footer will not necessarily correct the impression created by the main component.

Prefer labels such as “hypothetical scenario” and show the input near the output. Present a downside case alongside an upside case when the tool is intended for scenario comparison. Avoid calling a deterministic slider output a probability or confidence interval unless a model actually supports that interpretation.

Crypto communities sometimes use [copium](https://www.zoomex.com/en/glossary/copium) for comforting rationalizations after a disappointing result. A product should not encourage that pattern by presenting an optimistic assumption as new evidence. Keep observations, assumptions and conclusions visibly separate.

Ask whether a reader can identify the source of a number, its time unit, its freshness and the conditions under which it was produced. Then check whether the application enforces the same distinctions internally.

A clear interface is not just a better chart. It makes the boundaries between a market observation, a mathematical illustration and a transaction explicit.

*Educational software-design discussion only. These examples do not recommend an asset or predict investment returns.*
