Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Why I can't use the order(sid(mysid), 20)?

The following code is OK:
... order(sid(24), 20)
...

But following I get error:
... mysid = 24
order(sid(mysid), 20)
...

Error: The sid(id) method takes one parameter.

Why?

3 responses

I think the problem is that by design, you need a literal as id. The design of the API includes scanning over the code, looking for sid(id) and then loading those securities into the data object. If you make id a variable in the code, then the automatic searching and loading of securities doesn't work. At least that's my take on it. Kinda weird, but it shouldn't hamper your coding.

It seems that Q could fix this problem, by making it so that if you write sid(id) with id a variable, the API would look in the data object, instead of throwing an exception.

Hi,

Thanks for the reply.

But what do you mean "Q could fix this problem"? What/who is Q?

Cheers

Hello Thomas,

Q as in Q uantopian.

Regarding fixing the problem, I mean that I think that when they scan the code for sids, ones without literals could be ignored. Then, when sid(x) is called in the code, it would accept the variable x instead of throwing an exception. I don't know how feasible this is, and once you know how things work, it is not an impediment. It's not a high priority, in my mind.