(I created another post for the actual question I was asking, by cloning my algorithm) There seems to be an issue with forum posting where some aspects of Python code are not viewable ion the post. What is showing below is not what I actually have between the "..." "..." in my post, could someone from support take a look, specifically, the if statement is not displaying correctly.
moving_average = ta.MA(timeperiod=30)
def initialize(context):
context.stocks = [sid(40107),sid(12652)]
context.voo = sid(40107)
context.dltr = sid(12652)
context.prev_voo_ma = 0
context.prev_dltr_ma = 0
context.portfolio.starting_cash = 1000
def handle_data(context, data):
moving_average_data = moving_average(data)
voo_ma = moving_average_data[context.voo]
dltr_ma = moving_average_data[context.dltr]
log.info("prev_ma: " + str(context.prev_voo_ma))
log.info("cur_ma: " + str(voo_ma))
if voo_ma context.prev_voo_dltr:
order_percent(context.voo, -1)
order_percent(context.dltr, 1)
else:
order_percent(context.dltr, -1)
order_percent(context.voo, 1)
context.prev_voo_ma = voo_ma
context.prev_dltr_ma = dltr_ma