Compatibility with ta-lib

Using ta-lib as a comparison as to whether an indicator is correctly implemented seems like a logical choice. But this is not so always (see the section: I3 Indicators)

Some implementations deviate from ta-lib. Indicators that do deviate from ta-lib indicate that in the documentation

Deviating from ta-lib

  • Default Parameters

    Some of the ta-lib parameters are deemed to be out of sync with what the de-facto value in the industry is.

    One example would be the stochastic indicator. The most chose period combination is (14, 3, 3) whereas ta-lib applies (5, 3, 3).

    The good thing about parameters is that any value can be chosen.

  • Implementation

    Where ta-lib has made something that can be considered a mistake or an odd choice, bta-lib offers what it is considered right or changes the choice to be non-odd.

    These indicators offer the possibility to deliver the same values as ta-lib

    See (again) the section: I3 Indicators

Per-Indicator Compatibility

When instantiating each indicator, the ta-lib behavior can be requested with by passing the named argument _talib=True.

In the case of the aforementioned stochastic:

import btalib

# load the data into dataframe with the name `df`

talib_compatible_stochastic = btalib.stochastic(df, _talib=True)

The library recognizes the name _talib=True argument and instructs the stochastic indicator to reconfigure itself for this instantiation and use the periods (5, 3, 3) rather than the default ones in bta-lib, which are (14, 3, 3)

Global Compatibility

Reconfiguring the indicators deviating from the ta-lib behavior in just one go is possible with a single call using the configuration module and the call btalib.config.set_talib_compat(). See the section btalib - configuration.

An example to activate it

import btalib
btalib.config.set_talib_compat()  # the default is `True`

# Indicators which previously deviated, are now `ta-lib` compliant

It can also be deactivated

btalib.config.set_talib_compat(False)  # the default is `True`

The current status can also be queried

ta_lib_compat_status = btalib.config.get_talib_compat()