gpt4 book ai didi

python - TA-Lib 如何识别十字星

转载 作者:行者123 更新时间:2023-11-28 17:26:57 24 4
gpt4 key购买 nike

我正在尝试摆弄 TA-Lib 函数,试图了解它们如何识别模式。

下面的代码会产生奇怪的结果

import talib  
import numpy
sample_data = [
['1/22/14', 10, 18, 5, 20],
['1/23/14', 12, 21, 7, 22],
['1/24/14', 14, 24, 9 , 24],
['1/25/14', 16, 27, 11, 26],
['1/26/14', 18, 30, 13, 28],
['1/27/14', 20, 33, 15, 30],
['1/28/14', 22, 36, 17, 32],
['1/29/14', 24, 39, 19, 34],
['1/30/14', 26, 41, 21, 38],
['1/31/14', 30, 45, 25, 40],
['2/01/14', 43, 44, 42, 43.01],
['2/02/14', 46, 47, 45, 46.01],
['2/03/14', 44, 45, 43, 44.01],
['2/04/14', 40, 55, 35, 50],
]

# convert data to columns
sample_data = numpy.column_stack(sample_data)

# extract the columns we need, making sure to make them 64-bit floats
o = sample_data[1].astype(float)
h = sample_data[2].astype(float)
l = sample_data[3].astype(float)
c = sample_data[4].astype(float)

print(talib.CDLDOJI(o,h,l,c))

结果:

print(talib.CDLDOJI(o,h,l,c)) [0 0 0 0 0 0 0 0 0 0 0 0 0 0]

如果我查看 ta_global.c Here

real body is like doji's body when it's shorter than 10% the average of the 10 previous candles' high-low range

{ TA_BodyDoji, TA_RangeType_HighLow, 10, 0.1 },

我图基于这个定义和ta_CDLDOJI.c的定义here该函数应产生三个十字星:

[0 0 0 0 0 0 0 0 0 0 100 100 100 0]

我在这里错过了什么?

最佳答案

我已经更改了基础数据以使其更加明显

sample_data = [ ['1/22/14', 10, 22, 5, 20], ['1/23/14', 12, 23, 7, 22], ['1/24/14', 14, 24, 9 , 24], ['1/25/14', 16, 27, 11, 26], ['1/26/14', 18, 30, 13, 28], [ '1/27/14', 20, 33, 15, 30], ['1/28/14', 22, 36, 17, 32], ['1/29/14', 24, 39, 19, 34], ['1/30/14', 26, 41, 21, 38], ['1/31/14', 30, 45, 25, 40], ['2/01/14', 43, 46, 40, 43.001], ['2/02/14', 46, 54, 38, 46.001], ['2/03/14', 39.99, 40.01, 39.99, 40.01], ['2/04/14 ', 40, 55, 35, 50], ]第 12 根蜡烛显然是十字星,如果您考虑高-低而不是 abs(收-开),第 13 根蜡烛也应归类为十字星。CDLDOJI 函数都将 a 返回为零...

关于python - TA-Lib 如何识别十字星,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38105872/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com