Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
OrderNonSecurity?

Hey, Quantopian,

I've just been playing around, iterating over all the securities in my universe every day to find the one that maximizes some function or other. However, sometimes when I do this and place an order, I get an OrderNonSecurity error. What does this mean, and how can I check for it before placing the order, or how can I handle it?

If I had to guess, I would guess this is because the security stopped existing during that day. But how do I detect that?

2 responses

Hello Matthew,

I wonder if you are trying to place an order against a security that does not have a trade during the tic? I could be mistaken, but I think that in order to place an order, there needs to have been a historical trade in the database for a given minute/day. Can you add something like:

if price_of_offending_security == NaN:  
    print 'Arghh!'  

Also, would you be willing to post the code (perhaps with anything you want to keep private removed)?

Grant

You can receive an error even trying to get the price of a security if it has been dropped from the universe.

It's a good idea to check for the presence of the security first:

if sid in data:  
    price = data[sid].price