| | |
| | | } |
| | | } |
| | | |
| | | // 保证金 |
| | | BigDecimal bondAmount = CalculateUtil.getBondAmount(holdOrderEntity.getOpeningPrice(), lotNumber, closeCnt, holdOrderEntity.getLeverRatio()); |
| | | |
| | | // 平仓手续费 |
| | | BigDecimal fee = holdOrderEntity.getOpeningFeeAmount().divide(BigDecimal.valueOf(holdOrderEntity.getSymbolCnt()), 8, BigDecimal.ROUND_DOWN).multiply(BigDecimal.valueOf(closeCnt)); |
| | | |
| | | ContractOrderEntity contractOrderEntity = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrder(holdOrderEntity); |
| | | contractOrderEntity.setId(null); |
| | | contractOrderEntity.setClosingPrice(newPrice); |
| | |
| | | contractOrderEntity.setClosingType(closingType); |
| | | contractOrderEntity.setSymbolCnt(closeCnt); |
| | | contractOrderEntity.setRewardAmount(profitOrLoss); |
| | | contractOrderEntity.setBondAmount(bondAmount); |
| | | contractOrderEntity.setClosingFeeAmount(fee); |
| | | contractOrderDao.insert(contractOrderEntity); |
| | | |
| | | holdOrderEntity.setSymbolCntSale(holdOrderEntity.getSymbolCntSale() - closeCnt); |
| | | contractHoldOrderDao.updateById(holdOrderEntity); |
| | | } |
| | | |
| | | BigDecimal changeAmount = profitOrLoss.add(bondAmount).subtract(fee); |
| | | |
| | | memberWalletContractDao.increaseWalletContractBalanceById(changeAmount, fee.negate(), null, walletContract.getId()); |
| | | |
| | | ThreadPoolUtils.sendWholeForceClosingPrice(holdOrderEntity.getSymbol(), memberEntity); |
| | | // 计算佣金 |
| | | ThreadPoolUtils.calReturnMoney(memberEntity.getId(), fee, contractOrderEntity, AgentReturnEntity.ORDER_TYPE_CLOSE); |
| | | |
| | | } |
| | | } |
| | | } |