veriql Forecast Desk
Time now, UTC

Embed a widget

Put the forecast on your own site with one script and one tag. Choose what to show, copy the tag and paste it into your page.

Recommended: put the forecast on your site with the kit

The same elements as this site, in one script and one tag. Add the script once, then put a tag where the forecast should appear.

Forecast, not financial advice. The widget kit puts the forecast ranges, the odds of touching a level and the record of how those ranges held on any web page, with one script and one tag. It shows ranges and odds only, never a buy or sell call. It reads the public API described in the API reference and needs no account or key.

  • Credits: Price data: Bitstamp. Metal prices: gold-api.com.
  • SITE_DOMAIN is the address the site is served from and API_DOMAIN is the address of the API. On the site's own embed page both are already filled in with the real addresses. Anywhere else, replace them with the real addresses.

Quick start

Add the script once and the tag where the forecast should appear:

<script type="module" src="https://SITE_DOMAIN/kit/v1/vqf-widgets.js"></script>
<vqf-forecast skin="veriql"></vqf-forecast>

With no asset or horizon, the tag shows Bitcoin (BTC) for the next 24 hours. Add asset or horizon to choose another (see the attributes below).

<vqf-forecast> is the whole flow: the asset chips, the forecast screen, why the range is this size, the touch chance of a level, the trade check, hour by hour, and the track record. Every part is also a tag of its own (see the table of elements below), and the tag builder on this page writes the line for any of them.

The kit is one file with no dependencies. It is built with the API's address and the site's address, so a tag needs no api attribute, and its "how to read this" links open the guide page on our site with no guide-href either. Add guide-href only to send those links to a guide page of your own. The script is a module: it is loaded once, in any order with the tags, and a tag that is on the page before the script loads is drawn as soon as it does.

Build your tag

Choose what to show. The tag is what to paste into your page, and the preview is the real element.

Pick veriql app if your page uses the veriql app's CSS variables (--bg, --text and so on), and the forecast then matches your page's colours and font; on any other page it looks the same as Default.

Preview

The preview shows the kit's own colours. With the veriql look, the colours of your page show instead.

The kit never reads or writes the page's address, history, cookies or storage, and it adds nothing to the page's <html> or <body>. Every element draws inside its own shadow root.

Pin a version

/kit/v1/ moves: every release that changes nothing a page can see (a fix, or something added) arrives there by itself, and it is cached for five minutes. A page that must not change without a review loads a numbered release instead. A numbered release is never changed once it is published, and it is cached for a year:

<script type="module" src="https://SITE_DOMAIN/kit/0.1.0/vqf-widgets.js"
        integrity="VALUE_FROM_THE_SRI_FILE" crossorigin="anonymous"></script>

The integrity value is the one line of https://SITE_DOMAIN/kit/0.1.0/vqf-widgets.js.sri.txt. It starts with sha384-: copy it in place of VALUE_FROM_THE_SRI_FILE. The browser refuses the file if a single byte differs. The crossorigin attribute is needed because the file is on another origin: the site answers every origin (Access-Control-Allow-Origin: *) for everything under /kit/. integrity cannot be used with /kit/v1/, because its bytes change with each release.

The guide, <vqf-guide>, is a second file, vqf-guide.js, that a page loads after the kit. It is pinned the same way, with the one line of https://SITE_DOMAIN/kit/0.1.0/vqf-guide.js.sri.txt as its own integrity value:

<script type="module" src="https://SITE_DOMAIN/kit/0.1.0/vqf-guide.js"
        integrity="VALUE_FROM_THE_SRI_FILE" crossorigin="anonymous"></script>

What the page's security policy needs

A page without a Content-Security-Policy needs nothing. A page with one needs two additions, and nothing else:

script-src <what you have now> https://SITE_DOMAIN
connect-src <what you have now> https://API_DOMAIN
  • script-src gets the site's origin, so the browser may run the kit.
  • connect-src gets the API's origin, so the elements may read the forecast.
  • If the policy has no script-src or no connect-src of its own, the browser uses default-src for it: add the origin there.

What is not needed, and why:

  • style-src stays as it is. The kit's look is built in: it is a stylesheet that the script creates in memory and gives to each shadow root, and it sets sizes through the browser's style object, never through style attributes or <style> tags. A page whose style-src is 'self' alone shows no violation. (A very old browser without constructable stylesheets gets a <style> element instead, which a policy that has no 'unsafe-inline' blocks; every current browser has them.)
  • img-src and font-src stay as they are. The kit loads no image and no font. Its pictures are drawn in place, and its text uses the page's own font (or the --vqf-font you set).
  • frame-src stays as it is. The kit uses no frame.

The origin is the part before the first single slash: https:// plus the domain, and a port if it has one.

If a policy cannot change

  • Serve a pinned copy yourself. Download /kit/0.1.0/vqf-widgets.js and serve it from your own origin, so script-src 'self' is enough and nothing runs from the site's origin. This is the strictest option. connect-src still needs the API's origin.
  • Or send the API through your own server: point the api attribute at your own origin, so connect-src 'self' is enough. The cost is that you then run, cache and rate-limit that proxy yourself.

Before you embed

The site and the API each need their own domain, and the API needs a rate limit in front of it. On the API's shared address (workers.dev) there is no cache and no rate limit, so every viewer's request counts against a daily cap. Embed on a busy page only once both are in place.

The elements

Every element works alone, shares the page's choice of asset and window with the others (see Groups), and carries its own link to the guide.

Element What it shows Follows Reads
vqf-assets The asset chips with each last price; arrow keys move between them. asset, window /v1/latest, /v1/now
vqf-hero The forecast screen: price, window switch, countdown, gauge, ranges and every state. asset, window /v1/latest, /v1/now, /v1/schedule, /v1/health
vqf-why Why the range is this size: the usual-width comparison and the inputs. asset, window /v1/latest
vqf-touch The touch chance of each level (crypto), with the so-far low and high. asset, window /v1/latest, /v1/now
vqf-checker Trade check, position size and leverage room, with the tools' record lines. asset /v1/latest, /v1/touch/A/h, /v1/record
vqf-hourly Hour by hour: the next 24 hourly ranges and the hours that add the most width. asset /v1/latest, /v1/hourly/A
vqf-facts Upcoming events: today's facts for the asset and the scheduled releases of the next 7 days, with their times and sources. asset /v1/facts
vqf-context The long run so far: past range, averages, swings and pairs. asset /v1/context
vqf-ratio The gold/silver ratio's long run: the 30 and 90 day ranges, how each was tested, the leans, where the ratio sits in its history, and what a range means for silver. It is its own file, vqf-ratio.js, loaded after the kit, and it reads its own data file every 3600 s. window /v1/latest/XAUXAG, /v1/now, /v1/context
vqf-no-call Why there is no buy or sell call (words only, no numbers). none none
vqf-improving Self-correction by asset and window, and the log of model changes. none /v1/evolution
vqf-record Track record: how often the ranges held, with every sample size. asset /v1/latest, /v1/scorecard
vqf-scorecard The full scorecard: tests, reliability and challengers. none /v1/scorecard
vqf-evolution The full log of model changes. none /v1/evolution
vqf-guide How to read this: the guide to every number and word, with a picture from the real elements in each section. It is its own file, vqf-guide.js, loaded after the kit. none none
vqf-forecast The whole flow: chips, hero, why and touch, checker, hourly, upcoming events, the long run so far, no call, improving, record, footer. asset, window (all of the above)

In the Reads column A is the asset and h is the window. "Follows" says which of the page's choices the element shows: an element that follows none shows the same on every asset and window.

The attributes

Attribute Values Default What it does
asset BTC, ETH, XRP, SOL, NEAR, XAU, XAG, XAUXAG, OIL the first asset in the API's order The asset shown.
horizon 24h, 8h 24h The forecast window.
api an address that starts with https:// or http://, or empty the baked public.api_base, or the page's own origin when that is empty The forecast API's origin.
theme auto, light, dark auto: html[data-theme], then the system setting Light or dark.
guide-href any text the site's guide.html (the baked site base), or the relative guide.html when that is empty Where the guide links go (an anchor is added).
group any text page: one group per page Elements in one group share their asset and window.
illustration present or absent absent Shows the badge "Illustration, not a forecast" and fetches nothing (give it el.data).
skin default, veriql default veriql maps the colours and fonts onto the veriql app's variables.
density guided, compact guided compact shows the same numbers with the explanations behind "How to read this".

A value outside the list is never guessed: the element draws a box that names the attribute, the value and the valid values, and logs one line of the same words to the console. <vqf-forecast> hands api, theme, skin, density, guide-href and illustration down to its parts.

Groups and the vqf-select event

Elements in one group share their asset and window: choosing a chip or the window switch in one moves all of them. Elements with no group attribute are one group for the whole page. Give two sets of elements different group values to keep them apart.

An asset shows a window it publishes. If the group is on a window the asset does not publish (Gold on 8 hours, then Bitcoin, which publishes the 24 hour window only), the elements show the asset's own window and name it. The group keeps its choice, so the asset that publishes the window shows it again.

When a person chooses an asset or a window, the element dispatches vqf-select. It bubbles, crosses shadow roots, and carries detail: {asset, horizon}:

document.addEventListener("vqf-select", (e) => {
  console.log(e.detail.asset, e.detail.horizon);
});

The kit never writes the choice anywhere: a page that wants it in its address or in storage does that itself, from this event. An element with the illustration attribute dispatches nothing.

Giving an element its data

An element reads the API by itself. To show numbers the page already has, set el.data to an object whose keys are the API's own payloads: latest, now, hourly, facts, context, touch (by window), record, scorecard, evolution, schedule and health. The element draws them as they are and fetches nothing. Set it back to null to read the API again.

const el = document.querySelector("vqf-hero");
el.data = { latest, now };

Each payload has the shape given in the API reference.

Light and dark

theme="light" and theme="dark" fix the look. With theme="auto" (the default) an element follows data-theme="light" or data-theme="dark" on the page's <html> element, and when that is absent, the system setting (prefers-color-scheme). A change of either is followed at once, without reloading.

Colours, sizes and fonts

Every colour, radius, size and font is a CSS variable that the page can set on the tag or on any element above it. An element that finds none of them uses the default below. Under skin="veriql" the defaults are the veriql app's own variables where it has one: the kit reads --bg, --surface, --surface-2, --line, --line-2, --text, --text-2, --link, --brand-fill, --brand-ink, --shadow, --font and --mono from the page, and falls back to the defaults below for any it does not find.

Colours (light, then dark):

Variable Light Dark Used for
--vqf-desk #F4F6F9 #0B1320 Reserved: no element uses it yet.
--vqf-panel #FFFFFF #111B2B The background of a panel.
--vqf-panel-2 #F1F4F8 #162236 Inset boxes, loading blocks and empty states.
--vqf-line #DCE2EA #233149 Borders.
--vqf-line-2 #C3CCD8 #34445F Stronger borders and hovered controls.
--vqf-ink #0F1B2D #E6ECF4 Text on a panel.
--vqf-ink-2 #3A4759 #B2BFCF Secondary text on a panel.
--vqf-ink-3 #566377 #8C9AB0 Hints and small print on a panel.
--vqf-screen #FFFFFF #12203A The background of the forecast screen.
--vqf-screen-2 #F4F7FA #16273F Boxes on the forecast screen.
--vqf-screen-line #D6DEE8 #2A3D5C Borders on the forecast screen.
--vqf-s-ink #0F1B2D #F0F4F9 Text on the forecast screen.
--vqf-s-ink-2 #3A4759 #BAC6D6 Secondary text on the forecast screen.
--vqf-s-ink-3 #566377 #93A2B9 Hints on the forecast screen.
--vqf-g-grid #E6EBF1 #233048 Grid lines of the gauge and the hourly chart.
--vqf-g-axis #C3CCD8 #2E3B52 The gauge's axis.
--vqf-band-tail #98BADB #33587D Reserved: no element uses it yet.
--vqf-band-90 #76A6D6 #3A6FA3 The 90% range.
--vqf-band-80 #397CC0 #5290CF The 80% range.
--vqf-band-core #0B4C92 #9FCDF5 Reserved: no element uses it yet.
--vqf-bar-1 #96A6BB #627389 Reserved: no element uses it yet.
--vqf-bar-2 #2965A5 #5D97D8 Bars in the touch ladder and the hourly table.
--vqf-bar-3 #173C70 #A4CCF3 The hours that add the most width.
--vqf-tp #137C5D #33A57A The target line of the trade check.
--vqf-sl #C34707 #DD723B The stop line of the trade check.
--vqf-liq #960537 #CD144F The liquidation line of the trade check.
--vqf-liq-ink #960537 #F25771 The liquidation label on the trade check's level map.
--vqf-bad #960537 #F25771 Warnings and a setting that is not valid.
--vqf-ok #1B6C36 #5DC47E A live forecast and an open market.
--vqf-warn #88520A #EBAE51 Numbers kept from an earlier reading, and the beta label.
--vqf-soon #3D5A7F #98B3D7 The "soon" label.
--vqf-closed #566377 #8C9AB0 A closed market.
--vqf-accent #275DA5 #5E93D6 Links, and the chosen chip or row.
--vqf-accent-fill #275DA5 #5E93D6 The chosen window and tab.
--vqf-on-accent #FFFFFF #0B1320 Text on --vqf-accent-fill.
--vqf-accent-soft #ECF0F7 #1D2E46 The background of a chosen chip or row.
--vqf-shadow 0 1px 2px rgba(15,27,45,.05),0 6px 20px rgba(15,27,45,.05) 0 1px 0 rgba(255,255,255,.02),0 10px 26px rgba(0,0,0,.32) The shadow of a panel.

Sizes (the same in both themes):

Variable Default Used for
--vqf-radius-screen 20px Corners of the forecast screen.
--vqf-radius-panel 16px Corners of a panel.
--vqf-radius-card 14px Corners of a card inside a panel.
--vqf-radius-ctl 10px Corners of controls.
--vqf-radius-bar 6px Reserved: no element uses it yet.
--vqf-fs-body 16px Body text.
--vqf-fs-small 14px Small text and links.
--vqf-fs-tiny 12.5px Badges.
--vqf-fs-px clamp(40px,6.4vw,72px) The price on the forecast screen.
--vqf-fs-h2 clamp(21px,2.1vw,26px) Section titles.
--vqf-fs-headline clamp(21px,2.5vw,30px) The headline of the forecast screen.
--vqf-fs-stat 19px The figures under the gauge.
--vqf-fs-big clamp(28px,3.4vw,38px) The big figures of the track record.
--vqf-touch-min 44px The least height of a control you tap.
--vqf-motion 250ms The length of the highlight when a number changes.

Fonts:

Variable Default Used for
--vqf-font the page's own font Text.
--vqf-font-display the page's own font Prices, titles and figures.
--vqf-font-mono ui-monospace,SFMono-Regular,Menlo,Consolas,monospace Fixed-width text, such as the times in the log of model changes.

The names above are the whole list: the kit reads no other --vqf- variable from the page. (The forecast screen sets --vqf-anim-t on itself, so that its entrance animation carries on from where it was; a page cannot change it.)

Parts and states

Every element can be styled from the page with ::part(name). Every element has the parts root, legal, copy, toast, error, illustration, banner, unreachable and explain, and these more:

Element More parts
vqf-assets chips, chip
vqf-hero screen, price, switch, gauge, stats, headline, market
vqf-why panel, drivers
vqf-touch panel, ladder, row
vqf-checker panel, tabs, tool
vqf-hourly panel, chart, table
vqf-facts panel, facts, events
vqf-context panel, range, averages, swing, pairs
vqf-ratio panel, long, leans, history, silver
vqf-no-call panel
vqf-improving panel, grid, log
vqf-record panel, table
vqf-scorecard panel
vqf-evolution panel
vqf-guide guide
vqf-forecast flow, new-here, footer

An element is in one or more of four states that a page can style with :state(name), or with [data-vqf-state~="name"] in a browser that has no custom states: loading (waiting for the first answer), stale (the last reading failed, so the numbers are older), unreachable (no answer at all and nothing to show) and illustration.

How often it reads the API

  • /v1/now every 60 seconds while the page is visible and someone has used it in the last 10 minutes, otherwise every 300 seconds, or sooner when the price on screen is about to turn 5 minutes old (never more often than every 150 seconds while the page is idle, so at most 24 an hour).
  • /v1/latest every 300 seconds. No other endpoint is read more often than every 300 seconds.
  • /v1/health every 1200 seconds. /v1/record, /v1/schedule, /v1/scorecard, /v1/evolution, /v1/facts, /v1/context and /v1/latest/XAUXAG (the ratio's own file) every 3600 seconds.
  • /v1/hourly/A and /v1/touch/A/h once for each forecast, and again only when that forecast is replaced.
  • Elements on one page share one request per endpoint. Nothing is read while the page is hidden or while no element is near the screen (an element starts reading a screen and a half before it scrolls into view, so it has its size before anyone sees it).
  • A failed reading keeps the last good numbers, marks them with their time, and is tried again after 300 seconds.

When the forecast cannot be reached

When the API gives no answer at all (the page is offline, the address is wrong, a policy blocks it, or something other than the forecast answers: a cap page, a 429, a 5xx) and there is nothing earlier to show, the element draws a box instead of a number:

The forecast could not be reached

No numbers are shown rather than a guess. This page tries again on its own.

It also writes one warning to the console, which begins with vqf: and names the setting to check:

vqf: could not reach the forecast API at {api}. If this page sets a Content-Security-Policy, add {origin} to connect-src.

{api} is the address the element tried and {origin} is its origin. A page that sees this line on a page with a policy has left out the connect-src addition above.

The legal line stays

Wherever a forecast number is shown, the line "Ranges and odds only, never a direction. Not financial advice." and the price credits must stay visible. Each element that shows a number and stands alone draws them itself (::part(legal)); <vqf-forecast> draws the line and the credits in its hero, and the disclaimer and the credits again in its footer. A page may restyle the line, but it may not hide or remove it. This is the one rule of the kit that is not a matter of style.

Versions and updates

The kit follows semantic versioning, and /kit/v1/ is always the newest release of version 1.

  • A release that fixes something or adds an element, an attribute, a variable or a part is a minor or patch release. /kit/v1/ takes it by itself.
  • A breaking change is a major version, and it is published at /kit/v2/, never at /kit/v1/. A break is the removal or renaming of an element, an attribute, an event, a part or a variable, or a change in what a valid value means.
  • Numbered releases stay served: a page pinned to one keeps loading it.

Size

The kit, vqf-widgets.js, is one file of less than 64 kB gzipped, with every element but the guide, the look and the words in it. The guide, vqf-guide.js, is its own file of less than 30 kB gzipped, with the guide's words and look in it. A page loads it after the kit, and only a page that shows <vqf-guide> needs it.

For maintainers

Releasing is one command, run from the repository root once the version in web/widget/package.json is the one to publish:

npm run kit:release -w web/site

It builds the kit and the guide's file and copies both, each with its .sri.txt, to web/site/public/kit/<x.y.z>/, where the build serves it as a numbered release. It refuses to change a release that already exists.

A lighter option: one forecast card

Use the card when you need only one coin and one window, and want a much smaller script. It is one tag with its own attributes: coin, horizon (the window), theme, api and refresh-s. theme is light or dark; leave it out and the card follows the visitor's own light or dark setting. It is a narrow box and has none of the kit's other parts. refresh-s is the number of seconds between readings: 300 seconds when you leave it out. A smaller or invalid value is ignored, so it can only make the card read less often.

<script type="module" src="https://forecast.veriql.app/forecast-card.js"></script>
<forecast-card coin="BTC" horizon="24h" api="https://forecast.veriql.app"></forecast-card>

Credit the sources

Every element carries its credits and the line Forecast, not financial advice. Keep them visible where you place it: Price data: Bitstamp, and Metal prices: gold-api.com for gold and silver.