pipefolio.data#
Classes#
A placeholder for financial data with OHLCV structure. |
Module Contents#
- class pipefolio.data.DataPlaceHolder#
A placeholder for financial data with OHLCV structure.
- data#
A pandas DataFrame containing financial data.
- symbols#
A list of asset symbols.
- ohlcv#
An OHLCV namedtuple mapping data columns.
- period#
The data period (e.g., daily, weekly).
- start#
The start timestamp of the data.
- end#
The end timestamp of the data.
- price_col#
The column to use as price data.
- data: pandas.DataFrame#
- symbols: list[str]#
- period: pipefolio.enums.DataPeriod#
- start: pandas.Timestamp#
- end: pandas.Timestamp#
- price_col: pipefolio.enums.DataColumn = None#
- classmethod from_dataframe(data, ohlcv=OHLCV('Open', 'High', 'Low', 'Close', 'Volume'), period=DataPeriod.DAILY, price_col=DataColumn.CLOSE)#
Create a DataPlaceHolder from a DataFrame.
- Parameters:
data (pandas.DataFrame) – A pandas DataFrame with a MultiIndex for columns.
ohlcv (OHLCV) – An OHLCV namedtuple to map data columns.
period (pipefolio.enums.DataPeriod) – The data period.
price_col (pipefolio.enums.DataColumn) – The column to use as price data.
- Returns:
A DataPlaceHolder instance.
- Return type:
Self
- property open: pandas.DataFrame#
Get the open prices.
- Return type:
pandas.DataFrame
- property high: pandas.DataFrame#
Get the high prices.
- Return type:
pandas.DataFrame
- property low: pandas.DataFrame#
Get the low prices.
- Return type:
pandas.DataFrame
- property close: pandas.DataFrame#
Get the close prices.
- Return type:
pandas.DataFrame
- property volume: pandas.DataFrame#
Get the volume data.
- Return type:
pandas.DataFrame
- property price: pandas.DataFrame#
Get the selected price column based on price_col.
- Returns:
The DataFrame for the selected price column.
- Return type:
pandas.DataFrame
- select_symbols(symbols)#
Select data for specific symbols.
- Parameters:
symbols (collections.abc.Iterable[str]) – An iterable of asset symbols.
- Returns:
A DataFrame with data for the specified symbols.
- Return type:
pandas.DataFrame
- copy_with_new_data(data)#
Create a copy of the instance with new data.
- Parameters:
data (pandas.DataFrame) – A pandas DataFrame with new data.
- Returns:
A new DataPlaceHolder instance with the updated data.
- Return type: