quantstats icon indicating copy to clipboard operation
quantstats copied to clipboard

Inconsistent results strategy vs. benchmark

Open BoudewijnKlijn opened this issue 3 years ago • 1 comments

When you compare the returns of a strategy with a benchmark, results are slightly different when the input returns for the strategy and the benchmark are identical.

Expected When returns of strategy and benchmark are identical, the report should give back identical performance metrics.

Solution When the benchmark is prepared, it yields the same results.

See minimum code below:

import quantstats as qs

# extend pandas functionality with metrics, etc.
qs.extend_pandas()

# fetch the daily returns for a stock
TICKER = 'SPY'
returns = qs.utils.download_returns(TICKER)

# prepare returns
prepared_returns = qs.utils._prepare_returns(returns)

# Create report to observe differences.
metrics = qs.reports.basic(returns, returns)  # different cumulative return for strategy and benchmark
metrics = qs.reports.basic(returns, TICKER)  # different cumulative return for strategy and benchmark
metrics = qs.reports.basic(returns, prepared_returns)  # __SAME__ cumulative return for strategy and benchmark

BoudewijnKlijn avatar May 11 '22 22:05 BoudewijnKlijn

Interesting

apoorvsingh090 avatar Sep 22 '22 16:09 apoorvsingh090