termino
~/docs/custom/candlestick

CandlestickChartcustom

OHLC candles with wicks, up/down colors and index labels

~/custom/candlestick
live
$ termino candlestick — ohlc stream
▄▄
▀▀ ████▄▄
▀▀ ██
▀▀
0 4 8 12 16 20 24 28 32
o 98.5 h 100.8 l 94.5 c 97.0

##API

One candle per data point at the column group center. Bodies are `█` with `▀/▄` edges at half-pixel rows, wicks are `│`; body wins over wick on overlap. Green when close ≥ open, red otherwise. Index labels every few candles on the bottom row.

properties
proptypedefaultdescription
data{ open, high, low, close }[]-OHLC series
width / heightnumber40 / 10Chart area
up / downstring"#9ece6a" / "#f7768e"Bullish / bearish body colors
wickstring"#7a81a8"Wick color
showLabelsbooleantrueIndex labels row

##Keymap

~/keymap
Display only

##Notes

  • Scale is computed from high/low across the whole series — candles stay true.
  • Feed it a rolling window (slice(-n)) to build a live ticker.

##Source

Real implementation — this is the code that runs in your terminal.

tsxcandlestick.tsx
1import { createElement as h, useMemo } from "react";
2import { Canvas } from "./canvas";
3import { renderCandles, type Candle } from "./chart";
4
5export interface CandlestickChartProps {
6 data: Candle[];
7 width?: number;
8 height?: number;
9 up?: string;
10 down?: string;
11 wick?: string;
12 showLabels?: boolean;
13}
14
15export function CandlestickChart({
16 data,
17 width = 40,
18 height = 10,
19 up,
20 down,
21 wick,
22 showLabels,
23}: Readonly<CandlestickChartProps>) {
24 const rows = useMemo(
25 () => renderCandles(data, width, height, { up, down, wick, showLabels }),
26 [data, width, height, up, down, wick, showLabels],
27 );
28 return h("box", { flexDirection: "column", gap: 0, width }, h(Canvas, { rows, width }));
29}
30