quantstats icon indicating copy to clipboard operation
quantstats copied to clipboard

add prepare_returns inside prepare_benchmark and make_index

Open BoudewijnKlijn opened this issue 3 years ago • 0 comments

This PR fixes an unexpected result when a ticker is compared with a benchmark.

If the ticker and the benchmark are identical, the metrics in the report should be identical as well.

In the basic report, the returns of the ticker are prepared: returns = _utils._prepare_returns(returns)

Hence, to get consistent results, the benchmark should also be prepared.

Code to show old benchmark gives inconsistent metrics

import quantstats as qs

qs.extend_pandas()
TICKER = 'SPY'
returns = qs.utils.download_returns(TICKER)

# Create report. Note inconsistent 'Cumulative Return'.
metrics = qs.reports.basic(returns, returns)

BoudewijnKlijn avatar Aug 09 '22 21:08 BoudewijnKlijn