Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Order of data from history() and items in the data object?

Hello,
when I call history(...) I receive an array of all my securities.
So what is the order? Is it the same as that one I receive when calling
for stock in data:
print stock

in the handle_data function?

Thanks very much for an hints!

1 response

Eugen,
The columns of the history dataframe are keyed by the security id's (sid) and sorted in ascending sid order, but it looks like they are not necessarily in the same order as when looping through data. Best practice is to select columns using the securities so there is no ambiguity. I attached a simple experiment you can play with. The data sids appear to have the same ordering as context.stocks. I hope this helps, if not, let me know your specific use case and I'll do my best to help you out.

David