Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Referencing qtradable universe

I am trying to make a price variable that assigns the close on a hourly chart of the last bar of the securities in the qtradableus() function. But i keep getting errors.

I am trying to make a algo that will trade all of what is available. or up to the max limit i am allowed to do. Do i need to make a array or something? I am new to this so I have been self teaching. I manage to debug all the other errors and this is the only issue i have left.
I want it to just go through a security in the universe check for my parameters, if it meets them put the trade then go to the next one. i have my parameters working just having trouble with getting price.

def make_pipeline():

data = QTradableStocksUS()  
price_history = data.history(100, frequency='1h', field='price')  
price = price_history( 'close', '1h')  
3 responses

This will give you all the stocks in QTradableStocksUS:

def make_pipeline():  
    return Pipeline(  
        columns={  
        },  
        screen=QTradableStocksUS()  
    )  

Then you'd do something like this to get that list:

before_trading_start(context):  
    context.output = algo.pipeline_output('pipeline')  

I don't think 1h is a valid frequency. If it is, it's new to me. Either 1d or 1m. You can synthesize 1h from 1m by being clever. You'll need get_datetime().minute to check how far into the hour you are, and then you can calculate how far back in time you need in order to get the 1hr close.

Thanks, this helps a ton. I am new to python but am learning more every day my biggest issue is i'm over complicating this stuff i gotta stop doing that.. I will get creative then with the minute function if 1h is not a valid frequency I would think that shouldn't be to hard to accomplish.