Good afternoon, I am having a problem with this simple algo which was taught to me by sentdex from the tutorial videos on youtube. His algo is wrong on line 10 he put Elif instead of IF, yet when he backtest his strategy it works for him and not for me. Please can someone come to my aid because I am not learning from his anymore.
def initialize(context):
context.aapl =sid(24)
def handle_data(context,data):
hist= data.history(context.aapl, 'price', 50, '1d')
log.info(hist.head())
sma_50 = hist.mean()
sma_20 = hist[-20:].mean()
if sma_20 > sma_50:
order_target_percent(context.aapl, 1.0)
if sma_50 > sma_20:
order_target_percent(context.aapl, -1.0)