#NEWLINE# def run( self , data , symbols , start , end , lookback , **kwargs ) : #NEWLINE# #INDENT# bollinger_data = data [ 'bollinger' ] #NEWLINE# start_index = ( bollinger_data . index . get_loc ( start ) - 1 ) #NEWLINE# timestamps = bollinger_data . index [ start_index : ] #NEWLINE# bollinger_spy = ( bollinger_data [ 'SPX' ] >= 1.2 ) #NEWLINE# bollinger_today = ( bollinger_data . loc [ timestamps [ 1 : ] ] <= ( - 2.0 ) ) #NEWLINE# bollinger_yesterday = ( start_index . loc [ timestamps [ : ( - 1 ) ] ] >= ( - 2.0 ) ) #NEWLINE# bollinger_yesterday . index = bollinger_today . index #NEWLINE# events = ( bollinger_today & bollinger_yesterday ) . mul ( bollinger_spy , axis = 0 ) #NEWLINE# return events . fillna ( 0 )