我正在使用talib技术分析库来计算 MACD。
我使用AAPL数据计算 MACD(8, 17, 9),但 talib 值与 Google 和 Yahoo Finance 完全不同。
这是我的 javascript(我复制了自 2015-08-21 以来的最后一个 AAPL 关闭数据):
var talib = require('./node_modules/talib/build/Release/talib');
var marketData = { open: [], close: [106.2199999999999989,
112.6500000000000057,
115.0100000000000051,
116.5000000000000000,
117.1599999999999966,
116,
115.1500000000000057,
115.2399999999999949,
113.5498999999999938,
119.6901000000000010,
115.5199999999999960,
115.1700000000000017,
115.4000000000000057,
114.6400000000000006,
118.4350000000000023,
121.4599999999999937,
122.3700000000000045,
122.9899999999999949,
123.3199999999999932,
122.8900000000000006,
124.4800000000000040,
125.1599999999999966,
125.2199999999999989,
130.7500000000000000,
132.0699999999999932],high: [], low: [], volume: [] };
talib.execute({
name: "MACD",
startIdx: 0,
endIdx: marketData.close.length - 1,
inReal: marketData.close,
optInFastPeriod: 8,
optInSlowPeriod: 17,
optInSignalPeriod: 9
}, function (result) {
console.log(result);
});
雅虎和谷歌金融2005-08-21的MACD值为-2.73,talib值为3.83,与更多数据MACD相差很大。我做错了什么?
我还注意到 talib SMA 和 EMA 给出了相同的结果。
顺便说一句,在谷歌图表中反转 MACD 慢速和快速周期不会改变图表......雅虎会。