Someone has an easy way to load all the S&P500 constituents in the context ?
Someone has an easy way to load all the S&P500 constituents in the context ?
You can trade the S&P 500 index using SPY (an ETF that tracks that index).
However you cannot load all 500 sids into your context because Quantopian has a limit of 100 manually identified sids.
Given the limit of 100 sids you could load the S&P 100 into your context. The attached backtest does exactly that. Note that I had to comment out a few stocks because they don't go back far enough (GOOG) or they have a period where they are delisted (GM). This introduces some "survivorship bias" so caveat emptor.
If you just want to trade the S&P 100 index there is OEF for that (an ETF that tracks the index).
Thanks Dennis! Nice. Do you have HISTORICAL S&P 100 constituents? Preferably going back to 2002 when Quantopian has data. We all know index members are added and dropped. I just want a list of S&P 100 constituents by year(2002,2003,...,2014,etc_. This would be a really nice featured given that Quantopian has all the dead issues going back historically.
Hi Aidan,
Thanks for putting that together! Since I'm new to Quantopian, I have a few questions. So, your csv has all the S&P 100 constituents going back to 2008(?) and it changes from year to year(great!).
When I backtest it, the symbol list changes accordingly? Please bare with the newbie question here.
Thanks!
So, your csv has all the S&P 100 constituents going back to 2008(?) and it changes from year to year(great!).
Yes, the first date is in Dec 2008. The constituents change whenever they were updated on the Wikipedia page. As it's from Wikipedia, the accuracy of the data is questionable. The list was updated more regularly from 2012 onwards.
When I backtest it, the symbol list changes accordingly?
Yes.
I also wrote a function to scrape the ticker list for the S&P 500, you can find details on my blog here.
For historical components of S&P 500, check this: http://marketcapitalizations.com/historical-data/historical-components-sp-500/
This feed from EventVestor might also fit the bill for you: https://www.quantopian.com/store/eventvestor/index_changes
(Also that 100 limit from 2013 at the top of the thread is now 500 as of late 2015. Progress!)
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.