コード例 #1
0
ファイル: ADate.java プロジェクト: jefferya/basex
 /**
  * Converts a day count into year, month and day components. Algorithm is derived from J R
  * Stockton (http://www.merlyn.demon.co.uk/daycount.htm).
  *
  * @param days day count
  * @return result array
  */
 private static long[] ymd(final BigDecimal days) {
   BigDecimal d = days;
   BigDecimal t =
       d.add(BD36525).multiply(BD4).divideToIntegralValue(BD146097).subtract(BigDecimal.ONE);
   BigDecimal y = BD100.multiply(t);
   d = d.subtract(BD36524.multiply(t).add(t.divideToIntegralValue(BD4)));
   t = d.add(BD366).multiply(BD4).divideToIntegralValue(BD1461).subtract(BigDecimal.ONE);
   y = y.add(t);
   d = d.subtract(BD365.multiply(t).add(t.divideToIntegralValue(BD4)));
   final BigDecimal m = BD5.multiply(d).add(BD2).divideToIntegralValue(BD153);
   d = d.subtract(BD153.multiply(m).add(BD2).divideToIntegralValue(BD5));
   long mm = m.longValue();
   if (mm > 9) {
     mm -= 12;
     y = y.add(BigDecimal.ONE);
   }
   return new long[] {y.subtract(BigDecimal.valueOf(ADD_NEG)).longValue(), mm + 2, d.longValue()};
 }
コード例 #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
ファイル: AdditiveExpr.java プロジェクト: JJWTimmer/AP2DX
  @Override
  public BigDecimal evaluate(QueryEval eval) {
    Object firstValue = multiplyExprs[0].evaluate(eval);
    BigDecimal result = new BigDecimal(firstValue.toString());

    for (int i = 1; i < multiplyExprs.length; i++) {
      Object nextValue = multiplyExprs[i].evaluate(eval);
      BigDecimal operand = new BigDecimal(nextValue.toString());
      result = operators.get(i - 1) ? result.add(operand) : result.subtract(operand);
    }

    return result;
  }
コード例 #6
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;
  }
コード例 #7
0
ファイル: Functional.java プロジェクト: zpublic/dozy
 public BigDecimal combine(BigDecimal x, BigDecimal y) {
   return x.add(y);
 }