Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
I'm getting a type error, please help.

I am trying to make a very basic algo using the SMA_50 and SMA_200 quotients. I am trying to write code to sell a position once it's not in the top 5 quotients. However, I am getting the error "TypeError: unbound method get_stop_price() must be called with MarketOrder instance as first argument (got bool instance instead) There was a runtime error on line 48."

def rebalance(context, data):  
    #check if the ratio of the positions being held are still in the top 5  
    for stock_have in context.portfolio.positions:  
        for stock_ranked in context.assets:  
            #context.assets contains the top 5 stocks ranked by the SMA ratio.  
            if get_sma_ratio(context, data, stock_have) > get_sma_ratio(context, data, stock_ranked):  
                pass  
            else:  
                order_position = context.portfolio.positions[stock_have.sid]  
                order(stock_have, order_position.amount * -1, style=MarketOrder)  
                #^ line 48^  

I never call "get_stop_price()" anywhere in my code. This makes no sense to me. Doe anyone know of a solution?

Thanks.

1 response

You forgot some parenthesis. The code...

                order(stock_have, order_position.amount * -1, style=MarketOrder)  

should be...

                order(stock_have, order_position.amount * -1, style=MarketOrder())