Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Problems with Ordering - Positions Are off by Huge Amounts

Could anyone help me out with this issue? I'm trying to write a simple sector rotation algorithm based on momentum, but there are some issues I'm running into with how ordering is implemented. When I'm running a backtest with $100,000, sometimes I get positions with over $3,000,000 invested.

1 response

Try:

def rebalance(context, data):  
    if get_open_orders():  
        return

    prices = history(context.moving_avg_window, '1d', 'price')  # unchanged line

    [ ... ]