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!!!