示例#1
0
  public void setOutstandingOrdersForMakeLiquidationOrder(
      Instrument instrument, boolean forMakeOrderForm) {
    if (this._outstandingOrders.size() > 0) {
      return;
    }
    for (Iterator<Order> iterator = this._tradingConsole.get_OpenOrders().values().iterator();
        iterator.hasNext(); ) {
      Order order = iterator.next();
      if (!order.canClose()) continue;

      if (order.get_Transaction().get_Instrument() == instrument
          && order.get_Transaction().get_Account() == this._account) {
        if (!forMakeOrderForm
            || order.getAvailableLotBanlance(false, null).compareTo(BigDecimal.ZERO) > 0) {
          Guid orderId = order.get_Id();
          RelationOrder outstandingOrder =
              new RelationOrder(this._tradingConsole, this._settingsManager, order);
          outstandingOrder.set_IsSelected(order.get_Close());
          this._outstandingOrders.put(orderId, outstandingOrder);
        }
      }
    }
  }
示例#2
0
  // exclude make Liquidation order and make Limit,MOO,MOC,MKT,OCO for mapOrder.....
  private void setOutstandingOrders(
      BuySellType buySellType, Boolean isSpot, Boolean isMakeLimitOrder, boolean isDelivery) {
    /*if (this._outstandingOrders.size() > 0 || this._account.get_Type() == AccountType.Agent)
    {
    	Iterator<RelationOrder> relationOrders = this._outstandingOrders.values().iterator();
    	while(relationOrders.hasNext())
    	{
    		relationOrders.next().set_IsMakeLimitOrder(isMakeLimitOrder);
    	}
    	return;
    }*/

    this._outstandingOrders.clear();
    HashMap<Guid, Transaction> accountInstrumentTransactions =
        this.getAccountInstrumentTransactions();
    for (Iterator<Transaction> iterator = accountInstrumentTransactions.values().iterator();
        iterator.hasNext(); ) {
      Transaction transaction = iterator.next();
      if (transaction.get_Phase().equals(Phase.Executed)) {
        for (Iterator<Order> iterator2 = transaction.get_Orders().values().iterator();
            iterator2.hasNext(); ) {
          Order order = iterator2.next();
          if (order.get_Phase() != Phase.Executed) continue;
          if (order.get_Transaction().get_Account().get_Type() == AccountType.Agent
              || order.get_Transaction().get_Account().get_Type() == AccountType.Transit) continue;

          BigDecimal availableLotBanlance = BigDecimal.ZERO;
          if (isDelivery) {
            if (order.canDelivery()) {
              availableLotBanlance = order.getAvailableDeliveryLot();
              if (availableLotBanlance.compareTo(BigDecimal.ZERO) > 0) {
                Guid orderId = order.get_Id();
                RelationOrder outstandingOrder =
                    new RelationOrder(
                        this._tradingConsole, this._settingsManager, order, false, null, true);
                this._outstandingOrders.put(orderId, outstandingOrder);
              }
            }
          } else {
            if (order.canClose()) {
              availableLotBanlance = order.get_LotBalance();
              if (isSpot != null)
                availableLotBanlance = order.getAvailableLotBanlance(isSpot, isMakeLimitOrder);

              if (availableLotBanlance.compareTo(BigDecimal.ZERO) > 0) {
                Guid orderId = order.get_Id();
                RelationOrder outstandingOrder =
                    new RelationOrder(this._tradingConsole, this._settingsManager, order);
                outstandingOrder.set_IsMakeLimitOrder(isMakeLimitOrder);
                if (buySellType.equals(BuySellType.Both)) {
                  this._outstandingOrders.put(orderId, outstandingOrder);
                } else if (order.get_IsBuy() && (buySellType.equals(BuySellType.Buy))) {
                  this._outstandingOrders.put(orderId, outstandingOrder);
                } else if (!order.get_IsBuy() && (buySellType.equals(BuySellType.Sell))) {
                  this._outstandingOrders.put(orderId, outstandingOrder);
                }
              }
            }
          }
        }
      }
    }
  }