K线机器人-优化盘口数量出现0的BUG

pull/1/head
luzhaofeng 5 years ago
parent 41fd8064b8
commit aadd82388a
  1. 23
      blockchain-server/blockchain-server-databot/src/main/java/com/blockchain/server/databot/schedule/KMarketScheduling.java

@ -270,7 +270,7 @@ public class KMarketScheduling {
continue; continue;
} else { } else {
//新创盘口数量 //新创盘口数量
float newAmount = avgAmount * random.nextInt(100) / 50; float newAmount = avgAmount * (random.nextInt(100) + 1) / 50;
//减去发行总数量 //减去发行总数量
totalAmount -= newAmount; totalAmount -= newAmount;
@ -333,7 +333,7 @@ public class KMarketScheduling {
//格式化数据 //格式化数据
float unitPrice = formatValue(depthPrice); float unitPrice = formatValue(depthPrice);
//新创盘口数量 //新创盘口数量
float newAmount = avgAmount * random.nextInt(100) / 50; float newAmount = avgAmount * (random.nextInt(100) + 1) / 50;
//减去发行总数量 //减去发行总数量
totalAmount -= newAmount; totalAmount -= newAmount;
//判断是否存在相同单价 //判断是否存在相同单价
@ -558,15 +558,16 @@ public class KMarketScheduling {
* @return * @return
*/ */
private static float formatValue(float value) { private static float formatValue(float value) {
if (value < 0.001) { // if (value < 0.001) {
return BigDecimal.valueOf(value).setScale(8, BigDecimal.ROUND_HALF_DOWN).floatValue(); // return BigDecimal.valueOf(value).setScale(8, BigDecimal.ROUND_HALF_DOWN).floatValue();
} else if (value < 0.1) { // } else if (value < 0.1) {
return BigDecimal.valueOf(value).setScale(6, BigDecimal.ROUND_HALF_DOWN).floatValue(); // return BigDecimal.valueOf(value).setScale(6, BigDecimal.ROUND_HALF_DOWN).floatValue();
} else if (value < 10) { // } else if (value < 10) {
return BigDecimal.valueOf(value).setScale(4, BigDecimal.ROUND_HALF_DOWN).floatValue(); // return BigDecimal.valueOf(value).setScale(4, BigDecimal.ROUND_HALF_DOWN).floatValue();
} else { // } else {
return BigDecimal.valueOf(value).setScale(2, BigDecimal.ROUND_HALF_DOWN).floatValue(); // return BigDecimal.valueOf(value).setScale(2, BigDecimal.ROUND_HALF_DOWN).floatValue();
} // }
return BigDecimal.valueOf(value).setScale(8, BigDecimal.ROUND_HALF_DOWN).floatValue();
} }
/*** /***

Loading…
Cancel
Save