示例#1
0
  public boolean isAcceptLot(boolean isBuy, BigDecimal lot, boolean isHasMakeNewOrder) {
    // if (!Parameter.isNewOrderAcceptedHedging)
    // {
    //	return true;
    // }

    if (this._instrument.get_Code().substring(0, 1).equals("#")) {
      GetSumLotBSForOpenOrderWithFlagResult getSumLotBSForOpenOrderWithFlagResult =
          this.getSumLotBSForOpenOrderWithFlag(isBuy);
      BigDecimal sumBuyLots = getSumLotBSForOpenOrderWithFlagResult.sumBuyLots;
      BigDecimal sumSellLots = getSumLotBSForOpenOrderWithFlagResult.sumSellLots;
      if (isHasMakeNewOrder || getSumLotBSForOpenOrderWithFlagResult.isExistsUnconfirmedOrder) {
        return (isBuy && (sumSellLots.subtract(sumBuyLots).compareTo(lot) >= 0)
            || (!isBuy && (sumBuyLots.subtract(sumSellLots).compareTo(lot) >= 0)));
      }
    }
    return true;
  }
示例#2
0
  public BigDecimal closeAll() {
    BigDecimal totalLiqLot = BigDecimal.ZERO;
    for (Iterator<RelationOrder> iterator = this._outstandingOrders.values().iterator();
        iterator.hasNext(); ) {
      RelationOrder relationOrder = iterator.next();
      if (this._isBuyForCurrent != relationOrder.get_IsBuy()
          || (this._isForDelivery && relationOrder.get_IsBuy())) {
        totalLiqLot = totalLiqLot.add(relationOrder.get_LiqLot());
      }
    }
    TradePolicyDetail tradePolicyDetail =
        this._settingsManager.getTradePolicyDetail(
            this._account.get_TradePolicyId(), this._instrument.get_Id());
    totalLiqLot =
        this._isForDelivery
            ? AppToolkit.fixDeliveryLot(totalLiqLot, tradePolicyDetail)
            : totalLiqLot; // AppToolkit.fixLot(totalLiqLot, false, tradePolicyDetail, this);
    BigDecimal totalLiqLot2 = totalLiqLot;

    for (Iterator<RelationOrder> iterator = this._outstandingOrders.values().iterator();
        iterator.hasNext(); ) {
      RelationOrder relationOrder = iterator.next();
      if (this._isBuyForCurrent != relationOrder.get_IsBuy()
          || (this._isForDelivery && relationOrder.get_IsBuy())) {
        BigDecimal liqLot = relationOrder.get_LiqLot();
        liqLot = totalLiqLot.compareTo(liqLot) > 0 ? liqLot : totalLiqLot;
        relationOrder.set_LiqLot(liqLot);
        totalLiqLot = totalLiqLot.subtract(liqLot);
        relationOrder.set_IsSelected(true);
        relationOrder.update(this._outstandingKey);

        if (totalLiqLot.compareTo(BigDecimal.ZERO) <= 0) break;
      }
    }

    if (this._isBuyForCurrent) {
      this._buyLot = totalLiqLot2;
    } else {
      this._sellLot = totalLiqLot2;
    }
    return totalLiqLot2;
  }