| | |
| | | |
| | | private String orderPriceType; |
| | | |
| | | /** |
| | | * 仓位类型:0:逐仓 1:全仓 |
| | | */ |
| | | private Integer locationType = 1; |
| | | |
| | | public BigDecimal getAmountClose() { |
| | | if(amountClose == null){ |
| | | amountClose = BigDecimal.ZERO; |
| | |
| | | } |
| | | |
| | | public BigDecimal getChangeRatio() { |
| | | if(amountClose == null){ |
| | | amountClose = BigDecimal.ZERO; |
| | | } |
| | | if(profit == null){ |
| | | profit = BigDecimal.ZERO; |
| | | } |
| | | if(deposit == null){ |
| | | deposit = BigDecimal.ZERO; |
| | | } |
| | | if(depositOpen == null){ |
| | | depositOpen = BigDecimal.ZERO; |
| | | } |
| | | if (STATE_SUBMITTED.equals(state)) { |
| | | changeRatio = amountClose.add(profit).add(deposit).subtract(depositOpen).divide(depositOpen,10 , RoundingMode.HALF_UP); |
| | | } else { |
| | | changeRatio = amountClose.add(deposit).subtract(depositOpen).divide(depositOpen, 10 , RoundingMode.HALF_UP); |
| | | } |
| | | // if(amountClose == null){ |
| | | // amountClose = BigDecimal.ZERO; |
| | | // } |
| | | // if(profit == null){ |
| | | // profit = BigDecimal.ZERO; |
| | | // } |
| | | // if(deposit == null){ |
| | | // deposit = BigDecimal.ZERO; |
| | | // } |
| | | // if(depositOpen == null){ |
| | | // depositOpen = BigDecimal.ZERO; |
| | | // } |
| | | // if (STATE_SUBMITTED.equals(state)) { |
| | | // changeRatio = amountClose.add(profit).add(deposit).subtract(depositOpen).divide(depositOpen,10 , RoundingMode.HALF_UP); |
| | | // } else { |
| | | // changeRatio = amountClose.add(deposit).subtract(depositOpen).divide(depositOpen, 10 , RoundingMode.HALF_UP); |
| | | // } |
| | | // |
| | | // changeRatio = changeRatio.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | // 计算收益率,指定除法时的精度 |
| | | BigDecimal changeRatio = profit.divide(depositOpen, 10, BigDecimal.ROUND_DOWN) // 设置精度为10位 |
| | | .multiply(new BigDecimal("100")); |
| | | |
| | | changeRatio = changeRatio.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | // 保留两位小数 |
| | | changeRatio = changeRatio.setScale(2, BigDecimal.ROUND_DOWN); |
| | | |
| | | return changeRatio; |
| | | } |
| | | |