PortfolioAnalyzer
vbt.Portfolio.
Method generated by attrs for class PortfolioAnalyzer.
Class variables
-
data: vectorbtpro.data.base.Data: Data object. -
s1: str: First symbol. -
s2: str: Second symbol. -
vbt: vectorbtpro.portfolio.base.Portfolio: VectorBT PRO Portfolio object. -
model_output: pandas.core.frame.DataFrame | numpy.ndarray: Model output used in the strategy. Defaults toNone. -
window: int: Rolling window used in the model. Defaults toNone. -
minp: int: Minimum number of observations required in the model. Defaults toNone.
Instance variables
-
freq: pandas._libs.tslibs.timedeltas.Timedelta: Get the frequency of the data. -
column_wrapper: List[str]: Get the column wrapper for the portfolio. If MultiIndex (where group_by isFalse), Get the first level only. -
categories: pandas.core.frame.DataFrame | None: Retrieve asset categories. -
drawdowns_readable: Get the drawdowns of the portfolio. -
pfo: vectorbtpro.portfolio.pfopt.base.PortfolioOptimizer: Pick allocations from an already filled array. -
pfo_allocations: pandas.core.frame.DataFrame: Get the portfolio allocations. -
latest_allocation: pandas.core.frame.DataFrame: Get the latest allocation of the portfolio. -
current_holdings: Get the current holdings of the portfolio. -
pfo_describe: pandas.core.frame.DataFrame: Get descriptive statistics of portfolio allocations. -
average_allocation: Get the average allocation of the portfolio. -
allocation_records_readable: Get readable allocation records. -
latest_allocation_records: Get the latest allocation records.
Methods
get_signals
group_by=False to disable grouping.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
sim_start | ArrayLike | None | Start index of the simulation range. |
sim_end | ArrayLike | None | End index of the simulation range. |
group_by | bool | False | Grouping specification. |
| Type | Description |
|---|---|
Signals | systematica Signals namedtuple class. |
get_market_returns
| Type | Description |
|---|---|
pd.DataFrame | DataFrame of market returns. |
get_rolling_metrics
| Name | Type | Default | Description |
|---|---|---|---|
metrics | str | -- | Metric to compute |
window | int | None | Rolling window length. The default is None. |
minp | int | None | Mininum periods. The default is None. |
to_numpy | bool | False | Output numpy array if True. The default is False. |
validate_metrics | bool | True | Validate metrics if True. The default is True. |
kwargs | tp.Kwargs | -- | Additional key-word arguments passed to MetricRegistry.run_rolling_metric. |
| Type | Description |
|---|---|
ValueError | if parameter window is to be specified.. |
| Type | Description |
|---|---|
pd.DataFrame | tp.Array | Rolling metrics. |
all_stats
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
portfolio | tp.Kwargs | None | Addtional arguments for vbt.stats. Defaults to None. |
drawdowns | tp.Kwargs | None | Addtional arguments for vbt.drawdowns.stats. Defaults to None. |
| Type | Description |
|---|---|
pd.Series | All portfolio, returns, orders, trades and drawdowns statistics. |
plot_rolling_metrics
| Name | Type | Default | Description |
|---|---|---|---|
metrics | str | -- | Metric to compute |
window | int | None | Rolling window length. The default is None. |
minp | int | None | Mininum periods. The default is None. |
validate_metrics | bool | True | Validate metrics if True. The default is True. |
layout_kwargs | tp.Kwargs | -- | Additional layout keyword arguments passed to vbt.FigureWidget.plot. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the rolling metric. |
plot_equity_curve
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
bm_returns | bool | False | Whether to include benchmark returns. Defaults to False. |
layout_kwargs | tp.Kwargs | -- | Additional layout keyword arguments. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the equity curve. |
plot_performance_pnl
| Name | Type | Default | Description |
|---|---|---|---|
symbol | str | -- | Symbol to plot. |
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
group_by | bool | False | Whether to group by. Defaults to False. |
pct_scale | bool | False | Whether to scale by percentage. Defaults to False. |
marker_size_range | tuple | “(7,` | 14)` Range of marker sizes. Defaults to (7, 14). |
opacity_range | tuple | “(0.75,` | 0.9)` Range of opacity. Defaults to (0.75, 0.9). |
closed_trace_kwargs | dict | None | Keyword arguments for closed trace. |
closed_profit_trace_kwargs | dict | None | Keyword arguments for closed profit trace. |
closed_loss_trace_kwargs | dict | None | Keyword arguments for closed loss trace. |
open_trace_kwargs | dict | None | Keyword arguments for open trace. |
hline_shape_kwargs | dict | None | Keyword arguments for horizontal line shape. |
add_trace_kwargs | dict | None | Keyword arguments for adding trace. |
xref | str | x | X reference. Defaults to x. |
yref | str | y | Y reference. Defaults to y. |
fig | vbt.FigureWidget | None | Existing figure widget. |
layout_kwargs | tp.Kwargs | -- | Additional layout keyword arguments. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the performance PnL. |
plot_running_edge_ratio
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
volatility | float | None | Volatility value. |
entry_price_open | bool | False | Whether to use entry price open. Defaults to False. |
exit_price_close | bool | False | Whether to use exit price close. Defaults to False. |
max_duration | int | None | Maximum duration. |
incl_shorter | bool | False | Whether to include shorter durations. Defaults to False. |
group_by | str | None | Group by value. |
jitted | bool | None | Whether to use jitted mode. Defaults to None. |
xref | str | x | X reference. Defaults to x. |
yref | str | y | Y reference. Defaults to y. |
hline_shape_kwargs | dict | None | Keyword arguments for horizontal line shape. |
kwargs | tp.Kwargs | -- | Additional keyword arguments. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the running edge ratio. |
plot_performance_reset
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
by | str | Y | Reset by value. Defaults to Y. |
add_close | bool | True | Whether to add close prices. Defaults to True. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the performance reset. |
plot_performance_rebase
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
add_close | bool | True | Whether to add close prices. Defaults to True. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the performance rebase. |
plot_performance_matrix
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
plot_kwargs | tp.Kwargs | -- | Additional plot keyword arguments. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the performance matrix. |
plot_drawdown_and_underwater
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
plot_kwargs | tp.Kwargs | -- | Additional plot keyword arguments. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the drawdowns. |
plot_allocation_report
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
column | tp.Label | None | Column to plot. |
dropna | str | head | Drop NaN values. Defaults to head. |
line_shape | str | hv | Line shape. Defaults to hv. |
plot_rb_dates | bool | None | Whether to plot rebalancing dates. |
trace_kwargs | dict | None | Keyword arguments for trace. |
add_shape_kwargs | dict | None | Keyword arguments for adding shape. |
add_trace_kwargs | dict | None | Keyword arguments for adding trace. |
fig | vbt.FigureWidget | None | Existing figure widget. |
group_by_category | bool | False | Whether to group by category. Defaults to False. |
layout_kwargs | tp.Kwargs | -- | Additional layout keyword arguments. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the allocations. |
plot_pie_allocation
| Name | Type | Default | Description |
|---|---|---|---|
rp_kwargs | dict | None | Keyword arguments for radial plot. |
trace_kwargs | dict | None | Keyword arguments for trace. |
add_trace_kwargs | dict | None | Keyword arguments for adding trace. |
make_figure_kwargs | dict | None | Keyword arguments for making the figure. |
fig | vbt.FigureWidget | None | Existing figure widget. |
layout_kwargs | tp.Kwargs | -- | Additional layout keyword arguments. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the pie chart. |
plot_average_allocation
| Name | Type | Default | Description |
|---|---|---|---|
rp_kwargs | dict | None | Keyword arguments for radial plot. |
trace_kwargs | dict | None | Keyword arguments for trace. |
add_trace_kwargs | dict | None | Keyword arguments for adding trace. |
make_figure_kwargs | dict | None | Keyword arguments for making the figure. |
fig | vbt.FigureWidget | None | Existing figure widget. |
layout_kwargs | tp.Kwargs | -- | Additional layout keyword arguments. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the pie chart. |
plot_cash_report
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
plot_kwargs | tp.Kwargs | -- | Additional plot keyword arguments. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the cash balance. |
plot_expanding_excursions
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
plot_kwargs | tp.Kwargs | -- | Additional plot keyword arguments. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the expanding excursions. |
plot_excursions
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
plot_kwargs | tp.Kwargs | -- | Additional plot keyword arguments. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the excursions. |
plot_trades_by_symbol
| Name | Type | Default | Description |
|---|---|---|---|
symbol | str | -- | Symbol to plot. |
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the trades by symbol. |
plot_all_trades
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
layout_kwargs | tp.Kwargs | -- | Additional layout keyword arguments. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of all trades. |
plot_dashboard
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start date. Defaults to None. |
end | pd.Timestamp | None | The end date. Defaults to None. |
showlegend | bool | False | Show legend. Defaults to False. |
layout_kwargs | tp.Kwargs | -- | Additional layout keyword arguments. |
| Type | Description |
|---|---|
vbt.FigureWidget | Figure widget of the dashboard. |

