Hi, How can i calculate the # of sids from set_universe, in order to define the position weight,
Thanks
Hi, How can i calculate the # of sids from set_universe, in order to define the position weight,
Thanks
Try
n=len(get_universe())
and if get_universe
doesn't exist, complain, because there should be a getter for every setter.
For now, you can use data.keys()
from within handle_data
, but that will only give you those securities in your universe that have traded in the last minute.
Yes, you can. But what good will it do?
You could write and run outside Quantopian:
print """def initialize(context):
context.stocks = [
"""
for n in xrange(1, 8000):
print " "*8 + "sid({}),".format(n)
print """ ]
def handle_data(context, data):
pass
"""
Then paste the output into the Quantopian IDE as a new algorithm and run it. It will throw an error on the first invalid SID. Comment it out and run the code again. Repeat until you have no invalid SIDs.