| | |
| | | import com.yami.trading.common.util.Arith; |
| | | import com.yami.trading.huobi.data.AdjustmentValueCache; |
| | | import com.yami.trading.huobi.data.DataCache; |
| | | import com.yami.trading.huobi.data.RandomNumbersGenerator; |
| | | import com.yami.trading.huobi.data.internal.DataDBService; |
| | | import com.yami.trading.huobi.data.model.AdjustmentValue; |
| | | import com.yami.trading.huobi.hobi.HobiDataService; |
| | |
| | | |
| | | // 首次执行:生成含正负值的调整序列 |
| | | if (adjustments == null || currentIndex == null) { |
| | | adjustments = generateRandomAdjustments(delayValue.getValue(), frequency, decimal); |
| | | //分几段执行 |
| | | int nums = Math.max(10, frequency / 10); |
| | | List<BigDecimal> result = RandomNumbersGenerator.generateNumbers(delayValue.getValue(), nums, decimal + 4); |
| | | for (int i = 0; i < result.size(); i++) { |
| | | if (adjustments == null) { |
| | | adjustments = new ArrayList<>(); |
| | | } |
| | | adjustments.addAll(generateRandomAdjustments(result.get(i), frequency / 10, decimal)); |
| | | } |
| | | currentIndex = 0; |
| | | AdjustmentValueCache.getPreAllocatedAdjustments().put(symbol, adjustments); |
| | | AdjustmentValueCache.getCurrentAdjustmentIndex().put(symbol, currentIndex); |
| | |
| | | realtime.setTs(Long.valueOf(realtime.getTs() + "000")); |
| | | } |
| | | realtime.setName(item.getName()); |
| | | if (high == null || realtime.getHigh().doubleValue() > high) { |
| | | /*if (high == null || realtime.getHigh().doubleValue() > high) { |
| | | DataCache.getRealtimeHigh().put(symbol, realtime.getHigh().doubleValue()); |
| | | } |
| | | if ((low == null || realtime.getLow().doubleValue() < low) && realtime.getLow().doubleValue() > 0) { |
| | | DataCache.getRealtimeLow().put(symbol, realtime.getLow().doubleValue()); |
| | | }*/ |
| | | if (high != null) { |
| | | realtime.setHigh(BigDecimal.valueOf(high)); |
| | | } |
| | | if (low != null) { |
| | | realtime.setLow(BigDecimal.valueOf(low)); |
| | | } |
| | | this.dataDBService.saveAsyn(realtime); |
| | | } |
| | |
| | | |
| | | public static void main(String[] args) { |
| | | AbstractGetDataJob abstractGetDataJob = new CryptosGetDataJob(); |
| | | List<BigDecimal> list = abstractGetDataJob.generateRandomAdjustments(new BigDecimal(0.002), 300, 8); |
| | | List<BigDecimal> list = new ArrayList<>(); |
| | | int frequency = 166; |
| | | int decimal = 4; |
| | | //分几段执行 |
| | | int nums = Math.max(10, frequency / 10); |
| | | List<BigDecimal> result = RandomNumbersGenerator.generateNumbers(BigDecimal.valueOf(0.0026), nums, decimal + 4); |
| | | System.out.println(result); |
| | | for (int i = 0; i < result.size(); i++) { |
| | | List<BigDecimal> numbers = abstractGetDataJob.generateRandomAdjustments(result.get(i), frequency / 10, decimal); |
| | | list.addAll(numbers); |
| | | } |
| | | |
| | | BigDecimal sum = BigDecimal.ZERO; |
| | | int num = 0; |
| | | int dmt = 1; |