Exemplo n.º 1
0
  /** 融资融券交易,需要检查可卖数量(InprogressCheck已经检查)、(可还券数量、可还款金额、可还券金额:必须大于等于0)、可融资额度、 可融券额度、保证金比例、 维持担保比例 */
  public String check(PositionAccountDeltaEvent accountDelta) {
    if (isNeedCheck(accountDelta) == false) {
      return null;
    }

    String positionAccountType = accountDelta.getPositionAccountType();
    String securityTypeCode = accountDelta.getSecurityTypeCode();
    if (SecurityTypeConsts.CURRENCY.equals(securityTypeCode)) {
      // 可还券金额
      if (AccountTypeConsts.ORDER_FLOW_OUT.equals(positionAccountType)
          || AccountTypeConsts.PLACEMENT_FLOW_OUT.equals(positionAccountType)) {
        if (isLessThanZero(accountDelta, AccountTypeConsts.POSITION)) {
          return "可还券金额必须大于等于0";
        }
      }
      // 可还款金额
      else if (AccountTypeConsts.GAGE_POSITION_ORDER_OUT.equals(positionAccountType)
          || AccountTypeConsts.GAGE_POSITION_PLACEMENT_OUT.equals(positionAccountType)) {
        if (isLessThanZero(accountDelta, AccountTypeConsts.GAGE_POSITION)) {
          return "可还款金额必须大于等于0";
        }
      }
    } else if (SecurityTypeConsts.STOCK.equals(securityTypeCode)) {
      // 可还券数量
      if (AccountTypeConsts.ORDER_FLOW_OUT.equals(positionAccountType)
          || AccountTypeConsts.PLACEMENT_FLOW_OUT.equals(positionAccountType)) {
        if (isLessThanZero(accountDelta, AccountTypeConsts.POSITION)) {
          return "可还券数量必须大于等于0";
        }
      }
    }
    return null;
  }
Exemplo n.º 2
0
 private boolean isNeedCheck(PositionAccountDeltaEvent accountDelta) {
   String tradeAccountType = accountDelta.getTradeAccountType();
   if (TradeAccountTypeConsts.MARGIN_TRADING.equals(tradeAccountType)) {
     return true;
   }
   return false;
 }
Exemplo n.º 3
0
 private boolean isLessThanZero(PositionAccountDeltaEvent accountDelta, String accountType) {
   String portfolioId = accountDelta.getPortfolioId();
   String accountId = accountDelta.getAccountId();
   String positionAccountType = accountDelta.getPositionAccountType();
   String securityId = accountDelta.getSecurityId();
   BigDecimal outValue =
       positionAccountCheckDao.findAccount(
           portfolioId, accountId, positionAccountType, securityId, LongShortConsts.LONG);
   BigDecimal realValue =
       positionAccountCheckDao.findAccount(
           portfolioId, accountId, accountType, securityId, LongShortConsts.LONG);
   BigDecimal willValue =
       BigDecimalUtil.minus(realValue, BigDecimalUtil.add(outValue, accountDelta.getBalance()));
   if (BigDecimalUtil.compareTo(willValue, BigDecimal.ZERO) < 0) {
     return true;
   }
   return false;
 }