TA-Lib Functions
DolphinDB provides TA-Lib functions for quantitative analysis in 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
.
A general template for the TA-Lib functions:
$ TA-libFunc(X, window)
X is a vector/matrix/table.
window is a positive integer indicating the size of the sliding window.
List of Functions
See also
TA-Lib functions provide a common format ma . You can specify the type of moving average with this function to implement the features of the following functions:
Exponential moving average:
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)
[ , , , 1, 3, 6, 9, 12, 15, 11, 14, 17]
$ talib(msum, X, w)
[ , , , , , 6, 9, 12, 15, 11, 14, 17]
The results of gray windows are NULL.