| | |
| | | return null; |
| | | } |
| | | String markPx = ObjectUtil.isEmpty(redisUtils.getString(CoinEnums.HE_YUE.getCode())) ? "0" : redisUtils.getString(CoinEnums.HE_YUE.getCode()); |
| | | |
| | | log.info("当前价格: {}", markPx); |
| | | WangGeListEnum gridByPrice = WangGeListEnum.getGridByPrice(new BigDecimal(markPx)); |
| | | if (gridByPrice == null){ |
| | |
| | | return null; |
| | | } |
| | | log.info("当前网格: {}", gridByPrice.name()); |
| | | Map<String, String> accountMap = InstrumentsWs.getAccountMap(accountName); |
| | | String wanggeName = accountMap.get(CoinEnums.WANG_GE_OLD.name()); |
| | | |
| | | PriorityBlockingQueue<AscBigDecimal> ascBigDecimals = wangGeListService.initWangGe(markPx); |
| | | if (ascBigDecimals == null){ |
| | | log.error("没有获取到网格队列......"); |
| | | return null; |
| | | } |
| | | /** |
| | | * 如果下单的网格不属于同一个网格,则先止损掉老的网格的仓位 |
| | | */ |
| | | Map<String, String> accountMap = InstrumentsWs.getAccountMap(accountName); |
| | | String wanggeName = accountMap.get(CoinEnums.WANG_GE_OLD.name()); |
| | | if (StrUtil.isNotEmpty(wanggeName) && !wanggeName.equals(gridByPrice.name())){ |
| | | log.error("正在止损老的网格仓位......"); |
| | | WangGeListEnum oldWangge = WangGeListEnum.getByName(wanggeName); |
| | |
| | | return OrderParamEnums.HOLDING.getValue(); |
| | | } |
| | | } |
| | | |
| | | if (PositionsWs.getAccountMap(positionAccountName).get("pos") == null){ |
| | | log.error("没有获取到持仓信息,等待初始化......"); |
| | | return null; |
| | | } |
| | | BigDecimal pos = PositionsWs.getAccountMap(positionAccountName).get("pos"); |
| | | if (BigDecimal.ZERO.compareTo( pos) >= 0) { |
| | | log.error("持仓数量为零,进行初始化订单"); |
| | | return OrderParamEnums.INIT.getValue(); |
| | | } |
| | | // 判断是否保证金超标 |
| | | if (PositionsWs.getAccountMap(positionAccountName).get("imr") == null){ |
| | | log.error("没有获取到持仓信息,等待初始化......"); |
| | |
| | | return OrderParamEnums.HOLDING.getValue(); |
| | | } |
| | | |
| | | PriorityBlockingQueue<AscBigDecimal> ascBigDecimals = wangGeListService.initWangGe(markPx); |
| | | if (ascBigDecimals == null){ |
| | | log.error("没有获取到网格队列......"); |
| | | if (PositionsWs.getAccountMap(positionAccountName).get("pos") == null){ |
| | | log.error("没有获取到持仓信息,等待初始化......"); |
| | | return null; |
| | | } |
| | | BigDecimal pos = PositionsWs.getAccountMap(positionAccountName).get("pos"); |
| | | if (BigDecimal.ZERO.compareTo( pos) >= 0) { |
| | | log.error("持仓数量为零,进行初始化订单"); |
| | | return OrderParamEnums.INIT.getValue(); |
| | | } |
| | | if (CoinEnums.POSSIDE_LONG.getCode().equals(posSide)){ |
| | | return caoZuoLong(accountName,markPx); |
| | | }else if (CoinEnums.POSSIDE_SHORT.getCode().equals(posSide)){ |