hikyuu2/docs/source/indicator/talib.rst
2019-02-17 16:10:03 +08:00

30 lines
749 B
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

.. py:currentmodule:: hikyuu.indicator
.. highlightlang:: python
TA-Lib 包装
============
由于内建指标还不完整在交互工具里对TA-Lib进行了包装命名方式统一为 TA_FUNC名称。其中ta-lib指标的lookback属性用discard属性代替。
::
x = TA_SMA(CLOSE(k))
print(x)
x.plot()
print(x.discard)
个别的Ta-Lib函数需要两个数组参数比如BETA、CORREL。此时需要利用特殊的 Indicator WEAVE 将两个数组包装到一个 ind 对象中。
::
query = Query(-200)
k1 = sm['sh000001'].getKData(query)
k2 = sm['sz000001'].getKData(query)
w = WEAVE(CLOSE(k1))
w = w(CLOSE(k2))
print(w.getResultNumber())
cr = TA_CORREL(w)
cr.plot()