| | |
| | | package com.xcong.excoin.quartz.job; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | |
| | | import com.xcong.excoin.modules.contract.dao.ContractOrderDao; |
| | | import com.xcong.excoin.modules.contract.entity.ContractOrderEntity; |
| | | import com.xcong.excoin.modules.documentary.dao.FollowFollowerOrderRelationDao; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | BigDecimal winRate = BigDecimal.valueOf(winCnt).divide(BigDecimal.valueOf(allCnt), 4, BigDecimal.ROUND_DOWN); |
| | | traderInfoProfit.setWinRate(winRate); |
| | | } |
| | | |
| | | Date date = new Date(); |
| | | DateTime offsetDay = DateUtil.offsetDay(new Date(), -30); |
| | | //30天胜率(30天盈利总张数/30平仓总张数) |
| | | BigDecimal thirtyTotalCnt = contractOrderDao.selectThirtyTotalCntByMemberId(tradeMemberId,date,offsetDay); |
| | | BigDecimal thirtyWinCnt = contractOrderDao.selectThirtyWinCntByMemberId(tradeMemberId,date,offsetDay); |
| | | BigDecimal thirtyTotalCntRatio = (thirtyTotalCnt == null?BigDecimal.ZERO:thirtyTotalCnt.setScale(2, BigDecimal.ROUND_DOWN)); |
| | | BigDecimal thirtyWinCntRatio = (thirtyWinCnt == null?BigDecimal.ZERO:thirtyWinCnt.setScale(2, BigDecimal.ROUND_DOWN)); |
| | | BigDecimal thirtyProfitRatio = BigDecimal.ZERO.setScale(2, BigDecimal.ROUND_DOWN);; |
| | | if(thirtyTotalCnt.compareTo(BigDecimal.ZERO) > 0) { |
| | | thirtyProfitRatio = thirtyWinCntRatio.divide(thirtyTotalCntRatio, 2, BigDecimal.ROUND_DOWN).setScale(2, BigDecimal.ROUND_DOWN); |
| | | } |
| | | traderInfoProfit.setThirtyProfitRatio(thirtyProfitRatio); |
| | | //30天最大回撤率(30天最高收益率-30天最低收益率) |
| | | BigDecimal thirtyMaxRatio = contractOrderDao.selectThirtyMaxRatioByMemberId(tradeMemberId,date,offsetDay); |
| | | BigDecimal thirtyMinRatio = contractOrderDao.selectThirtyMinRatioByMemberId(tradeMemberId,date,offsetDay); |
| | | BigDecimal thirtyRatio = (thirtyMaxRatio == null?BigDecimal.ZERO:thirtyMaxRatio.setScale(2, BigDecimal.ROUND_DOWN)) |
| | | .subtract((thirtyMinRatio == null?BigDecimal.ZERO:thirtyMinRatio.setScale(2, BigDecimal.ROUND_DOWN))); |
| | | traderInfoProfit.setThirtyRatio(thirtyRatio); |
| | | // 当前跟随者总收益 |
| | | BigDecimal followerProfit = followFollowerProfitDao.selectAllFollowerProfit(tradeMemberId); |
| | | traderInfoProfit.setFollowerTotalProfit(followerProfit); |