Candlestick Chart
Signature
sp.build_candlestick(
title: str,
dates: list[str],
opens: list[float],
highs: list[float],
lows: list[float],
closes: list[float],
*,
width: int = 1000,
height: int = 480,
x_label: str = "",
y_label: str = "",
color_up: int = 0x22c55e,
color_down: int = 0xef4444,
background: str | None = None,
gridlines: bool = True,
hover_json: str | None = None,
) -> Chart
Aliases: sp.candlestick
Description
Financial candlestick chart for OHLC (Open / High / Low / Close) price data.
Green candles indicate a price rise (close > open), red candles a fall.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
title | str | required | Chart title |
dates | list[str] | required | Date/time labels for X-axis |
opens | list[float] | required | Opening prices |
highs | list[float] | required | Session high prices |
lows | list[float] | required | Session low prices |
closes | list[float] | required | Closing prices |
color_up | int | 0x22c55e | Bullish candle fill color |
color_down | int | 0xef4444 | Bearish candle fill color |
width | int | 1000 | Canvas width |
height | int | 480 | Canvas height |
y_label | str | "" | Y-axis label |
gridlines | bool | True | Horizontal gridlines |
hover_json | str | None | None | Custom hover JSON |
Returns
Chart
Examples
Stock price chart
import seraplot as sp
chart = sp.build_candlestick(
"AAPL - January 2024",
["Jan 2","Jan 3","Jan 4","Jan 5","Jan 8","Jan 9","Jan 10"],
[185.0, 184.2, 182.5, 181.0, 183.5, 185.0, 186.0],
[186.5, 185.0, 183.8, 183.5, 186.0, 187.2, 188.0],
[183.5, 182.0, 180.5, 180.0, 183.0, 184.5, 185.5],
[184.2, 182.5, 181.0, 183.5, 185.0, 186.0, 187.5],
y_label="Price ($)",
)const sp = require('seraplot');
const chart = sp.build_candlestick("AAPL - January 2024",
["Jan 2", "Jan 3", "Jan 4", "Jan 5", "Jan 8", "Jan 9", "Jan 10"],
[185.0, 184.2, 182.5, 181.0, 183.5, 185.0, 186.0],
[186.5, 185.0, 183.8, 183.5, 186.0, 187.2, 188.0],
[183.5, 182.0, 180.5, 180.0, 183.0, 184.5, 185.5],
[184.2, 182.5, 181.0, 183.5, 185.0, 186.0, 187.5],
{
y_label: "Price ($)"
})import * as sp from 'seraplot';
const chart = sp.build_candlestick("AAPL - January 2024",
["Jan 2", "Jan 3", "Jan 4", "Jan 5", "Jan 8", "Jan 9", "Jan 10"],
[185.0, 184.2, 182.5, 181.0, 183.5, 185.0, 186.0],
[186.5, 185.0, 183.8, 183.5, 186.0, 187.2, 188.0],
[183.5, 182.0, 180.5, 180.0, 183.0, 184.5, 185.5],
[184.2, 182.5, 181.0, 183.5, 185.0, 186.0, 187.5],
{
y_label: "Price ($)"
})▶ Live Preview
See also
Signature
sp.build_candlestick(
title: str,
dates: list[str],
opens: list[float],
highs: list[float],
lows: list[float],
closes: list[float],
*,
width: int = 1000,
height: int = 480,
x_label: str = "",
y_label: str = "",
color_up: int = 0x22c55e,
color_down: int = 0xef4444,
background: str | None = None,
gridlines: bool = True,
hover_json: str | None = None,
) -> Chart
Aliases: sp.candlestick
Description
Graphique bougie financier pour données OHLC (Ouverture / Haut / Bas / Fermeture). Bougies vertes = hausse (clôture > ouverture), bougies rouges = baisse.
Paramètres
| Paramètre | Type | Défaut | Description |
|---|---|---|---|
title | str | requis | Titre du graphique |
dates | list[str] | requis | Étiquettes dates/heures pour l'axe X |
opens | list[float] | requis | Prix d'ouverture |
highs | list[float] | requis | Prix hauts de séance |
lows | list[float] | requis | Prix bas de séance |
closes | list[float] | requis | Prix de clôture |
color_up | int | 0x22c55e | Couleur de la bougie haussiere |
color_down | int | 0xef4444 | Couleur de la bougie baissière |
width | int | 1000 | Largeur du canvas |
height | int | 480 | Hauteur du canvas |
y_label | str | "" | Étiquette de l'axe Y |
gridlines | bool | True | Lignes de grille horizontales |
hover_json | str | None | None | JSON d'infobulle personnalisée |
Retourne
Chart
Exemples
import seraplot as sp
chart = sp.build_candlestick(
"AAPL - Janvier 2024",
["2 jan","3 jan","4 jan","5 jan","8 jan","9 jan","10 jan"],
[185.0, 184.2, 182.5, 181.0, 183.5, 185.0, 186.0],
[186.5, 185.0, 183.8, 183.5, 186.0, 187.2, 188.0],
[183.5, 182.0, 180.5, 180.0, 183.0, 184.5, 185.5],
[184.2, 182.5, 181.0, 183.5, 185.0, 186.0, 187.5],
y_label="Prix ($)",
)