Output types#
Like indicators that process either simple or complex input values, the output values of indicators can also range from simple floats to complex objects.
Complex output types are required if indicator needs to return multiple values per a single data point. For instance, while SMA will always return a single output value for each input value, Bollinger Bands has to return three values per each input value (lower, central and upper band), hence requiring a complex return type.
Complex output type is always defined as a dataclass
and is documented in each indicator module.
For instance, output type of Bollinger Bands is BBVal and looks as follows:
That's why when printing Bollinger Bands, the output will be
Other examples of complex output types are:
- MACD -> MACDVal
- Parabolic SAR -> ParabolicSARVal
- Stoch -> StochVal
- ...
When complex outputs serve as an input for other components in a data pipeline sometimes it may be more convenient to decompose them into lists per each attribute of the complex type. In other words, instead of working with
it may be more useful to have
To transform the former output into the latter, talipp provides composite_to_lists utility function which can be applied to every indicator returning complex types.