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

Shades a 2D grid by value, for returns by period and symbol or correlation matrices.

Examples

Hourly K-lines show the change of every hour over the last 3 days.

javascript
function main() { var r = exchange.GetRecords(PERIOD_H1) if (!r || r.length < 73) return var rets = r.slice(-73).map(function (b, i, a) { return i ? b.Close / a[i - 1].Close - 1 : 0 }) var days = [1, 25, 49] // 24 bars per day; the first row is the earliest day LogStatus({ type: "heatmap", title: "Hourly change, last 3 days", format: {percent: true, precision: 2}, x: r.slice(-24).map(function (b) { return _D(b.Time, "hh:00") }), y: days.map(function (d) { return _D(r[r.length - 73 + d].Time, "MM-dd") }), z: days.map(function (d) { return rets.slice(d, d + 24) }) }) }
python
def main(): r = exchange.GetRecords(PERIOD_H1) if not r or len(r) < 73: return bars = r[-73:] rets = [0] + [bars[i]["Close"] / bars[i - 1]["Close"] - 1 for i in range(1, 73)] days = [1, 25, 49] # 24 bars per day; the first row is the earliest day LogStatus({ "type": "heatmap", "title": "Hourly change, last 3 days", "format": {"percent": True, "precision": 2}, "x": [_D(b["Time"] / 1000, "%H:00") for b in bars[-24:]], "y": [_D(bars[d]["Time"] / 1000, "%m-%d") for d in days], "z": [rets[d:d + 24] for d in days] })
rust
fn main() { let Ok(r) = exchange.GetRecords(None, PERIOD_H1, None) else { return }; if r.len() < 73 { return; } let bars = &r[r.len() - 73..]; let days = [1usize, 25, 49]; // 24 bars per day; the first row is the earliest day // Rust's _D() always prints UTC time let x: Vec<String> = bars[49..].iter() .map(|b| format!("\"{}:00\"", &_D(b.Time)[11..13])) .collect(); let y: Vec<String> = days.iter() .map(|&d| format!("\"{}\"", &_D(bars[d].Time)[5..10])) .collect(); let ret = |i: usize| (bars[i].Close / bars[i - 1].Close - 1.0).to_string(); let row = |d: usize| format!("[{}]", (d..d + 24).map(ret).collect::<Vec<_>>().join(",")); let z: Vec<String> = days.iter().map(|&d| row(d)).collect(); LogStatus!(format!( r#"{{"type": "heatmap", "title": "Hourly change, last 3 days", "format": {{"percent": true, "precision": 2}}, "x": [{}], "y": [{}], "z": [{}]}}"#, x.join(","), y.join(","), z.join(",") )); }

Attributes

NameTypeDescription

type

string

Required. Always heatmap.

x

string array / numeric array

Required. X-axis labels.

y

string array / numeric array

Required. Y-axis labels; the first one is at the bottom.

z

array

Required. 2D numeric array z[row][column]: as many rows as y labels, each with as many values as x labels; non-numeric cells stay empty.

min

number

Lower bound of the color scale. Defaults to the data minimum.

max

number

Upper bound of the color scale. Defaults to the data maximum.

color

string

Single-color shading. When unset and the data has both signs, positive cells use the up color and negative ones the down color, shaded by magnitude. Values: see Status Bar Components.

format

object

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

height

number

Height in pixels, 120–600. Default 260.

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

The product of the x and y counts may not exceed 40000; more cells, or z dimensions that do not match, show an error card. Hovering shows a cell's value.