private MarginAssetsQueryResult getMarginAsset( MarginCashAccountView assetsPositionQueryView, MarginAccountPositionInfoResult marginAccountPositionInfo1) { MarginAccountPositionInfoResult marginAccountPositionInfo = marginAccountPositionInfo1; MarginAssetsQueryResult result = new MarginAssetsQueryResult(); result.setFundName(assetsPositionQueryView.getFundName()); result.setPortfolioName(assetsPositionQueryView.getPortfolioName()); result.setCashAccountName(assetsPositionQueryView.getCashAccountName()); result.setTotalAssets(marginAccountPositionInfo.getTotalAssets()); result.setTotalDebt(marginAccountPositionInfo.getTotalDebt()); BigDecimal netAssets = BigDecimalUtil.minus(result.getTotalAssets(), result.getTotalDebt()); result.setTotalNetAssets(netAssets); BigDecimal totalProfitAndLoss = marginAccountPositionInfo.getTotalProfit(); result.setProfitAndLoss(totalProfitAndLoss); BigDecimal maintainGuarantyRatio = BigDecimalUtil.divide( result.getTotalAssets(), result.getTotalDebt(), 4, BigDecimal.ROUND_HALF_DOWN); result.setMaintainGuarantyRatio(maintainGuarantyRatio); result.setTotalFee(marginAccountPositionInfo.getLeftFeeAndInterest()); return result; }
@Override public List<MarginAssetsQueryResult> queryAssets() throws PositionException { List<MarginAssetsQueryResult> assetsQueryResults = new ArrayList<MarginAssetsQueryResult>(); List<MarginCashAccountView> totalCashAssets = assetsPositionQueryDao.queryAccountInfo(); for (MarginCashAccountView assetsPositionQueryView : totalCashAssets) { try { MarginAccountPositionInfoResult marginAccountPositionInfo = marginAccountPositionInfoQueryImpl.query( assetsPositionQueryView.getPortfolioId(), assetsPositionQueryView.getCashAccountId(), TradeLevelConsts.ORDER); MarginAssetsQueryResult result = getMarginAsset(assetsPositionQueryView, marginAccountPositionInfo); assetsQueryResults.add(result); } catch (Exception e) { logger.error("查询头寸信息出现异常:{}", e.getMessage()); } } return assetsQueryResults; }