This should get you started. Any sids that are added to the context in initialize will always be included in the data "dict". All other sids are the ones selected by the universe.
def initialize(context):
set_universe(universe.DollarVolumeUniverse(floor_percentile=90.0,
ceiling_percentile=100.0))
context.indexes = [sid(8554)]
def handle_data(context, data):
for sid in data:
if sid in context.indexes:
log.info("Index %s vwap(5) %s" % (sid, data[sid].vwap(5)))
try:
if data[sid].vwap(5) > 1:
log.info("Ordering %s" % sid)
order(sid, 1)
except Exception: # NoTradeDataAvailable phantom exception ;)
log.debug("No trade data for sid(%s)" % sid)
Happy Hacking!
7-11