Hello, as I stated above, I'm very new to all of this and I'm trying to learn the basics. I was watching a youtube tutorial from a guy and I decided to just copy his algorithm and try to backtest it my self, just to start getting used to the platform. I copied his code word by word and somehow when I run it it doesn't place any orders. This video is about 3 years old so maybe something changed and that is why it doesn't work?
I appreciate the help, thanks.
This is the code:
def initialize(context): context.aapl = sid(24) def hande_data(context, data): hist = data.history(context.aapl, 'price', 50, '1d') log.info(hist.head()) sma_50 = hist.mean() sma_20 = hist[-20:].mean() open_orders = get_open_orders() if sma_20 > sma_50: if context.aapl not in open_orders: order_target_percent(context.aapl, 1.0) elif sma_50 > sma_20: if context.aapl not in open_orders: order_target_percent(context.aapl, -1.0) record(leverage = context.account.leverage)