Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Create Universe Based On Price From Pipeline Results

Hey there I was just wondering if you could help me use the pipeline to create a universe of 500 securities that are under $10. Here's what I've got so far.
Thanks for your help

from quantopian.algorithm import attach_pipeline, pipeline_output  
from quantopian.pipeline import Pipeline  
from quantopian.pipeline.data.builtin import USEquityPricing  
from quantopian.pipeline.factors import SimpleMovingAverage  
from quantopian.pipeline import CustomFactor  
import numpy as np  
import pandas as pd  
import datetime  
class PriceRange(CustomFactor):  
    # define inputs for the compute method  
    inputs = [USEquityPricing.close]  
    def compute(self, today, assets, out, close):  
        out[:] = close[-1]  
def initialize(context):

    context.stocks = []  
    stock_prices = PriceRange(window_length=10)  
    #attaches a name to the pipeline  
    pipe = attach_pipeline(Pipeline(), name = 'pipeline')  
    # adds the stock_prices variable to the stock_prices pipeline  
    pipe.add(stock_prices, 'pipeline')

def before_trading_start(context, data):  
    # Access results using the name passed to `attach_pipeline`.  
    context.stocks = [sid for sid in data]  
    results = pipeline_output('pipeline')  
    for stock in context.stocks:  
        price = data[stock].price  
        if price < 5:

            print results.iloc[:30]

    # Define a universe with the results of a Pipeline.  
    update_universe(results.sort('pipeline').index[:10])  
def handle_data(context, data):  
    variable = int