Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Set universe/context as a custom benchmark

Is it possible to set the stocks in the universe/context as the custom benchmark? I would like to compare the performance of my algorithm with the combined performance of the stocks I have the option to invest in, to see if my algorithm adds any value. if not possible, are any workarounds possible, like a separate chart with record?

3 responses

It's possible to change the benchmark to another equity using set_benchmark (here are the docs). But it's not possible to create a customized benchmark using multiple equities in the IDE. You can head over to the research environment to graph the portfolio returns against different benchmarks and create your own customized one.

Disclaimer

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.

You can construct your own index as the sum, or another linear combination, of a collection of securities, and record it. And/or subtract it from your portfolio value to get your excess performance.

    myindex=sum([data[sec].price for sec in context.securities])  
    myexcess=context.portfolio.portfolio_value  
    record(myindex=myindex, myexcess=myexcess)  

But for that to work, you need to know what your securities are. If you let Quantopian choose them with set_universe, you don't, because there is no get_universe. There should be a getter for every setter.

Awesome, thanks!

If I wanted an equally weighted index of the securities in my context, so that a 1% increase in a USD 5 stock has the same impact on the index as a 1% increase on a USD 20 stock, what would be a smart way to achieve that? Maybe even like a NAV figure starting at 100. But maybe this is more a generic Python question.