| | |
| | | package com.xcong.excoin.modules.okxNewPrice.celue; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.xcong.excoin.modules.okxNewPrice.okxWs.AccountWs; |
| | | import com.xcong.excoin.modules.okxNewPrice.okxWs.InstrumentsWs; |
| | | import com.xcong.excoin.modules.okxNewPrice.okxWs.PositionsWs; |
| | | import com.xcong.excoin.modules.okxNewPrice.okxWs.TradeOrderWs; |
| | | import com.xcong.excoin.modules.okxNewPrice.okxWs.*; |
| | | import com.xcong.excoin.modules.okxNewPrice.okxWs.enums.CoinEnums; |
| | | import com.xcong.excoin.modules.okxNewPrice.okxWs.enums.OrderParamEnums; |
| | | import com.xcong.excoin.modules.okxNewPrice.wangge.WangGeQueue; |
| | |
| | | */ |
| | | @Override |
| | | public String caoZuo() { |
| | | log.info("开始执行操作CaoZuoServiceImpl......"); |
| | | |
| | | // 获取合约执行操作状态 |
| | | String state = (String) redisUtils.get(instrumentsStateKey); |
| | | log.info("开始执行操作CaoZuoServiceImpl......{}",state); |
| | | |
| | | String live = (String) redisUtils.getWithDelay(TradeOrderWs.ORDERWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":state"); |
| | | if (!CoinEnums.ORDER_LIVE.getCode().equals( live)){ |
| | | log.warn("正在下单中,等待下单结束..."); |
| | | } |
| | | // 获取合约执行操作状态 |
| | | String outStr = (String) redisUtils.get(instrumentsOutKey); |
| | | if (OrderParamEnums.OUT_YES.getValue().equals(outStr) && OrderParamEnums.STATE_3.getValue().equals(state)){ |
| | | log.error("止损过了......冷静一下,等待下次入场......"); |
| | |
| | | } |
| | | |
| | | String uplStr = (String) redisUtils.get(positionsUplKey); |
| | | if (StrUtil.isBlank(uplStr)){ |
| | | //可使用的总保证金 |
| | | String cashBalStrKey = AccountWs.ACCOUNTWS_CHANNEL + ":" + CoinEnums.USDT.getCode() + ":cashBal"; |
| | | String cashBalStr = (String) redisUtils.get(cashBalStrKey); |
| | | if (StrUtil.isBlank(cashBalStr) || StrUtil.isBlank(uplStr)){ |
| | | return OrderParamEnums.INIT.getValue(); |
| | | } |
| | | //可使用的总保证金 |
| | | String cashBalStrKey = AccountWs.ACCOUNTWS_CHANNEL + ":" + CoinEnums.USDT.getCode() + ":cashBalStr"; |
| | | String cashBalStr = (String) redisUtils.get(cashBalStrKey); |
| | | BigDecimal upl = new BigDecimal(uplStr); |
| | | if (BigDecimal.ZERO.compareTo(upl) >= 0){ |
| | | upl = upl.multiply(new BigDecimal("-1")); |