List of utility methods to do BigDecimal
BigDecimal | getPercentage(BigDecimal amount, BigDecimal percent) get Percentage return divide(amount.multiply(percent), ONE_HUNDRED);
|
BigDecimal | getPercentageValue(BigDecimal price, double amount) get Percentage Value return price.multiply(new BigDecimal(amount / 100)); |
BigDecimal | getProfit(BigDecimal ask, BigDecimal bid, BigDecimal fee) Get the profit of an operation from its ask/bid and fees values BigDecimal one = new BigDecimal(1); BigDecimal oneMinusFee = one.subtract(fee); BigDecimal omfPow = oneMinusFee.multiply(oneMinusFee); BigDecimal profit = ask.divide(bid, 8, RoundingMode.FLOOR).multiply(omfPow).subtract(one); return profit; |
BigDecimal | getProzentWert(BigDecimal zahl, BigDecimal prozentsatz, int nachkommastellen) Den Wert eines Prozentsatzes einer Zahl berechnen, kaufmaennisch auf n Nachkommastellen gerundet. BigDecimal prozentsatz2 = prozentsatz.movePointLeft(2);
BigDecimal result = zahl.multiply(prozentsatz2);
return rundeKaufmaennisch(result, nachkommastellen);
|
BigDecimal | getRandomBigDecimal(BigDecimal a, BigDecimal b) get Random Big Decimal double randomNum = Math.random(); return a.add((b.subtract(a)).multiply(new BigDecimal(randomNum))); |
BigDecimal | getRandomBigDecimal(int maxValue, int scale) get Random Big Decimal Random generator = new Random(); double d = (double) generator.nextInt(maxValue) + generator.nextDouble(); BigDecimal decimal = new BigDecimal(d); BigDecimal result = decimal.setScale(scale, RoundingMode.FLOOR); return result; |
BigDecimal | getRandomPriceChangeFactor(BigDecimal currentPrice) get Random Price Change Factor if (currentPrice.compareTo(PENNY_STOCK_P) == -1 || currentPrice.compareTo(PENNY_STOCK_P) == 0) { return JUNK_STOCK_MIRACLE_MULTIPLIER; } else if (currentPrice.compareTo(STOCK_P_HIGH_BAR) == 1 || currentPrice.compareTo(STOCK_P_HIGH_BAR) == 0) { return STOCK_P_HIGH_BAR_CRASH; BigDecimal factor = BigDecimal.valueOf(0); Random rand = new Random(); int y = rand.nextInt(STOCK_CHANGE_MAX_PERCENT.subtract(BigDecimal.ONE).intValue()); ... |
int | getRecordSize(List
get Record Size if (columnBaseData == null || columnBaseData.size() == 0) { return 0; if (columnBaseData.get(0) == null) { return 0; return columnBaseData.get(0).size(); |
double | getRSBigDecimal(Object object) getRSBigDecimal, get fields value from a object if (object == null) return (double) 0; return ((BigDecimal) object).doubleValue(); |
int | getScale(BigDecimal bd1, BigDecimal bd2) get Scale int scale1 = 0; int scale2 = 0; if (bd1 != null) { scale1 = bd1.scale(); if (bd2 != null) { scale2 = bd2.scale(); return (scale1 > scale2 ? scale1 : scale2); |