Skip to content

What is the structure of self.data ? #526

Answered by kernc
wolfcuring asked this question in Q&A
Discussion options

You must be logged in to vote

The docs explicitly say Strategy.data is not a dataframe, so you can't just use it as if.
If you need data to become a DataFrame, you can use its .df accessor (self.data.df), or .s accessor for individual series (self.data.Close.s).

Finally, when in doubt, just look in the source:

class _Data:
"""
A data array accessor. Provides access to OHLCV "columns"
as a standard `pd.DataFrame` would, except it's not a DataFrame
and the returned "series" are _not_ `pd.Series` but `np.ndarray`
for performance reasons.
"""
def __init__(self, df: pd.DataFrame):
self.__df = df
self.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wolfcuring
Comment options

Answer selected by wolfcuring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants