예제 #1
0
 /** Calculate Performance Goal as multiplier */
 public void setGoalPerformance() {
   BigDecimal MeasureTarget = getMeasureTarget();
   BigDecimal MeasureActual = getMeasureActual();
   BigDecimal GoalPerformance = Env.ZERO;
   if (MeasureTarget.signum() != 0)
     GoalPerformance = MeasureActual.divide(MeasureTarget, 6, BigDecimal.ROUND_HALF_UP);
   super.setGoalPerformance(GoalPerformance);
 } //	setGoalPerformance
예제 #2
0
 public BigDecimal getSumLiqLots() {
   BigDecimal sumLiqLots = BigDecimal.ZERO;
   for (Iterator<RelationOrder> iterator = this._outstandingOrders.values().iterator();
       iterator.hasNext(); ) {
     RelationOrder relationOrder = iterator.next();
     if (relationOrder.get_IsSelected() && relationOrder.get_LiqLot() != null) {
       sumLiqLots = sumLiqLots.add(relationOrder.get_LiqLot());
     }
   }
   return sumLiqLots;
 }
예제 #3
0
 public BigDecimal getTotalCloseLotOfFullClose() {
   BigDecimal sumLiqLots = BigDecimal.ZERO;
   for (Iterator<RelationOrder> iterator = this._outstandingOrders.values().iterator();
       iterator.hasNext(); ) {
     RelationOrder relationOrder = iterator.next();
     if (relationOrder.isFullClose()) {
       sumLiqLots = sumLiqLots.add(relationOrder.get_LiqLot());
     }
   }
   return sumLiqLots;
 }
예제 #4
0
 public BigDecimal getQuoteLotForDirectLiq(boolean isSpotTrade, Boolean isMakeLimitOrder) {
   BigDecimal quoteLot = BigDecimal.ZERO;
   for (Iterator<RelationOrder> iterator = this._outstandingOrders.values().iterator();
       iterator.hasNext(); ) {
     RelationOrder relationOrder = iterator.next();
     quoteLot =
         quoteLot.add(
             relationOrder.get_OpenOrder().getAvailableLotBanlance(isSpotTrade, isMakeLimitOrder));
   }
   return quoteLot;
 }
예제 #5
0
    public int compare(MakeOrderAccount left, MakeOrderAccount right) {
      int leftHasClose = left.isOpen() ? 1 : 0;
      int rightHasClose = right.isOpen() ? 1 : 0;
      int result = leftHasClose - rightHasClose;
      if (result != 0) return result;

      BigDecimal leftLot = left._isBuyForCurrent ? left._buyLot : left._sellLot;
      BigDecimal rightLot = right._isBuyForCurrent ? right._buyLot : right._sellLot;

      result = leftLot.compareTo(rightLot);
      if (result != 0) return -result;

      return left._account.get_Code().compareTo(right._account.get_Code());
    }
예제 #6
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;
  }
예제 #7
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;
  }
예제 #8
0
  // Used by Limit,MOO,MOC,MKT,OCO for mapOrder
  private void setOutstandingOrders(
      Order mapOrder, 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();
    Guid orderId = mapOrder.get_Id();
    RelationOrder outstandingOrder =
        new RelationOrder(
            this._tradingConsole,
            this._settingsManager,
            mapOrder,
            isSpot,
            isMakeLimitOrder,
            isDelivery);

    BigDecimal avaiableCloseLot = outstandingOrder.get_LiqLot();
    if (avaiableCloseLot.compareTo(BigDecimal.ZERO) > 0) {
      TradePolicyDetail tradePolicyDetail = this.getTradePolicyDetail();
      BigDecimal lot =
          isDelivery
              ? AppToolkit.fixDeliveryLot(avaiableCloseLot, tradePolicyDetail)
              : AppToolkit.fixCloseLot(
                  avaiableCloseLot, avaiableCloseLot, tradePolicyDetail, this._account);
      if (avaiableCloseLot.compareTo(lot) >= 0) {
        outstandingOrder.set_LiqLot(lot);

        if (!isDelivery) outstandingOrder.set_IsMakeLimitOrder(isMakeLimitOrder);
        this._outstandingOrders.put(orderId, outstandingOrder);
      }
    }
  }
예제 #9
0
 /**
  * Get Goal Performance in Percent
  *
  * @return performance in percent
  */
 public int getPercent() {
   BigDecimal bd = getGoalPerformance().multiply(Env.ONEHUNDRED);
   return bd.intValue();
 } //	getPercent
예제 #10
0
 /**
  * Get Goal Performance as Double
  *
  * @return performance as multipier
  */
 public double getGoalPerformanceDouble() {
   BigDecimal bd = getGoalPerformance();
   return bd.doubleValue();
 } //	getGoalPerformanceDouble
예제 #11
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);
                }
              }
            }
          }
        }
      }
    }
  }