Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,12 @@ def test_cum_returns_benchmark_trace(self):
assert "Value" in nt
assert isinstance(nt["Value"], go.Scatter)
assert len(nt["Value"].y) == len(index_5)
# Custom benchmark returns should also work when plotting a selected portfolio column.
fig = pf_multi.plot_cum_returns(column="a", benchmark_rets=pf_multi["b"].returns())
nt = named_traces(fig)
assert "Benchmark" in nt
assert isinstance(nt["Benchmark"], go.Scatter)
assert len(nt["Benchmark"].y) == len(index_5)

def test_smoke_plot_drawdowns(self):
self._assert_fig(
Expand Down
2 changes: 1 addition & 1 deletion vectorbt/portfolio/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5385,7 +5385,7 @@ def plot_cum_returns(
if benchmark_rets is None:
benchmark_rets = self.benchmark_returns(group_by=group_by)
else:
benchmark_rets = broadcast_to(benchmark_rets, self.obj)
benchmark_rets = broadcast_to(benchmark_rets, self.wrapper.dummy(group_by=group_by))
benchmark_rets = self.select_one_from_obj(benchmark_rets, self.wrapper.regroup(group_by), column=column)
kwargs = merge_dicts(
dict(
Expand Down
Loading