ranaroussi / quantstats

Portfolio analytics for quants, written in Python
Apache License 2.0
4.91k stars 851 forks source link

html report file is empty #243

Closed KIC closed 1 year ago

KIC commented 1 year ago

for some reason the html file for the report is empty:

qs.reports.html(dfhist["TOTAL", "return"], benchmark, output="assets/min-variance-report.html")

however the

qs.reports.full(dfhist["TOTAL", "return"], benchmark)

works as expected.

No errors were thrown only several warnings about Arial font can't be found.

findfont: Font family 'Arial' not found.

elektor123 commented 1 year ago

qs.reports.html takes pd.Series as input for strategy. Here you are giving a pandas as input.

Following code worked for me from backtrader timeReturn analyzer.

returns_dict = thestrat.analyzers.time_return.get_analysis()
# Convert the dictionary to a DataFrame
returns_df = (
    pd.DataFrame(
        list(returns_dict.items()),
        columns = ["date", "return"]
    )
    .set_index("date")
)
returns = pd.Series(returns_df['return'])

qs.reports.html(
    returns,
    benchmark=benchmark,
    output='tear_sheet.html'
)
KIC commented 1 year ago

I pass a series my frame has a MultiIndex and thus ["TOTAL", "return"] evaluates to a Series.