Skip to main content

plot_allocation

plot_allocation(
    data: vectorbtpro.data.base.Data,
    signals: ~Signals,
    fig: vectorbtpro.utils.figure.FigureWidget = None,
)
Plot asset allocation based on trading signals. Parameters:
NameTypeDefaultDescription
datavbt.Data--Data object containing asset prices.
signalsSignalsT--Object containing trading signals.
figvbt.FigureWidgetNoneExisting figure to update. Defaults to None.
Returns:
TypeDescription
vbt.FigureWidgetFigure containing the allocation plot.

plot_signal_crossover

plot_signal_crossover(
    model_output: pandas.core.series.Series,
    upper_crossed: pandas.core.series.Series,
    lower_crossed: pandas.core.series.Series,
    upper: float,
    lower: float,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot signal crossover points with upper and lower bounds. Parameters:
NameTypeDefaultDescription
model_outputpd.Series--Model output series.
upper_crossedpd.Series--Series indicating upper boundary crossovers.
lower_crossedpd.Series--Series indicating lower boundary crossovers.
upperfloat--Upper threshold value.
lowerfloat--Lower threshold value.
Returns:
TypeDescription
vbt.FigureWidgetFigure containing the crossover plot.

plot_signals

plot_signals(
    data: vectorbtpro.data.base.Data,
    symbol: str,
    signals: ~Signals,
    fig: vectorbtpro.utils.figure.FigureWidget = None,
    **plot_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot trading signals on a price chart. This function overlays trading signals (long/short entries and exits) on a price chart for a given asset symbol. It uses the provided data and signals to generate the plot. Parameters:
NameTypeDefaultDescription
datavbt.Data--A data object containing asset prices and other relevant information.
symbolstr--The asset symbol to plot.
signalsSignalsT--An object containing trading signals (long/short entries and exits).
figvbt.FigureWidgetNoneAn existing figure to update. If None, a new figure is created. Defaults to None.
plot_kwargstp.Kwargs--Additional keyword arguments for customizing the plot.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the signals plot.
Examples:
>>> fig = plot_signals("AAPL", data, signals)
>>> fig.show()

plot_signal_vlines

plot_signal_vlines(
    df: pandas.core.frame.DataFrame,
    symbol: str,
    signals: ~Signals,
    **plot_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot long and short entry signals as vertical lines. Parameters:
NameTypeDefaultDescription
dfpd.DataFrame--Dataframe containing price data.
symbolstr--Symbol for which to plot signals.
signalsSignals--Signal object containing entry points.
plot_kwargstp.Kwargs--Additional keyword arguments for plotting.
Returns:
TypeDescription
vbt.FigureWidgetA figure with entry signals plotted as vertical lines.

plot_dashboard

plot_dashboard(
    data: vectorbtpro.data.base.Data,
    s1: str,
    s2: str,
    pf: vectorbtpro.portfolio.base.Portfolio,
    model_output: numpy.ndarray,
    showlegend: bool = False,
    **layout_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Generate a dashboard visualization for a pair of assets. Parameters:
NameTypeDefaultDescription
datavbt.Data--Market data.
s1str--First asset symbol.
s2str--Second asset symbol.
pfvbt.Portfolio--Portfolio object.
model_outputtp.Array--Model output data.
showlegendboolFalseShow legend. Defaults to False.
layout_kwargstp.Kwargs--Additional keyword arguments for customizing the layout.
Returns:
TypeDescription
vbt.FigureWidgetA dashboard figure displaying asset data, portfolio returns, and signals.

plot_pie_chart

plot_pie_chart(
    *args,
    **kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot a pie chart. This function creates a pie chart using the Pie class from systematica.utils.custom_plots. Parameters:
NameTypeDefaultDescription
argstp.Args--Positional arguments passed to the Pie class.
kwargstp.Kwargs--Keyword arguments passed to the Pie class.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the pie chart.

plot_allocations

plot_allocations(
    pfo: vectorbtpro.portfolio.pfopt.base.PortfolioOptimizer,
    market_returns: pandas.core.frame.DataFrame,
    categories: pandas.core.frame.DataFrame = None,
    group_by_category: bool = False,
    column: Hashable = None,
    dropna: str = 'head',
    line_shape: str = 'hv',
    plot_rb_dates: bool = None,
    trace_kwargs: Dict[str, Any] | Sequence[Dict[str, Any] | None| None = None,
    add_shape_kwargs: Dict[str, Any] | None = None,
    add_trace_kwargs: Dict[str, Any] | None = None,
    fig: plotly.basedatatypes.BaseFigure = None,
    **layout_kwargs,
) ‑> plotly.basedatatypes.BaseFigure
Plot portfolio allocations over time. This function visualizes portfolio allocations as an area plot. It supports grouping by categories and marking rebalancing dates. Parameters:
NameTypeDefaultDescription
pfovbt.PortfolioOptimizer--Portfolio optimizer object containing allocation data.
market_returnspd.DataFrame--DataFrame containing market returns.
categoriespd.DataFrameNoneDataFrame containing category information for assets. Defaults to None.
group_by_categoryboolFalseWhether to group allocations by category. Defaults to False.
columntp.LabelNoneColumn to select from the portfolio optimizer. Defaults to None.
dropnastr"head"How to handle NaN values in allocations. Defaults to head.
line_shapestr"hv"Shape of the lines in the area plot. Defaults to hv.
plot_rb_datesboolNoneWhether to plot rebalancing dates. Defaults to None.
trace_kwargstp.KwargsLikeSequenceNoneAdditional keyword arguments for traces. Defaults to None.
add_shape_kwargstp.KwargsLikeNoneAdditional keyword arguments for shapes. Defaults to None.
add_trace_kwargstp.KwargsLikeNoneAdditional keyword arguments for adding traces. Defaults to None.
figtp.BaseFigureNoneExisting figure to update. If None, a new figure is created. Defaults to None.
layout_kwargstp.Kwargs--Additional layout arguments for the figure.
Returns:
TypeDescription
tp.BaseFigureA Plotly BaseFigure containing the allocations plot.

plot_performance_matrix

plot_performance_matrix(
    pf: Any,
    **plot_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Create a performance matrix heatmap. This function generates a heatmap of performance metrics for the given portfolio by resampling returns data to a monthly frequency. The matrix displays monthly returns by year, with an additional column for the total annual return. Parameters:
NameTypeDefaultDescription
pftp.Any--The portfolio object containing return data.
plot_kwargstp.Kwargs--Additional keyword arguments passed to the heatmap function.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the performance matrix heatmap.
Examples:
>>> pf = ...  # Initialize your portfolio object
>>> fig = plot_performance_matrix(pf)
>>> fig.show()

plot_performance_reset

plot_performance_reset(
    data: pandas.core.series.Series | pandas.core.frame.DataFrame,
    by: str = 'M',
    fig: vectorbtpro.utils.figure.FigureWidget = None,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot performance reset by month or year. This function calculates and plots the percentage change in performance reset at the start of each month or year. Parameters:
NameTypeDefaultDescription
datatp.SeriesFrame--Time series data of performance values.
bystrMReset frequency: M for monthly or Y for yearly. Defaults to M.
figvbt.FigureWidgetNoneExisting figure to update. If None, a new figure is created. Defaults to None.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the performance reset plot.

plot_performance_rebase

plot_performance_rebase(
    df: pandas.core.series.Series | pandas.core.frame.DataFrame,
    fig: vectorbtpro.utils.figure.FigureWidget = None,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot rebased performance. This function rebases the performance data to a starting value of 1 and plots it. Parameters:
NameTypeDefaultDescription
dftp.SeriesFrame--Time series data of performance values.
figvbt.FigureWidgetNoneExisting figure to update. If None, a new figure is created. Defaults to None.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the rebased performance plot.

plot_cash

plot_cash(
    pf: Any,
    **plot_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot cash-related metrics for a portfolio. This function creates subplots for cash, cash flow, gross exposure, and net exposure. Parameters:
NameTypeDefaultDescription
pftp.Any--Portfolio object containing cash-related data.
plot_kwargstp.Kwargs--Additional keyword arguments for customizing the plot.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the cash-related plots.

plot_excursions

plot_excursions(
    pf: Any,
    expanding: bool = True,
    **plot_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot trade excursions for a portfolio. This function visualizes Maximum Adverse Excursion (MAE) and Maximum Favorable Excursion (MFE) for each trade in the portfolio. Parameters:
NameTypeDefaultDescription
pftp.Any--Portfolio object containing trade data.
expandingboolTrueWhether to plot expanding MAE/MFE. Defaults to True.
plot_kwargstp.Kwargs--Additional keyword arguments for customizing the plot.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the excursion plots.

plot_all_trades

plot_all_trades(
    pf: Any,
    **layout_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Create a plot of all trades in the portfolio. The function generates subplots for all trades within the specified portfolio. Parameters:
NameTypeDefaultDescription
porttp.Any--The portfolio object containing trade data.
layout_kwargstp.Kwargs--Additional keyword arguments for layout configuration.
Returns:
TypeDescription
vbt.FigureWidgetA figure widget containing the plots for all trades.
Examples:
>>> port = ...  # Initialize your portfolio object
>>> fig = plot_all_trades(port)
>>> fig.show()

plot_drawdown

plot_drawdown(
    pf: Any,
    **plot_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Create a drawdown plot for the portfolio. This function visualizes the drawdowns and underwater metrics of the portfolio. Parameters:
NameTypeDefaultDescription
porttp.Any--The portfolio object containing drawdown data.
plot_kwargstp.Kwargs--Additional keyword arguments for customizing the plot.
Returns:
TypeDescription
vbt.FigureWidgetA figure widget containing the drawdown plots.
Examples:
>>> pf = ...  # Initialize your portfolio object
>>> fig = plot_drawdown(pf)
>>> fig.show()

plot_trades

plot_trades(
    pf: Any,
    symbol: str,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot trades and asset flow for a specific symbol. This function creates subplots for trades, asset flow, and asset holdings. Parameters:
NameTypeDefaultDescription
pftp.Any--Portfolio object containing trade data.
symbolstr--Symbol for which to plot trades and asset flow.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the trades and asset flow plots.

plot_smas

plot_smas(
    close: pandas.core.frame.DataFrame,
    timeperiods: list = None,
    length: int = None,
    **plot_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot Simple Moving Averages (SMAs). This function calculates and plots SMAs for the specified time periods. Parameters:
NameTypeDefaultDescription
closepd.DataFrame--DataFrame containing closing prices.
timeperiodslist, optional--List of time periods for SMAs. Defaults to [20, 50, 100, 200].
lengthint, optional--Number of data points to include in the plot. Defaults to None (all data).
plot_kwargstp.Kwargs--Additional keyword arguments for customizing the plot.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the SMA plots.

plot_bbands

plot_bbands(
    close: pandas.core.frame.DataFrame,
    length: int = None,
    **plot_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot Bollinger Bands. This function calculates and plots Bollinger Bands for the given data. Parameters:
NameTypeDefaultDescription
closepd.DataFrame--DataFrame containing closing prices.
lengthintNoneNumber of data points to include in the plot. Defaults to None (all data).
plot_kwargstp.Kwargs--Additional keyword arguments for customizing the plot.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the Bollinger Bands plot.

plot_slope_range

plot_slope_range(
    close: pandas.core.frame.DataFrame,
    window: int = 50,
    length: int = None,
    **plot_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot slope ranges for a moving average. This function identifies and visualizes steep slopes in a moving average. Parameters:
NameTypeDefaultDescription
closepd.DataFrame--DataFrame containing closing prices.
windowint50Window size for the moving average. Defaults to 50.
lengthintNoneNumber of data points to include in the plot. Defaults to None (all data).
plot_kwargstp.Kwargs--Additional keyword arguments for customizing the plot.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the slope range plot.

plot_pattern

plot_pattern(
    close: pandas.core.frame.DataFrame,
    pattern: Union(annotations=(<class 'vectorbtpro.utils.params.Param'><class 'list'>), resolved=True= None,
    window: int = 50,
    max_window: int = 120,
    min_similarity: float = 0.8,
    length: int = None,
    **plot_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot pattern matches in price data. This function identifies and visualizes occurrences of a specified pattern in the price data. Parameters:
NameTypeDefaultDescription
closepd.DataFrame--DataFrame containing closing prices.
patternlist--or vbt.Param, default None Pattern to search for. Defaults None.
windowint50Minimum window size for pattern matching. Defaults to 50.
max_windowint120Maximum window size for pattern matching. Defaults to 120.
min_similarityfloat0.8Minimum similarity threshold for pattern matching. Defaults to 0.8.
lengthintNoneNumber of data points to include in the plot. Defaults to None (all data).
plot_kwargstp.Kwargs--Additional keyword arguments for customizing the plot.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the pattern match plot.

plot_frontier

plot_frontier(
    target_portfolio: pandas.core.frame.DataFrame,
    efficient_frontier: pandas.core.frame.DataFrame = None,
    portfolio_name: str = 'Target Portfolio',
    marker_color: str = 'red',
    marker_size: int = 20,
    make_figure_kwargs: Dict[str, Any] | None = None,
    fig: plotly.basedatatypes.BaseFigure = None,
    showscale: bool = True,
    **layout_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot Frontier. Parameters:
NameTypeDefaultDescription
target_portfoliopd.DataFrame--Target_portfolio.
efficient_frontierpd.DataFrameNoneEfficient frontier. If None, the frontier is not displayed.
portfolio_namestrTarget...Portfolio name. Defaults to Target Portfolio.
marker_colorstrredColor of the portfolio star shaped marker. Defaults to red.
marker_sizeint20Size of the portfolio star shaped marker. Default to 20.
make_figure_kwargstp.KwargsLikeNoneAdditional figure arguments. Defaults to None.
figttp.BaseFigureNoneFigure. Defaults to None.
showscaleboolTrueShow scale. Defaults to True.
layout_kwargstp.Kwargs--Additional layout arguments for the figure.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing frontier plot.

plot_scatter_matrix

plot_scatter_matrix(
    df: pandas.core.frame.DataFrame,
    metrics: List[str],
    params: List[str],
    n_columns: int = 3,
    **layout_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot trial. Parameters:
NameTypeDefaultDescription
dfpd.DataFrame--Trial dataframe.
metricstp.List[str]--Metric columns.
paramsstr--Param columns.
n_columnsint3Number of columns in the grid. Defaults to 3.
layout_kwargstp.Kwargs--Additional layout arguments for the figure.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the trials.

plot_histogram_matrix

plot_histogram_matrix(
    df: pandas.core.frame.DataFrame,
    metrics: List[str],
    **layout_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot trial. Parameters:
NameTypeDefaultDescription
dfpd.DataFrame--Trial dataframe.
metricstp.List[str]--Metric columns.
layout_kwargstp.Kwargs--Additional layout arguments for the figure.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the trials.

plot_density_heatmap

plot_density_heatmap(
    df: pandas.core.frame.DataFrame,
    metric: str,
    param: str,
    **kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot density heatmap. Parameters:
NameTypeDefaultDescription
dfpd.DataFrame--Trial dataframe.
metricstr--Metric column.
paramstr--Param column.
kwargstp.Kwargs--Additional layout arguments for the figure.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the trials.

plot_density_contour

plot_density_contour(
    df: pandas.core.frame.DataFrame,
    metric: str,
    param: str,
    colorscale: List[str | Tuple[float]],
    **kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot density contour. Parameters:
NameTypeDefaultDescription
dfpd.DataFrame--Trial dataframe.
metricstr--Metric column.
paramstr--Param column.
kwargstp.Kwargs--Additional layout arguments for the figure.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the trials.

plot_range_breakout_signals

plot_range_breakout_signals(
    data: vectorbtpro.data.base.Data,
    symbol: str,
    training_window: str = '2h',
    by: str = 'D',
    freq: str = 'hours',
    tol: float = 0.5,
    use_close: bool = True,
    **layout_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot range breakout. Parameters:
NameTypeDefaultDescription
datavbt.Data--A data object containing asset prices and other relevant information.
symbolstr--The asset symbol to plot.
training_windowstr2hThe split size of the training window used in splitter.from_grouper. Defaults to 2h
bystrDSplit data temporarily. Defaults to D for daily.
freqstrhoursSplit data with by. Defaults to hours.
tolfloat0.5Range tolerance to trigger a long/short signal such as trigger = tol * range_values. Defauts to 0.5.
use_closeboolTrueUse close or open price for signals. Defaults to True (close).
layout_kwargstp.Kwargs--Additional layout arguments for the figure.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the trials.

plot_range_breakout_model_output

plot_range_breakout_model_output(
    data: vectorbtpro.data.base.Data,
    symbol: str,
    training_window: str = '2h',
    by: str = 'D',
    freq: str = 'hours',
    tol: float = 0.5,
    use_close: bool = True,
    **layout_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
Plot range breakout indicator. Parameters:
NameTypeDefaultDescription
datavbt.Data--A data object containing asset prices and other relevant information.
symbolstr--The asset symbol to plot.
training_windowstr2hThe split size of the training window used in splitter.from_grouper. Defaults to 2h.
bystrDSplit data temporarily. Defaults to D for daily.
freqstrhoursSplit data with by. Defaults to hours.
tolfloat0.5Range tolerance to trigger a long/short signal such as trigger = tol * range_values. Defauts to 0.5.
use_closeboolTrueUse close or open price for signals. Defaults to True (close).
layout_kwargstp.Kwargs--Additional layout arguments for the figure.
Returns:
TypeDescription
vbt.FigureWidgetA Plotly FigureWidget containing the trials.