| | |
| | | package com.xcong.excoin.modules.okxNewPrice; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | |
| | | return; |
| | | } |
| | | |
| | | String state = (String) redisUtils.get(InstrumentsWs.INSTRUMENTSWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":state"); |
| | | String uplKey = PositionsWs.POSITIONSWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":upl"; |
| | | String totalOrderUsdtKey = AccountWs.ACCOUNTWS_CHANNEL + ":" + CoinEnums.USDT.getCode() + ":totalOrderUsdt"; |
| | | |
| | | String upl = (String) redisUtils.get(uplKey); |
| | | String upl = ObjectUtil.isEmpty(redisUtils.get(uplKey)) ? "0" : (String)redisUtils.get(uplKey); |
| | | |
| | | String totalOrderUsdt = (String) redisUtils.get(totalOrderUsdtKey); |
| | | BigDecimal multiply = new BigDecimal(upl).multiply(new BigDecimal("-1")); |
| | | |
| | | if (new BigDecimal(totalOrderUsdt).compareTo(multiply) < 0) { |
| | | if (new BigDecimal(totalOrderUsdt).compareTo(multiply) < 0 || OrderParamEnums.STATE_3.getValue().equals(state)) { |
| | | log.error("持仓盈亏超过下单总保证金,止损冷静一天......"); |
| | | TradeOrderWs.orderEvent(webSocketClient, redisUtils, OrderParamEnums.OUT.getValue()); |
| | | return; |