Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
show me how plz?

i am trying to understand

 set_universe(universe.DollarVolumeUniverse(floor_percentile=90.0, ceiling_percentile=100.0))  

i am unsure of how to apply it without context of an item to execute the order.
can someone write a simple code of lets say if vwap(5) >1 buy, i know it wont make money, but just to see the coding. thanks

1 response

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