TA-Lib Functions

TA-Lib is used to add technical analysis to financial market trading applications. DolphinDB provides TA-Lib functions for analysis in quantitative finance.

Introduction

  • Higher-order function talib:

    talib(func, args...)

    To process data starting with consecutive NULL values in the same way as Python TA-Lib, you can call DolphinDB built-in functions with the higher-order function talib.

  • Syntax template for the TA-Lib functions:

    TA-libFunc(X, window)

    Parameters:

    X is a vector/matrix/table.

    window is a positive integer indicating the size of the sliding window.

List of Functions

  • TA-Lib functions provide a common template ma. You can specify the type of moving average with this function to implement the features of the following functions: sma, ema, wma, dema, tema, trima, kama, t3.
  • Exponential moving average: wilder, gema
  • Linear regression in sliding window: linearTimeTrend

Windowing Logic

The window size for TA-lib functions is measured by the number of elements.

Different from other DolphinDB window functions, TA-lib functions keep the NULL values at the beginning of data in the output. The calculation in the sliding window starts from the first non-NULL value.

Based on the calculation rules of the moving window functions, the calculation will be performed only when the elements fill the window, i.e., the result of the first window - 1 element is NULL by default.

The following example calls msum with talib and the figure shows how the windows slide:

X = NULL NULL NULL 1 2 3 4 5 6 NULL 8 9
w = 3 // window

print msum(X, w)
// output
[ , , , 1, 3, 6, 9, 12, 15, 11, 14, 17]

talib(msum, X, w)
// output
[ , , , , , 6, 9, 12, 15, 11, 14, 17]

The results of gray windows are NULL.