Back to Community
continuous_future with data.current

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!

Clone Algorithm
Backtest from to with initial capital
Total Returns
Max Drawdown
Benchmark Returns
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5973aa58b3cfd44e0dd93c83
There was a runtime error.
3 responses

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.