Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pythons talib.ATR方法是否存在错误?_Python_Ta Lib - Fatal编程技术网

Pythons talib.ATR方法是否存在错误?

Pythons talib.ATR方法是否存在错误?,python,ta-lib,Python,Ta Lib,以下是数据: high = np.array([10697.12, 10706.16, 10744.75, 10747.88, 10745.42]) low = np.array([10683.51, 10694.72, 10705.16, 10728.22, 10727.29]) close = np.array([10696.47, 10705.16, 10728.23, 10742.46, 10730.27]) 方法1:直接将数据输入平均真量程法 talib.ATR(high, low,

以下是数据:

high = np.array([10697.12, 10706.16, 10744.75, 10747.88, 10745.42])
low = np.array([10683.51, 10694.72, 10705.16, 10728.22, 10727.29])
close = np.array([10696.47, 10705.16, 10728.23, 10742.46, 10730.27])
方法1:直接将数据输入平均真量程法

talib.ATR(high, low, close, timeperiod=3)
output: array([nan, nan, nan, 23.56333333, 21.75222222])
方法2:首先计算真实范围,然后取平均值

talib.TRANGE(high, low, close)
output: array([nan, 11.44, 39.59, 19.66, 18.13])
taking 3 day average:
(11.44+39.59+19.66)/3=23.56
(39.59+19.66+18.13)/3=25.79

So the Average True Range array should be: array([nan, nan, nan, 23.56, 25.79])

第一种方法的平均真范围数组中的最后一个值与第二种方法不同。(21.75比25.79)


这里怎么了?

talib.ATR()
的计算是正确的

从:

使用以下公式计算时间t时刻的ATR:(这是指数移动平均数的一种形式)

使用您的价值观:

>>(23.56333*2+18.13)/3
21.752222219999997

计算
talib.ATR()
是正确的

从:

使用以下公式计算时间t时刻的ATR:(这是指数移动平均数的一种形式)

使用您的价值观:

>>(23.56333*2+18.13)/3
21.752222219999997