Code not working On BlueShift

Dear Quantra teachers, 

why is the following code showing 'truth value of a series is ambiguous' error on blueshift when I am running:

from blueshift.api import symbol, schedule_function, order_target_percent, date_rules, time_rules

def initialize(context):

context.security = symbol('AMZN')

schedule_function(entry_position,

date_rules.every_day(),

time_rules.market_open(minutes=5))

schedule_function(exit_position,

date_rules.every_day(),

time_rules.market_close(minutes=10))

def entry_position(context, data):

try:

vol = data.history(context.security, ['volume'], 90, '1d')

cv = data.current(context.security, 'volume')

except IndexError:

print("Error fetching data")

return

if vol.empty:

print("Volume data is empty")

return

avg_vol = vol.mean()['volume']

le = cv > 2 * avg_vol

se = cv < avg_vol * 0.5

print(f"Current Volume: {cv}")

print(f"Average Volume: {avg_vol}")

print(f"Long Entry: {le}")

print(f"Short Entry: {se}")

if le:

order_target_percent(context.security, 1)

elif se:

order_target_percent(context.security, -1)

def exit_position(context, data):

print("Exiting position")

order_target_percent(context.security, 0)

Hi Advait,



The code is working for me without any errors. Can you try re-running it once? If you are still getting an error, please share the "Console" logs to help us debug it. You can find the Console logs just below the "Run" button in the Quick Run tab.