Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Filtering in current time from pipeline

Hello, I'm having some trouble filtering my pipeline down in current time. I want to filter my current security list (context.security_list) to equities that have a negative return over the first 15 minutes of trading from the current context.security_list. Parts of my code are attached below. Let me know if I need to include more data.

def initialize(context):

# Create our dynamic stock selector.  
algo.attach_pipeline(make_pipeline(), 'pipeline')  

schedule_function(func=sell_equities,  
                  date_rule=date_rules.every_day(),  
                  time_rule=time_rules.market_open(minutes = 15))

... (pipeline code)...

def sell_equities(context, data):
#price list @ open
list_open = data.current(context.security_list,'open')
#price at 9:45am
list_945am = data.current(context.security_list,'price')
#difference as a percent
list_percent = (list_945am - list_open) / list_open

context.percent = list_percent

Does anyone know how to only include those stocks which are in context.security_list and have a negative return from the first 15 min of trading?

Thank you!!!

2 responses

Just wanted to recheck and see if anyone knows how to do this. Should be a quick fix I believe!!

Thank you!!!!!

@Nick...err...not possible I believe....on the Q platform, pipeline only runs in before_trading_start, and uses daily data...
See, for tips:
https://www.quantopian.com/posts/quantopian-learning-and-testing-note
alan