java中用于识别模式的浮点比较
我正在编写一个识别股票市场数据模式的程序,并试图识别以下短期模式: 如果下限值小于开启值至少3,且关闭值在开启值的2范围内 我正在以以下格式读取CSV文件中的值,但没有标题:java中用于识别模式的浮点比较,java,csv,floating-point,Java,Csv,Floating Point,我正在编写一个识别股票市场数据模式的程序,并试图识别以下短期模式: 如果下限值小于开启值至少3,且关闭值在开启值的2范围内 我正在以以下格式读取CSV文件中的值,但没有标题: Open High Low Close 353.4 359.2 347.7 349 351.4 354.08 349.1 353.1 350.1 354 349.3 350.2 352.4 353.28 348.7 349.8 345.7 352.3
Open High Low Close
353.4 359.2 347.7 349
351.4 354.08 349.1 353.1
350.1 354 349.3 350.2
352.4 353.28 348.7 349.8
345.7 352.3 345.7 351.5
这些值存储在名为closePrice、openPrice和lowPrice的浮点数组列表中。我在计算价格
这是我为尝试识别数据中的模式而编写的代码
for(int i = 0; i < closePrice.size(); i ++)
{
//Difference between opening price and the price low
float priceDrop = Math.abs(openPrice.get(i) - lowPrice.get(i));
//Difference between opening price and close price (regardless of positive or negative)
float closingDiff = Math.abs(openPrice.get(i) - closePrice.get(i));
float dropTolerance = 3.0f;
float closingTolerance = 2.0f;
if( (priceDrop > dropTolerance) || (closingDiff < closingTolerance) )
{
System.out.println("price drop = " + priceDrop + " closing diff = " + closingDiff);
System.out.println("Hangman pattern" + "\n");
}
}
是因为我在比较浮动吗?任何帮助都将不胜感激。看起来您混淆了AND运算符和OR运算符
您声明仅在两个条件都满足时才希望输出,但您的代码表明,如果满足任一条件,您将输出。看起来您混淆了AND运算符和OR运算符
您声明只在两个条件都满足时才想输出,但您的代码说,如果两个条件都满足,您将输出。argh犯了这样一个愚蠢的错误!我花了很长时间才写出这个问题:谢谢你啊,犯了这么愚蠢的错误!我花了很长时间才写出这个问题:谢谢
price drop = 5.6999817 closing diff = 4.399994
Hangman pattern
price drop = 2.2999878 closing diff = 1.7000122
Hangman pattern
price drop = 0.8000183 closing diff = 0.1000061
Hangman pattern