Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Is there something wrong with Quantopian's order_target_value

As show below I am getting leverage as much as 70x while using order_target_value.

1 response

If your order takes more than a minute to fill, it will re-order when you execute the order_target_value() function again each minute. Same problem exists with order_target_percent. What I think people typically do is at the top of handle_data() they put something like "if open_orders(): return" to avoid sending in more orders while the previous one is still being processed. Can't remember off the top of my head for certain the actual line of code, but you could do something like this:

handle_data(context,data):  
    ivv = sid(21513)  
    spy = sid(8554)  
    if len(get_open_orders(ivv)) != 0 or len(get_open_orders(spy)) != 0  :  
        return