當前位置: 首頁>>代碼示例>>Java>>正文


Java BigDecimal.max方法代碼示例

本文整理匯總了Java中java.math.BigDecimal.max方法的典型用法代碼示例。如果您正苦於以下問題:Java BigDecimal.max方法的具體用法?Java BigDecimal.max怎麽用?Java BigDecimal.max使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.math.BigDecimal的用法示例。


在下文中一共展示了BigDecimal.max方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: create

import java.math.BigDecimal; //導入方法依賴的package包/類
/**
 * Create a graph
 * @param goalInKg the goal set
 * @param measurements the measurement data
 * @return a chart 
 */
public Chart create(BigDecimal goalInKg, Iterable<WeightMeasurement> measurements) {
	BigDecimal minValue = goalInKg;
	BigDecimal maxValue = goalInKg;
	List<List<Object>> dataPoints = new ArrayList<>();
	for (WeightMeasurement wm : measurements) {
		if (minValue == null) {
			minValue = wm.getWeightInKg();
		} else {
			minValue = minValue.min(wm.getWeightInKg());
		}
		if (maxValue == null) {
			maxValue = wm.getWeightInKg();
		} else {
			maxValue = maxValue.max(wm.getWeightInKg());
		}
		dataPoints.add(Lists.newArrayList(wm.getDateTime().toInstant(ZoneOffset.UTC).toEpochMilli(),wm.getWeightInKg()));
	}
	if (minValue != null) {
		minValue = minValue.subtract(BigDecimal.valueOf(1));
	} 
	if (maxValue != null) {
		maxValue = maxValue.add(BigDecimal.valueOf(1));
	}
	return Chart.of(minValue, maxValue, goalInKg, dataPoints, calculareTrend(dataPoints));
}
 
開發者ID:xabgesagtx,項目名稱:fat-lining,代碼行數:32,代碼來源:ChartFactory.java

示例2: calculateCurvatureMarginResidual

import java.math.BigDecimal; //導入方法依賴的package包/類
/**
 * As defined in Appendix 1 of ISDA_SIMM_2.0_(PUBLIC).pdf
 */
static BigDecimal calculateCurvatureMarginResidual(List<BucketWeightedAggregation> aggregateByBucket) {
  List<BucketWeightedAggregation> residuals = BucketWeightedAggregationUtils.filterOutNonResiduals(aggregateByBucket);
  BigDecimal sum = ZERO;
  for (BucketWeightedAggregation bucketWeightedAggregation : residuals) {
    BigDecimal weightedSensitivitiesSum = WeightedSensitivityUtils.sumWeightSensitivities(bucketWeightedAggregation.getWeightedSensitivities());
    BigDecimal calculateLambda = CurvatureMarginLambdaUtils.calculateLambda(bucketWeightedAggregation.getWeightedSensitivities());
    BigDecimal product = calculateLambda.multiply(bucketWeightedAggregation.getAggregate());
    BigDecimal riskFactorTotal = weightedSensitivitiesSum.add(product);
    sum = sum.add(riskFactorTotal);
  }
  return sum.max(ZERO);
}
 
開發者ID:AcadiaSoft,項目名稱:simm-lib,代碼行數:16,代碼來源:CurvatureMarginResidualUtils.java

示例3: aggregateCrossBucket

import java.math.BigDecimal; //導入方法依賴的package包/類
/**
 * As defined in Appendix 1 of ISDA_SIMM_2.0_(PUBLIC).pdf
 */
static BigDecimal aggregateCrossBucket(RiskClass riskClass, List<BucketWeightedAggregation> aggregateByBucket) {
  List<BucketWeightedAggregation> nonResiduals = BucketWeightedAggregationUtils.filterOutResiduals(aggregateByBucket);
  if (CollectionUtils.isNotEmpty(nonResiduals)) {
    BigDecimal sumOfRiskExposures = BucketWeightedAggregationUtils.sumWeightedSensitivities(nonResiduals);
    List<WeightedSensitivity> allWeightedSensitivities =
      nonResiduals.stream().map(BucketWeightedAggregation::getWeightedSensitivities).flatMap(Collection::stream).collect(Collectors.toList());
    BigDecimal calculateLambda = CurvatureMarginLambdaUtils.calculateLambda(allWeightedSensitivities);

    BigDecimal sumSquaresByBucket = BucketWeightedAggregationUtils.sumSquared(nonResiduals);
    BigDecimal sumCorrelationsAcrossBuckets = sumCorrelationsAcrossBuckets(riskClass, nonResiduals);
    BigDecimal crossSum = sumSquaresByBucket.add(sumCorrelationsAcrossBuckets);
    BigDecimal crossSqrt = BigDecimalUtils.sqrt(crossSum);

    BigDecimal rhs = calculateLambda.multiply(crossSqrt);

    BigDecimal finalSum = sumOfRiskExposures.add(rhs);
    return finalSum.max(ZERO);
  } else {
    return ZERO;
  }
}
 
開發者ID:AcadiaSoft,項目名稱:simm-lib,代碼行數:25,代碼來源:CurvatureMarginAcrossBucketUtils.java

示例4: doLogic

import java.math.BigDecimal; //導入方法依賴的package包/類
public static boolean doLogic(BigDecimal valueOne, Operator.Logic operator, BigDecimal valueTwo)
{
	switch (operator)
	{
		case EQUALS:
			return valueOne.equals(valueTwo);
		case NOTEQUALS:
			return !valueOne.equals(valueTwo);
		case GREATER:
			BigDecimal max = valueOne.max(valueTwo);
			return max.equals(valueOne);
		case SMALLER:
			BigDecimal min = valueOne.min(valueTwo);
			return min.equals(valueOne);
		default:
			return false;
	}
}
 
開發者ID:DirkDeVisser,項目名稱:pifuck,代碼行數:19,代碼來源:BasicBigDecimal.java

示例5: getFeeAmount

import java.math.BigDecimal; //導入方法依賴的package包/類
private BigDecimal getFeeAmount(BigDecimal amount, BigDecimal feeRatio, BigDecimal feeMax) {
    BigDecimal fee = new BigDecimal(0);
    if(null == amount || null == feeRatio) return fee;
    //金額乘以費率 = 手續費
    fee = amount.multiply(feeRatio);
    //最大值為feeMax
    if(null != feeMax && feeMax.compareTo(new BigDecimal("0")) >= 0) fee = fee.max(feeMax);
    //設置精確到分並四舍五入
    fee = fee.setScale(4, BigDecimal.ROUND_HALF_UP);
    return fee;
}
 
開發者ID:wangfei0904306,項目名稱:unionpay,代碼行數:12,代碼來源:UnionPaymentServiceImpl.java

示例6: calculateMax

import java.math.BigDecimal; //導入方法依賴的package包/類
/**
 * Calculate Maximum
 * 
 * @param fileContents
 * @param target
 * @return sumValue
 */
private BigDecimal calculateMax(FileContents fileContents,
        final String target) {
    /* Calculate Maximum Column Value */
    BigDecimal maxValue = BigDecimal.valueOf(Double.MIN_VALUE);
    for (final FileRecord fileRecord : fileContents.getData()) {
        BigDecimal expressionValue = new BigDecimal(String.valueOf(
                evaluateExpression(fileContents, fileRecord, target)));
        maxValue = maxValue.max(expressionValue);
    }
    return maxValue;
}
 
開發者ID:ukubuka,項目名稱:ukubuka-core,代碼行數:19,代碼來源:UkubukaTransformer.java

示例7: max

import java.math.BigDecimal; //導入方法依賴的package包/類
@Override
public BigDecimal max(BigDecimal arg0, BigDecimal arg1) {
    return arg0.max(arg1);
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:5,代碼來源:BigRealAlgebra.java

示例8: max

import java.math.BigDecimal; //導入方法依賴的package包/類
public static BigDecimal max( BigDecimal a, BigDecimal b ) {
   return a.max( b );
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:4,代碼來源:Math.java

示例9: adjustSellBoundaryPrice

import java.math.BigDecimal; //導入方法依賴的package包/類
@Override
protected BigDecimal adjustSellBoundaryPrice(Context context, Request request, BigDecimal price) {

    if (price == null) {
        return null;
    }

    Key key = getUnderlyingKey(request);

    if (key == null) {
        return price;
    }

    BigDecimal ask = context.getBestAskPrice(key);

    BigDecimal comm = context.getCommissionRate(key);

    BigDecimal spread = request.getTradingSpread();

    BigDecimal dailyRate = getDecimalProperty(KEY_SWAP_S, SWAP_RATE);

    BigDecimal swap = calculateSwapRate(context, request, dailyRate);

    if (ask == null || comm == null || swap == null) {
        return null;
    }

    BigDecimal theoretical = ask.multiply(ONE.add(comm).add(spread).add(swap));

    return price.max(theoretical);

}
 
開發者ID:after-the-sunrise,項目名稱:cryptotrader,代碼行數:33,代碼來源:BitflyerAdviser.java

示例10: calculateSellLimitPrice

import java.math.BigDecimal; //導入方法依賴的package包/類
@VisibleForTesting
BigDecimal calculateSellLimitPrice(Context context, Request request, BigDecimal weighedPrice, BigDecimal basis) {

    if (weighedPrice == null || basis == null) {

        log.trace("Sell price not available : weighed=[{}] basis=[{}]", weighedPrice, basis);

        return null;

    }

    Key key = Key.from(request);

    BigDecimal bound = calculateSellBoundaryPrice(context, request, basis);

    if (bound == null) {

        log.trace("Sell price not available : No bound price.");

        return null;

    }

    BigDecimal basisPrice = weighedPrice.multiply(ONE.add(basis));

    BigDecimal boundPrice = basisPrice.max(bound);

    BigDecimal rounded = context.roundTickSize(key, boundPrice, UP);

    log.trace("Sell price : {} (target=[{}] basis=[{}])", rounded, boundPrice, basisPrice);

    return rounded;

}
 
開發者ID:after-the-sunrise,項目名稱:cryptotrader,代碼行數:35,代碼來源:TemplateAdviser.java

示例11: getDecimal

import java.math.BigDecimal; //導入方法依賴的package包/類
@VisibleForTesting
BigDecimal getDecimal(String site, String instrument,
                      PropertyType type, BigDecimal min, BigDecimal max, BigDecimal defaultValue) {

    try {

        BigDecimal value = get(type, site, instrument, Configuration::getBigDecimal);

        BigDecimal adjusted = value;

        if (min != null) {
            adjusted = adjusted.max(min);
        }

        if (max != null) {
            adjusted = adjusted.min(max);
        }

        log.trace("Fetched {} ({}.{}) : {} -> {}", type, site, instrument, value, adjusted);

        return adjusted;

    } catch (RuntimeException e) {

        log.warn(format("Invalid %s (%s.%s)", type, site, instrument), e);

        return defaultValue;

    }

}
 
開發者ID:after-the-sunrise,項目名稱:cryptotrader,代碼行數:32,代碼來源:PropertyManagerImpl.java

示例12: max

import java.math.BigDecimal; //導入方法依賴的package包/類
public static BigDecimal max(BigDecimal a, BigDecimal b) { return a.max(b); } 
開發者ID:CenPC434,項目名稱:java-tools,代碼行數:2,代碼來源:Lang.java


注:本文中的java.math.BigDecimal.max方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。