| | |
| | | MemberSettingDao memberSettingDao = SpringContextHolder.getBean(MemberSettingDao.class);
|
| | | BigDecimal forcePrice = BigDecimal.ZERO;
|
| | | BigDecimal money = bondAmount.divide(new BigDecimal(symbolSkuNumber).multiply(lotNumber), 8, BigDecimal.ROUND_DOWN);
|
| | | if (member.getIsForce() == 1) {
|
| | | MemberSettingEntity memberSetting = memberSettingDao.selectMemberSettingByMemberId(member.getId());
|
| | | money = money.multiply(memberSetting.getForceParam().multiply(BigDecimal.valueOf(100)));
|
| | | }
|
| | | //卖空
|
| | | if (type == 2) {
|
| | | forcePrice = money.add(openPrice);
|
| | | if (member.getIsForce() == 1) {
|
| | | MemberSettingEntity memberSetting = memberSettingDao.selectMemberSettingByMemberId(member.getId());
|
| | | //预估强平价 = 预估强平价-预估强平价*系数
|
| | | forcePrice = forcePrice.subtract(forcePrice.multiply(memberSetting.getForceParam() == null ? BigDecimal.ZERO : memberSetting.getForceParam()));
|
| | | }
|
| | | } else {//开多
|
| | | forcePrice = openPrice.subtract(money);
|
| | | if (member.getIsForce() == 1) {
|
| | | MemberSettingEntity memberSetting = memberSettingDao.selectMemberSettingByMemberId(member.getId());
|
| | | //预估强平价 = 预估强平价-预估强平价*系数
|
| | | forcePrice = forcePrice.add(forcePrice.multiply(memberSetting.getForceParam() == null ? BigDecimal.ZERO : memberSetting.getForceParam()));
|
| | | }
|
| | | }
|
| | | if (forcePrice.compareTo(BigDecimal.ZERO) < 0) {
|
| | | forcePrice = BigDecimal.ZERO;
|
| | |
| | | int subCnt = 0;
|
| | | BigDecimal openPrice = BigDecimal.ZERO;
|
| | | int type = 1;
|
| | | BigDecimal feeAmount = BigDecimal.ZERO;
|
| | | BigDecimal bondAmount = BigDecimal.ZERO;
|
| | | BigDecimal sku = BigDecimal.ZERO;
|
| | |
|
| | | Long id = 0L;
|
| | |
| | | subCnt = maxCnt - holdOrderEntity.getSymbolCntSale();
|
| | | }
|
| | |
|
| | | log.info("--{}, {}, {}, {}", maxCnt, subCnt, openPrice, type);
|
| | | feeAmount = feeAmount.add(holdOrderEntity.getOpeningFeeAmount());
|
| | | bondAmount = bondAmount.add(holdOrderEntity.getBondAmount().subtract(holdOrderEntity.getOpeningFeeAmount()));
|
| | | sku = holdOrderEntity.getSymbolSku();
|
| | | }
|
| | | BigDecimal forceSetPrice = BigDecimal.ZERO;
|
| | | if (subCnt != 0) {
|
| | | log.info("--->{}, {}, {}, {}, {}", openPrice, subCnt, sku, type, maxCnt);
|
| | | forceSetPrice = getForceSetPrice(walletContract.getTotalBalance().subtract(feeAmount), openPrice, subCnt, sku, type, memberEntity);
|
| | | log.info("---->{}, {}", walletContract.getAvailableBalance(), bondAmount);
|
| | | forceSetPrice = getForceSetPrice(walletContract.getAvailableBalance().add(bondAmount), openPrice, subCnt, sku, type, memberEntity);
|
| | | }
|
| | |
|
| | | log.info("强平价:{}", forceSetPrice);
|
| | |
| | |
|
| | | if (forceSetPrice.compareTo(BigDecimal.ZERO) > 0) {
|
| | | log.info("id:{}, type:{}, forceSetPrice:{}, symbol:{}, operateNo:{}", id, type, forceSetPrice, symbol, operateNo);
|
| | | sendOrderBombMsg(id, type, forceSetPrice, symbol, operateNo);
|
| | | sendOrderBombMsg(id, type, forceSetPrice, symbol, operateNo, memberEntity.getId());
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | */
|
| | |
|
| | | private static void sendOrderBombMsg(Long id, int type, BigDecimal forceClosingPrice, String symbol, int operateNo) {
|
| | | private static void sendOrderBombMsg(Long id, int type, BigDecimal forceClosingPrice, String symbol, int operateNo, Long memberId) {
|
| | | OrderModel model = null;
|
| | | // 开多
|
| | | if (ContractHoldOrderEntity.OPENING_TYPE_MORE == type) {
|
| | | model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo);
|
| | | model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo, memberId);
|
| | | // 开空
|
| | | } else {
|
| | | model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo);
|
| | | model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo, memberId);
|
| | | }
|
| | | SpringContextHolder.getBean(OrderProducer.class).sendPriceOperate(JSONObject.toJSONString(model));
|
| | | }
|