Principle:TA Lib Ta lib python Abstract Function Execution
| Knowledge Sources | |
|---|---|
| Domains | Technical_Analysis, Software_Architecture |
| Last Updated | 2026-02-09 22:00 GMT |
Overview
An execution pattern for computing indicator values through a Function object interface, supporting both explicit method calls and implicit callable invocation.
Description
The Abstract API provides three ways to execute a configured Function and retrieve results:
- outputs property: Returns cached results (recomputes if inputs/parameters changed)
- run(input_arrays): Sets input arrays and returns outputs in one call
- __call__(*args, **kwargs): Allows calling the Function object like a function with the same signature as the Function API
The execution caches results and only recomputes when inputs or parameters change (tracked via the outputs_valid flag). Output format adapts to input type — pandas DataFrame input yields pandas Series/DataFrame output.
Usage
Use this principle when you need to execute indicators through the Abstract API. Choose between the three execution methods based on your workflow:
- outputs — when data and params are already set
- run() — when you want to set data and execute in one step
- __call__() — when you want the same syntax as the Function API
Theoretical Basis
The execution pattern implements lazy evaluation with caching:
# Abstract execution pattern
if not outputs_valid:
results = call_c_function(input_arrays, parameters)
cache_results(results)
outputs_valid = True
return cached_results
Output conversion preserves input types:
- dict input → numpy array/list output
- pandas.DataFrame input → pandas.Series/DataFrame output
- polars.DataFrame input → polars.Series/DataFrame output