Hi everyone,
I encountered this problem when dealing with add_universe method in Jupyter Notebook. Here is the exact code that I have:
qb = QuantBook()
universe = qb.add_universe(qb.universe.etf("SPY"))
universe_history = qb.universe_history(universe, datetime(2024, 6, 19), datetime(2024, 6, 21))
spy_constituents = []
for x in universe_history[0]:
spy_constituents.append(x.symbol.value)
print(len(spy_constituents))
spy_constituents
Compare to the Excel file download from SPY current holdings, there are a few stock that I noticed wasn't on there and some not even on the holdings, which returned by the add_universe.
Symbol missing: BBWI, EG, FI, HST, PARA, RVTY, TT, WBD, WTW
Symbol that not on SPY but on the universe: WW, XPRO
I might be wrong and would really appreciate any help. Thank you!
Mia Alissi
Hi Tam,
The
add_universe
method in QuantConnect allows you to create a universe of securities that match the constituents of an ETF. However, please note that the constituents of an ETF can change over time, and the data you get from theadd_universe
method might not exactly match the current holdings you see on the SPY website. This is because the data in QuantConnect might not be updated in real-time.Here is an example of how to use the
add_universe
method:In your case, the symbols you mentioned (BBWI, EG, FI, HST, PARA, RVTY, TT, WBD, WTW) might not be part of the SPY ETF at the time you are querying the data. Similarly, the symbols that are not on SPY but are in the universe (WW, XPRO) might have been part of the SPY ETF at some point in the past.
If you believe there is a discrepancy in the data, you might want to check the date of the data you are querying and compare it with the historical constituents of the SPY ETF.
For more information about ETF universes, you can refer to the ETF Constituents Selection documentation.
I hope this helps! Let me know if you have any other questions.
Source: QuantConnect ETF Constituents Selection
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Tam Nguyen
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!