| | |
| | | } |
| | | |
| | | // 缓存中最新一条Realtime数据 |
| | | Realtime realtimeLast = DataCache.getRealtime(symbol); |
| | | if (null != realtimeLast) { |
| | | // 临时处理:正常10秒超过25%也不合理,丢弃 |
| | | double rate = Math.abs(Arith.sub(realtime.getClose(), realtimeLast.getClose())); |
| | | if (null == realtimeLast || Arith.div(rate, realtimeLast.getClose()) < 0.25D) { |
| | | Double high = DataCache.getRealtimeHigh().get(symbol); |
| | | Double low = DataCache.getRealtimeLow().get(symbol); |
| | | |
| | | if (high == null || realtime.getClose() > high) { |
| | | DataCache.getRealtimeHigh().put(symbol, realtime.getClose()); |
| | | } |
| | | if ((low == null || realtime.getClose() < low) && realtime.getClose() > 0) { |
| | | DataCache.getRealtimeLow().put(symbol, realtime.getClose()); |
| | | } |
| | | |
| | | this.dataDBService.saveAsyn(realtime); |
| | | } else { |
| | | Double high = DataCache.getRealtimeHigh().get(symbol); |
| | | Double low = DataCache.getRealtimeLow().get(symbol); |
| | | |
| | | if (high == null || realtime.getClose() > high) { |
| | | DataCache.getRealtimeHigh().put(symbol, realtime.getClose()); |
| | | } |
| | | if ((low == null || realtime.getClose() < low) && realtime.getClose() > 0) { |
| | | DataCache.getRealtimeLow().put(symbol, realtime.getClose()); |
| | | } |
| | | |
| | | this.dataDBService.saveAsyn(realtime); |
| | | logger.error("当前价格{},超过25%也不合理,丢弃Realtime,不入库", realtime.getClose()); |
| | | } |
| | | } else { |
| | | Double high = DataCache.getRealtimeHigh().get(symbol); |
| | | Double low = DataCache.getRealtimeLow().get(symbol); |
| | | if (high == null || realtime.getClose() > high) { |
| | | DataCache.getRealtimeHigh().put(symbol, realtime.getClose()); |
| | | } |
| | | if ((low == null || realtime.getClose() < low) && realtime.getClose() > 0) { |
| | | DataCache.getRealtimeLow().put(symbol, realtime.getClose()); |
| | | } |
| | | this.dataDBService.saveAsyn(realtime); |
| | | } |
| | | DataCache.getRealtimeHigh().put(symbol, realtime.getHigh()); |
| | | DataCache.getRealtimeLow().put(symbol, realtime.getLow()); |
| | | this.dataDBService.saveAsyn(realtime); |
| | | // Realtime realtimeLast = DataCache.getRealtime(symbol); |
| | | // if (null != realtimeLast) { |
| | | // // 临时处理:正常10秒超过25%也不合理,丢弃 |
| | | // double rate = Math.abs(Arith.sub(realtime.getClose(), realtimeLast.getClose())); |
| | | // if (null == realtimeLast || Arith.div(rate, realtimeLast.getClose()) < 0.25D) { |
| | | // Double high = DataCache.getRealtimeHigh().get(symbol); |
| | | // Double low = DataCache.getRealtimeLow().get(symbol); |
| | | // |
| | | // if (high == null || realtime.getClose() > high) { |
| | | // DataCache.getRealtimeHigh().put(symbol, realtime.getClose()); |
| | | // } |
| | | // if ((low == null || realtime.getClose() < low) && realtime.getClose() > 0) { |
| | | // DataCache.getRealtimeLow().put(symbol, realtime.getClose()); |
| | | // } |
| | | // |
| | | // this.dataDBService.saveAsyn(realtime); |
| | | // } else { |
| | | // Double high = DataCache.getRealtimeHigh().get(symbol); |
| | | // Double low = DataCache.getRealtimeLow().get(symbol); |
| | | // |
| | | // if (high == null || realtime.getClose() > high) { |
| | | // DataCache.getRealtimeHigh().put(symbol, realtime.getClose()); |
| | | // } |
| | | // if ((low == null || realtime.getClose() < low) && realtime.getClose() > 0) { |
| | | // DataCache.getRealtimeLow().put(symbol, realtime.getClose()); |
| | | // } |
| | | // |
| | | // this.dataDBService.saveAsyn(realtime); |
| | | // logger.error("当前价格{},超过25%也不合理,丢弃Realtime,不入库", realtime.getClose()); |
| | | // } |
| | | // } else { |
| | | // Double high = DataCache.getRealtimeHigh().get(symbol); |
| | | // Double low = DataCache.getRealtimeLow().get(symbol); |
| | | // if (high == null || realtime.getClose() > high) { |
| | | // DataCache.getRealtimeHigh().put(symbol, realtime.getClose()); |
| | | // } |
| | | // if ((low == null || realtime.getClose() < low) && realtime.getClose() > 0) { |
| | | // DataCache.getRealtimeLow().put(symbol, realtime.getClose()); |
| | | // } |
| | | // this.dataDBService.saveAsyn(realtime); |
| | | // } |
| | | |
| | | |
| | | } catch (Exception e) { |