Hello,
When I passed a single field into data.current() function, the data was retrieved well. However if I tried to pass a list of fields into data.current() function, an AttributeError occur. Do you know the reason? Thank you!
Hello,
When I passed a single field into data.current() function, the data was retrieved well. However if I tried to pass a list of fields into data.current() function, an AttributeError occur. Do you know the reason? Thank you!
data.current only has TWO arguments. Those are Asset and Field. So if you want multiple fields, you will have to do:
data.current(asset, 'price')
data.current(asset, 'close')
data.current(asset, 'open')
data.current(asset, 'high')
data.current(asset, 'low')
You can't just do
data.current(asset, 'close', 'open', 'high', 'low', 'price')
because that's sending in 6 parameters when it only accepts 2
Thank you Dustin,
According to the help document, it says:''If a single asset and a list of fields are passed in, a pandas Series is returned whose indices are the fields, and whose values are scalar values for this asset for each field.'' What I input is a list of fields. That means the ['close', 'open', 'high', 'low', 'price'] is the second argument. This looks like
data.current(asset, ['close', 'open', 'high', 'low', 'price'])
Maybe, This function does not allow to return a pandas Series for a continuous_future
Maybe, I am wrong.
Note the addition of volume here:
Not sure about futures, just want to cover the bases for any who might be digging for info in days to come.
This returns a series:
data.current(sid(8554), ['price', 'open', 'high', 'low', 'close', 'volume'])
And input of a list of securities instead of single will return a dataframe:
data.current([sid(8554), sid(39840)], ['close', 'open', 'high', 'low', 'price', 'volume'])
I do not use the word asset, it's only an asset as long as it makes money, otherwise transforms into a liability.