| | |
| | | // 构造Redis键名 |
| | | final String coinCode = CoinEnums.HE_YUE.getCode(); |
| | | final String instrumentsStateKey = InstrumentsWs.INSTRUMENTSWS_CHANNEL + ":" + coinCode + ":state"; |
| | | final String instrumentsOutKey = InstrumentsWs.INSTRUMENTSWS_CHANNEL+":" + coinCode+":out"; |
| | | final String positionsMarkPxKey = PositionsWs.POSITIONSWS_CHANNEL + ":" + coinCode + ":markPx"; |
| | | final String positionsAvgPxKey = PositionsWs.POSITIONSWS_CHANNEL + ":" + coinCode + ":avgPx"; |
| | | final String positionsOrderPriceKey = PositionsWs.POSITIONSWS_CHANNEL + ":" + coinCode + ":orderPrice"; |
| | |
| | | @Override |
| | | public String caoZuo() { |
| | | log.info("开始执行操作CaoZuoServiceImpl......"); |
| | | String outStr = (String) redisUtils.get(instrumentsOutKey); |
| | | if (OrderParamEnums.OUT_YES.getValue().equals(outStr)){ |
| | | log.error("止损过了......冷静一下,等待下次入场......"); |
| | | return null; |
| | | } |
| | | |
| | | // 获取合约执行操作状态 |
| | | String state = (String) redisUtils.get(instrumentsStateKey); |
| | |
| | | return OrderParamEnums.ORDERING.getValue(); |
| | | } |
| | | if (OrderParamEnums.STATE_3.getValue().equals(state)){ |
| | | log.error("持仓盈亏超过下单总保证金,止损冷静一天......"); |
| | | log.error("持仓盈亏超过下单总保证金,冷静止损......"); |
| | | redisUtils.set(instrumentsOutKey, OrderParamEnums.OUT_YES.getValue(), 0); |
| | | return OrderParamEnums.OUT.getValue(); |
| | | } |
| | | if (OrderParamEnums.STATE_2.getValue().equals(state)){ |