Principle:TA Lib Ta lib python Abstract Data Input
| Knowledge Sources | |
|---|---|
| Domains | Data_Preparation, Technical_Analysis |
| Last Updated | 2026-02-09 22:00 GMT |
Overview
A data input pattern for the Abstract API where OHLCV price data is provided as a dictionary of arrays, a pandas DataFrame, or a polars DataFrame with named price series keys.
Description
The Abstract API accepts input data in a structured format with named price series. Unlike the Function API which takes individual arrays, the Abstract API expects a single data structure with keys matching the required price series names: open, high, low, close, and volume.
Supported input types:
- dict of numpy arrays:
{'open': np.array(...), 'close': np.array(...)} - pandas.DataFrame: Columns accessed by name
- polars.DataFrame: Columns accessed by name
The default price series mapping is defined in __INPUT_PRICE_SERIES_DEFAULTS which maps abstract input names to concrete price series keys.
Usage
Use this pattern when working with the Abstract API (talib.abstract.Function). Prepare your data as a dict with the standard OHLCV keys, or pass a DataFrame directly.
Theoretical Basis
The Abstract API uses named input mapping:
# Abstract input mapping concept
__INPUT_PRICE_SERIES_DEFAULTS = {
'price': 'close',
'price0': 'high',
'price1': 'low',
'prices': ['open', 'high', 'low', 'close'],
'periods': ['periods'],
}
# Each indicator declares which input names it uses
# e.g., SMA uses 'price' -> resolves to 'close'
# e.g., ATR uses 'prices' -> resolves to ['open', 'high', 'low', 'close']
The input validation checks that all required keys exist in the provided dict/DataFrame before computation.