I'm new to this, and I just want to make a simple rebalancer that rebalances to 60% whenever it goes ~10% out of range. I tried the code below but the backtest seems to take a long time, and I'm not convinced about the results. Does anyone see what I'm doing wrong?
I would really like to keep this simple if possible.
def initialize(context): set_commission(commission.PerShare(cost=0.03, min_trade_cost=None)) context.security=symbol('AAPL') def handle_data(context, data): if context.account.leverage > 0.7 or context.account.leverage < 0.5: order_target_percent(context.security,0.6)