timeline
Lists events in order, for fills, trading signals or risk events.
Examples
Lists the latest events recorded by the strategy, newest first.
javascript
function main() {
var events = []
var add = function (text, color) {
events.unshift({time: Date.now(), text: text, color: color})
if (events.length > 10) events.pop()
}
add("Strategy started", "primary")
add("Price breakout", "up")
add("Risk check passed", "muted")
LogStatus({type: "timeline", title: "Recent events", items: events})
}
python
import time
def main():
events = []
def add(text, color):
events.insert(0, {"time": int(time.time() * 1000), "text": text, "color": color})
del events[10:]
add("Strategy started", "primary")
add("Price breakout", "up")
add("Risk check passed", "muted")
LogStatus({"type": "timeline", "title": "Recent events", "items": events})
rust
fn main() {
let mut events: Vec<String> = Vec::new();
let mut add = |text: &str, color: &str| {
let ms = UnixNano() / 1_000_000;
let e = format!(r#"{{"time": {}, "text": "{}", "color": "{}"}}"#, ms, text, color);
events.insert(0, e);
events.truncate(10);
};
add("Strategy started", "primary");
add("Price breakout", "up");
add("Risk check passed", "muted");
LogStatus!(format!(
r#"{{"type": "timeline", "title": "Recent events", "items": [{}]}}"#,
events.join(",")
));
}Attributes
| Name | Type | Description |
type | string | Required. Always |
items | object array | Required. Events, shown top to bottom in array order; entries without |
items[].text | string | Required. Event text. |
items[].time | number / string | Millisecond timestamp or any text; a midnight timestamp shows only the date. |
items[].color | string | Dot color, default |
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