| | |
| | | import com.xcong.excoin.modules.okxNewPrice.okxWs.wanggeList.WangGeListQueue; |
| | | import com.xcong.excoin.modules.okxNewPrice.okxWs.wanggeList.WangGeListService; |
| | | import com.xcong.excoin.modules.okxNewPrice.utils.WsMapBuild; |
| | | import com.xcong.excoin.modules.okxNewPrice.wangge.WangGeQueue; |
| | | import com.xcong.excoin.modules.okxNewPrice.wangge.WangGeService; |
| | | import com.xcong.excoin.rabbit.pricequeue.AscBigDecimal; |
| | | import com.xcong.excoin.rabbit.pricequeue.DescBigDecimal; |
| | | import com.xcong.excoin.utils.RedisUtils; |
| | |
| | | @RequiredArgsConstructor |
| | | public class CaoZuoServiceImpl implements CaoZuoService { |
| | | |
| | | private final WangGeService wangGeService; |
| | | private final WangGeListService wangGeListService; |
| | | private final RedisUtils redisUtils; |
| | | |
| | |
| | | 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){ |
| | |
| | | /** |
| | | * 如果下单的网格不属于同一个网格,则先止损掉老的网格的仓位 |
| | | */ |
| | | 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); |
| | |
| | | ? BigDecimal.ZERO : PositionsWs.getAccountMap(positionAccountName).get(CoinEnums.READY_STATE.name()); |
| | | if (WsMapBuild.parseBigDecimalSafe(CoinEnums.READY_STATE_YES.getCode()).compareTo(positionsReadyState) != 0) { |
| | | log.info("仓位{}通道未就绪,取消发送",positionAccountName); |
| | | return null; |
| | | // 判断是否保证金超标 |
| | | if (PositionsWs.getAccountMap(positionAccountName).get("imr") == null){ |
| | | log.error("没有获取到持仓信息,等待初始化......"); |
| | | return null; |
| | | } |
| | | BigDecimal ordFrozImr = PositionsWs.getAccountMap(positionAccountName).get("imr"); |
| | | BigDecimal totalOrderUsdt = WsMapBuild.parseBigDecimalSafe(AccountWs.getAccountMap(accountName).get(CoinEnums.TOTAL_ORDER_USDT.name())); |
| | | if (ordFrozImr.compareTo(totalOrderUsdt) >= 0){ |
| | | log.error("已满仓......"); |
| | | 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(); |
| | | }else{ |
| | | log.error("仓位有持仓,等待持仓更新"); |
| | | return null; |
| | | } |
| | | } |
| | | // 系统设置的开关,等于冷静中,则代表不开仓 |
| | | String outStr = InstrumentsWs.getAccountMap(accountName).get(CoinEnums.OUT.name()); |
| | |
| | | if (pingCang != null && avgPx.compareTo(pingCang.getValue()) < 0) { |
| | | log.info("开始减仓...上限队列价格大于开仓价格{}>{}", pingCang.getValue(), avgPx); |
| | | // 手续费 |
| | | BigDecimal feeValue = PositionsWs.getAccountMap(positionAccountName).get("fee").multiply(new BigDecimal("2")); |
| | | BigDecimal feeValue = PositionsWs.getAccountMap(positionAccountName).get("fee"); |
| | | //未实现收益 |
| | | BigDecimal uplValue = PositionsWs.getAccountMap(positionAccountName).get("upl"); |
| | | //已实现收益 |
| | |
| | | log.info("开始减仓...下限队列价格小于开仓价格{}<{}", kaiCang.getValue(), avgPx); |
| | | |
| | | // 手续费 |
| | | BigDecimal feeValue = PositionsWs.getAccountMap(positionAccountName).get("fee").multiply(new BigDecimal("2")); |
| | | BigDecimal feeValue = PositionsWs.getAccountMap(positionAccountName).get("fee"); |
| | | //未实现收益 |
| | | BigDecimal uplValue = PositionsWs.getAccountMap(positionAccountName).get("upl"); |
| | | //已实现收益 |