Type/to search
Built-in Functions
Structures
Ticker
Depth
OrderBook
Trade
Record
Market
Order
Condition
Account
Asset
Position
Funding
Other Structures
HttpQuery-options
HttpQuery-return
LogStatus-table
LogStatus-btnTypeOne
LogStatus-btnTypeTwo
Status Bar Components
grid
tabs
kpi
stat
progress
gauge
sparkline
chart
heatmap
calendar
histogram
pie
timeline
markdown
alert
badge
Chart-options
Chart-return
KLineChart-options
KLineChart-return
SetData-data
EventLoop-return
exchange.Go-return
DBExec-return
Dial-return
Thread.join-return
Built-in Variables and Constants
Conventions
Exchanges

Shows one prominent number with optional unit, change and hint, for equity, returns or the last price.

Examples

A KPI card shows the last price and its change from the open.

javascript
function main() { var ticker = exchange.GetTicker() if (!ticker) return var change = ticker.Open > 0 ? (ticker.Last / ticker.Open - 1) * 100 : 0 LogStatus({type: "kpi", title: "Last price", value: ticker.Last, delta: change, hint: "vs. open"}) }
python
def main(): ticker = exchange.GetTicker() if not ticker: return change = (ticker["Last"] / ticker["Open"] - 1) * 100 if ticker["Open"] > 0 else 0 LogStatus({"type": "kpi", "title": "Last price", "value": ticker["Last"], "delta": change, "hint": "vs. open"})
rust
fn main() { let Ok(t) = exchange.GetTicker(None) else { return }; let change = if t.Open > 0.0 { (t.Last / t.Open - 1.0) * 100.0 } else { 0.0 }; LogStatus!(format!( r#"{{"type": "kpi", "title": "Last price", "value": {}, "delta": {}, "hint": "vs. open"}}"#, t.Last, change )); }

Attributes

NameTypeDescription

type

string

Required. Always kpi.

value

number / string

Required. The value: numbers are formatted with format, strings are shown as is.

unit

string

Unit shown after the value.

delta

number

Change: positive values show the up color with ▲, negative ones the down color with ▼, 2 decimals.

deltaUnit

string

Unit of delta. Default %.

format

object

Number format {precision, compact, percent}; see Status Bar Components.

color

string

Color: up, down, primary, warning or muted; see Status Bar Components.

hint

string

Note shown under the value.

title

string

Title shown at the top left of the component.

id

string

Stable identifier. Set it when the number or order of components changes, so refreshes do not rebuild the component.

span

number

Number of columns it spans in the enclosing grid. Default 1.

See Also

Remarks

delta is the change itself, not a ratio: write 3.2 for a 3.2% rise. When value uses format.percent, pass a ratio (0.032).