Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
is there a limit to the number of SIDs that can be referenced?

I've been trying to break a large number of SID references into categories like so...

    context.hyd['aerospaceDefense']  = [sid(18027),sid(12691),sid(6458),sid(29176),sid(6583),  
                                        sid(3136),sid(42021),sid(41113),sid(15991),sid(43150),  
                                        sid(23852),sid(22880),sid(4195),sid(698),sid(9156),sid(600),  
                                        sid(2015),sid(41111),sid(21755),sid(18568)]  
    context.hyd['automotive']        = [sid(39563),sid(3597),sid(7217),sid(4878),sid(36344),sid(16838),  
                                        sid(42637),sid(3286),sid(4117),sid(7433),sid(7039),sid(5787),  
                                        sid(3499),sid(6992),sid(6967),sid(42173),sid(22460),sid(43449),  
                                        sid(12379),sid(35166)]  

this works up to a point, but it seems like I reach a limit of some sort and I when I try and build I get the error:

Algorithm must reference 1 to 10 SIDs, inclusive.

The way the message reads to me seems to indicate that I can only use up to 10 SIDs, however I'm well over 10 before I get the error. What am I missing?

6 responses

Upon a second search, I did find this thread, however, I don't quite see in there an explicit limit to the number of SIDs which appears to be more than 10. But some of that discussion is a little over my head so I may just be missing the obvious. If anyone could clarify it would be well appreciated.

Hello Pumplerod,

Here's a list of 100 sids that works:

# Nasdaq 100 from https://www.quantopian.com/posts/list-of-nasdaq-100-sids-to-use-in-your-algo  
    context.stocks = [sid(24),    sid(114),   sid(122),   sid(630)  , sid(67),  
              sid(20680), sid(328),   sid(14328), sid(368),   sid(16841),  
              sid(9883),  sid(337),   sid(38650), sid(739),   sid(27533),  
              sid(3806),  sid(18529), sid(1209),  sid(40207), sid(1419),  
              sid(15101), sid(17632), sid(39095), sid(1637),  sid(1900),  
              sid(32301), sid(18870), sid(14014), sid(25317), sid(36930),  
              sid(12652), sid(26111), sid(24819), sid(24482), sid(2618),  
              sid(2663),  sid(27543), sid(1787) , sid(2696),  sid(42950),  
              sid(20208), sid(2853),  sid(8816),  sid(12213),  sid(3212),  
              sid(9736),  sid(23906), sid(26578), sid(22316), sid(13862),  
              sid(3951),  sid(8655),  sid(25339), sid(4246),  sid(43405),  
              sid(27357), sid(32046), sid(4485),  sid(43919), sid(4668),  
              sid(8677),  sid(22802), sid(3450),  sid(5061),  sid(5121),  
              sid(5149),  sid(5166),  sid(23709), sid(13905), sid(19926),  
              sid(19725), sid(8857),  sid(5767),  sid(5787),  sid(19917),  
              sid(6295),  sid(6413),  sid(6546),  sid(20281), sid(6683),  
              sid(26169), sid(6872),  sid(11901), sid(13940), sid(7061),  
              sid(15581), sid(24518), sid(7272),  sid(39840), sid(7671),  
              sid(27872), sid(8017),  sid(38817), sid(8045),  sid(8132),  
              sid(8158),  sid(24124), sid(8344),  sid(8352),  sid(14848)]  

I think that the limit is 100 (unless you are using set_universe, which selects the sids for you). Try adding another sid to the Nasdaq 100 list and see what happens.

Grant

Sure enough, that crashes when you try with 101. So I guess the error should actually be:
Algorithm must reference 1 to 100 SIDs, inclusive.

Based on this, how would one attempt to break up securities into various sectors? I was attempting to create a universe of securities which offer high rate or high yield dividends and that are divided into various industry sectors such as pharmaceuticals, electronics, etc...

Ideally (for me) each SID would also have as part of its data variables such as "sector", "sub_sector", "market_cap", "dividend_rate", "dividend_yield" and things of that nature. Is there a clever way to somehow get at this information?

I don't believe the info. you want is available in the Quantopian database; you just get OHLCV. I suggest looking into fetcher to load in the info., or type it in manually. --Grant

Yes, I was attempting to type it in manually, however, that's when I came across this problem of referencing too many SIDs. I guess the only way to go about this would be to setup my universe with set_universe(universe.DollarVolumeUniverse(floor_percentile=1.0, ceiling_percentile=100.0)) and then have a separate database which I query against for every stock in my universe to determine where it fits regarding sector and dividends.

Intuitively that just feels wrong to me. It seems like it would have been a common enough thing to look for that I thought others may have already put together a solution.

You may only be able to get at a few percent of the dollar-volume universe at a time. As I understand, the backtester just can't handle all of the sids at once (I recall maybe ~15,000 total). --Grant