Back to Community
Wonky algorithm / benchmark returns

Why does buying and holding SPY perform so much differently than the benchmark? I noticed that when I try to invest the entire $1M in my sample portfolio that it invests $1.005M, which may be a portion of the problem, but certainly does not fully explain it. (Speaking of, how would I invest the portfolio amount?)

Clone Algorithm
Total Returns
Max Drawdown
Benchmark Returns
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
import math

# Put any initialization logic here.  The context object will be passed to
# the other methods in your algorithm.
def initialize(context):
    context.invested = False

# Will be called on every trade event for the securities you specify. 
def handle_data(context, data):
    # Implement your algorithm logic here.

    # data[sid(X)] holds the trade event data for that security.
    # data.portfolio holds the current portfolio state.

    # Place orders with the order(SID, amount) method.

    # TODO: implement your own logic here.
    spy = sid(8554)
    if not context.invested:
        shares = math.floor([spy].price)
        order(spy, shares)
        context.invested = True
This backtest was created using an older version of the backtester. Please re-run this backtest to see results using the latest backtester. Learn more about the recent changes.
There was a runtime error.
6 responses

I believe I read a different thread that explains this. The benchmark does not include dividends but is price only, while the algo includes dividends.

If that's the case it would certainly explain it.

Hi Ben,

Rex nailed it - the difference is that the benchmark does not reinvest the dividends. For more info, see this thread he was referring to:

If you have suggestions, we'd love to hear them!


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Thank you for confirming, Alisa. I see that Dan also believes there should be a total return benchmark used by default. I really hope that can be prioritized since it seems like an easy fix and it has a big impact to a really core part of the platform.

I completely agree and if it was an easy fix as you mentioned, I'd love to see the change. We're aware of the discrepancy and unfortunately its not an easy fix, otherwise we would have gladly made the adjustment!

Hmm, okay, well I appreciated that you're aware and looking at it. I figured you'd just pop in a different data series and be good to go.