I cannot execute this code. It says ValueError: The truth value of a Series is ambiguous. (for "if" statement line)... Please help!
def initialize(context):
context.security = symbol('AAPL')
schedule_function(handle_entry, date_rules.every_day(), time_rules.market_open(minutes=30))
def handle_entry(context, data):
close_price = history(2, '1d', field='price')
open_price = history(2, '1d', field='open_price')
gap = close_price[context.security] - open_price[context.security]
log.info(gap, gap)
if gap > 0:
order(sid(24), 50)
def handle_data(context, data):
pass