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?
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?
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.
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.