Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Using CustomFactor as Stop Loss

Hi all.
I'm new to Q, and hope not too naive.

I have a custom factor within my pipeline that returns a certain price for each security. I would like to use this price as a stop loss price.
In the research environment, this price is called CustomFactor_StopPrice and it displays the price for each security in the pipeline. So my initial thought was simply:

    for security in context.longs:  
        if data.can_trade(security):  
            order_value(security, 1000)  
            order_target_percent(security, 0,style=StopOrder(CustomFactor_StopPrice))  

This results in the runtime error:Attempted to place an order with a stop price of class 'CustomFactor'.

Would be grateful for any ideas on how best to implement this, thank you