import pandas as pd
import numpy as np
import quantstats_lumi as qs
stock = qs.utils.download_returns('META')
qs.reports.full(stock, "SPY")
Error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File ".../lib/python3.12/site-packages/pandas/core/generic.py", line 1577, in __nonzero__
raise ValueError(
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Looks like the plots class turns returns series into a dataframe just before _plots.returns() which is passed to _core.plot_timeseries(). In this class there's a section to set the min and max value of returns for the plot sizes that uses returns.min()/max() and compares that to the benchmark, which throws the error as min()/max() of the dataframe returns a series indexed by the strategy.
code throwing the error:
# Set y-axis limits to avoid blank space at the bottom and top
min_val = returns.min() <- series indexed by strategy
max_val = returns.max() <- series indexed by strategy
if benchmark is not None:
min_val = min(min_val, benchmark.min()) <- comparing series to scaler, source of error
max_val = max(max_val, benchmark.max())
ax.set_ylim(bottom=min_val, top=max_val)
Also, separate issue, after just doing a local fix for this (added extra min(): returns.min().min()/max(), this does break the reports.html() function) the plots appear and disappear immediately.
Code:
Error:
Looks like the plots class turns returns series into a dataframe just before _plots.returns() which is passed to _core.plot_timeseries(). In this class there's a section to set the min and max value of returns for the plot sizes that uses returns.min()/max() and compares that to the benchmark, which throws the error as min()/max() of the dataframe returns a series indexed by the strategy.
code throwing the error:
Also, separate issue, after just doing a local fix for this (added extra min(): returns.min().min()/max(), this does break the reports.html() function) the plots appear and disappear immediately.