plot_candlestick
function backtide.analysis.candlestick.plot_candlestick(data, rangeslider=True, title=None, legend="upper left", figsize=(900, 600), filename=None, display=True)[source]
Create a candlestick chart.
Visualizes OHLC (Open-High-Low-Close) price data over time as candlestick bars — the standard chart type used in financial technical analysis. When the dataframe contains multiple symbols, each symbol gets its own color-coded candlestick trace with a matching close-price line overlay for readability.
| Parameters |
data : pd.DataFrame | pl.DataFrame
Input data containing columns
rangeslider : bool, default=Trueopen, high, low, close
and dt with the datetime.
Whether to show the range slider below the chart.
title : str | dict | None, default=None
Title for the plot.
legend : str | dict | None, default="upper left"
Legend for the plot. See the user guide for an extended
description of the choices.
figsize : tuple[int, int], default=(900, 600)
Figure's size in pixels, format as (x, y).
filename : str | Path | None, default=None
Save the plot using this name. The type of the file depends on the
provided name (
display : bool | None, default=True.html, .png, .pdf, etc...). If filename has no
file type, the plot is saved as .html. If None, the plot isn't saved.
Whether to render the plot. If
None, it returns the figure.
|
| Returns |
Figure | None
The Plotly figure object. Only returned if
display=None.
|
See Also
Create a price line chart.
Create a trading volume bar chart.
Create a VWAP (Volume-Weighted Average Price) chart.
Example
>>> from backtide.storage import query_bars
>>> from backtide.analysis import plot_candlestick
>>> df = query_bars("AAPL", "1d")
>>> # Show only the last 30 days
>>> df = df.sort_values("open_ts").iloc[-30:]
>>> plot_candlestick(df, title="AAPL Daily")