calendar
Shows returns as daily heat cells (like a contribution graph) or as a year × month table.
Examples
Daily K-line changes drawn as a return calendar.
javascript
function main() {
var r = exchange.GetRecords(PERIOD_D1)
if (!r || r.length < 2) return
var data = r.slice(1).map(function (b, i) { return [b.Time, b.Close / r[i].Close - 1] })
LogStatus({type: "calendar", title: "Daily change", data: data,
format: {percent: true, precision: 2}})
}
python
def main():
r = exchange.GetRecords(PERIOD_D1)
if not r or len(r) < 2:
return
data = [[r[i]["Time"], r[i]["Close"] / r[i - 1]["Close"] - 1] for i in range(1, len(r))]
LogStatus({"type": "calendar", "title": "Daily change", "data": data,
"format": {"percent": True, "precision": 2}})
rust
fn main() {
let Ok(r) = exchange.GetRecords(None, PERIOD_D1, None) else { return };
if r.len() < 2 { return; }
let data: Vec<String> = r.windows(2)
.map(|w| format!("[{}, {}]", w[1].Time, w[1].Close / w[0].Close - 1.0))
.collect();
LogStatus!(format!(
r#"{{"type": "calendar", "title": "Daily change", "data": [{}],
"format": {{"percent": true, "precision": 2}}}}"#,
data.join(",")
));
}Attributes
| Name | Type | Description |
type | string | Required. Always |
data | array | Required. Array of |
mode | string |
|
format | object | Number format |
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 |
See Also
Remarks
Positive values use the up color and negative ones the down color, shaded by magnitude. day mode shows only day-precise entries; month mode adds up the values of each month. Timestamps are converted to dates in the browser's time zone.