我在 spring-boot 应用程序中使用带有 Java 的 ta-lib 计算 RSI。在花了一些时间弄清楚函数调用参数之后,我设法从计算中得到了一个输出。但是,rsi 函数在输出数组中不断返回零值。为什么它返回零?
我正在从 Binance 的 API 中获取烛台数据,试图计算给定时期的 RSI。我已经尝试了 stochasticRSI 和 RSI,但两者都在输出数组中返回零。
public double[] calculateRsi() {
int OPT_IN_TIME_PERIOD = 14;
double closePrices[] = {3553.06005859375,3572.5,3555.070068359375,3589.02001953125,3590.219970703125,3576.39990234375,3591.840087890625,3574.590087890625,3584.0,3579.56005859375,3597.6201171875,3604.949951171875,3616.2099609375,3600.8701171875,3604.010009765625,3599.010009765625,3610.679931640625,3587.909912109375,3594.8701171875,3606.1298828125,3604.39990234375,3695.3798828125,3685.739990234375,3686.530029296875,3665.300048828125,3680.719970703125,3678.8701171875,3580.0,3524.6298828125,3518.0,3539.280029296875,3530.949951171875,3526.830078125,3545.050048828125,3528.169921875,3528.820068359375,3526.89990234375,3523.0,3515.699951171875,3535.14990234375,3577.320068359375,3578.4599609375,3570.929931640625,3581.31005859375,3561.72998046875,3577.800048828125,3549.070068359375,3533.39990234375,3552.820068359375,3532.570068359375,3546.330078125,3563.22998046875,3553.409912109375,3574.929931640625,3569.6201171875,3568.06005859375,3568.47998046875,3541.969970703125,3566.919921875,3553.2099609375};
MInteger outBegIdx = new MInteger();
MInteger outNbElement = new MInteger();
double[] outReal = new double[closePrices.length];
int startIdx = 0;
int endIdx = closePrices.length - 1;
talibCore.rsi(startIdx, endIdx, closePrices, OPT_IN_TIME_PERIOD, outBegIdx, outNbElement, outReal);
return outReal;
}
我希望计算的输出是一个包含首选 RSI 值的数组,但实际输出是以下数组:
[
55.50236554101884,
48.4420340522227,
48.936642078369324,
39.61167139428769,
39.308159841569264,
42.58440044993444,
43.68867735156312,
50.14296711032441,
50.83654805452586,
50.79841825933019,
50.311807765799145,
45.53568823545641,
43.2867452256146,
43.38390663365912,
41.2894895311203,
41.133921783119135,
41.957983467430424,
34.6763182163226,
29.239623192248875,
43.73473552102837,
39.70980937294976,
38.722071869417974,
33.91981286332463,
40.415256033334316,
39.967050108741674,
30.237053069193013,
47.24515019760144,
48.09365697810791,
47.397062335425126,
47.919330703443016,
48.50051589076493,
45.588023453959245,
41.35162036615853,
39.976389434938056,
41.79568536987075,
36.94666938984934,
40.95986916491035,
38.21570616480444,
38.538139356924304,
39.93113081247877,
39.69620754900941,
38.9256798286741,
34.87273047865816,
43.210471567071465,
37.873988767931046,
35.92186113528669,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]