Metric
Type:
metric
• Category:visualization
Description
Store latest metric value
Parameters
Name | Type | Description | Required | Default |
---|---|---|---|---|
widgetId | string | no | ||
metricExpr | string | Expr -> number or {value,label} | no | |
keepHistory | boolean | no | false | |
historyLimit | number | no | 100 |
Help
Overview
The Metric Store Worker records the most recent value of a specified metric and makes it available for display in financial‑market widgets. It can also retain a configurable history of past values, enabling trend analysis or historical look‑ups.
Inputs
widgetId
(string) – Identifier of the widget that will consume the stored metric.metricExpr
(string) – An expression that evaluates to either a numeric value or an object of the form{value, label}
. The expression is executed each time the worker runs, and its result is stored.keepHistory
(boolean, default = false) – When set totrue
, the worker retains previous metric values instead of only keeping the latest one.historyLimit
(number, default = 100) – Maximum number of historic entries to keep whenkeepHistory
is enabled. Older entries are discarded once this limit is reached.
Minimal Example Usage
Assume you want to track the latest price of the S&P 500 index and keep the last 50 values for charting:
- widgetId:
sp500_chart
- metricExpr:
fetchPrice('SPX')
– returns a number representing the current index level. - keepHistory:
true
- historyLimit:
50
When the worker runs, it evaluates fetchPrice('SPX')
, stores the resulting price under the widget sp500_chart
, and appends the value to the history array (up to 50 entries). Subsequent runs overwrite the latest entry while preserving the historic series according to the configured limit.