/** * Returns a copy of this monetary value with a collection of monetary amounts subtracted. * <p> * This subtracts the specified amounts from this monetary amount, returning a new object. * The amounts must be in the same currency. * <p> * This instance is immutable and unaffected by this method. * * @param moniesToSubtract the monetary values to subtract, no null elements, not null * @return the new instance with the input amounts subtracted, never null * @throws CurrencyMismatchException if the currencies differ */ public Money minus(Iterable<Money> moniesToSubtract) { return with(money.minus(moniesToSubtract)); }
/** * Subtracts the second {@code BigMoney} from the first, handling null. * <p> * This returns {@code money1 - money2} where null is ignored. * If both input values are null, then null is returned. * * @param money1 the first money instance, null treated as zero * @param money2 the first money instance, null returns money1 * @return the total, where null is ignored, null if both inputs are null * @throws CurrencyMismatchException if the currencies differ */ public static BigMoney subtract(BigMoney money1, BigMoney money2) { if (money2 == null) { return money1; } if (money1 == null) { return money2.negated(); } return money1.minus(money2); }
/** * Returns a copy of this monetary value with the amount subtracted. * <p> * This subtracts the specified amount from this monetary amount, returning a new object. * The amount subtracted must be in the same currency. * <p> * The subtraction has no rounding issues and is always accurate. * For example,'USD 25.95' minus 'USD 3.02' will 'USD 22.93'. * <p> * This instance is immutable and unaffected by this method. * * @param moneyToSubtract the monetary value to subtract, not null * @return the new instance with the input amount subtracted, never null * @throws CurrencyMismatchException if the currencies differ */ public Money minus(Money moneyToSubtract) { return with(money.minus(moneyToSubtract)); }
/** * Returns a copy of this monetary value with the amount subtracted. * <p> * This subtracts the specified amount from this monetary amount, returning a new object. * The amount subtracted must be in the same currency. * <p> * No precision is lost in the result. * The scale of the result will be the maximum of the two scales. * For example,'USD 25.95' minus 'USD 3.021' gives 'USD 22.929'. * <p> * This instance is immutable and unaffected by this method. * * @param moneyToSubtract the monetary value to subtract, not null * @return the new instance with the input amount subtracted, never null * @throws CurrencyMismatchException if the currencies differ */ public BigMoney minus(BigMoneyProvider moneyToSubtract) { BigMoney toSubtract = checkCurrencyEqual(moneyToSubtract); return minus(toSubtract.getAmount()); }
BigMoney macdShort = observer.getShortMACD(); BigMoney macdSigLine = observer.getSigLineMACD(); BigMoney macdLine = macdShort.minus(macdLong);
profitBTC = equivBTCEndBal.minus(equivBTCStartBal); profitPercent = profitBTC.getAmount().divide(equivBTCStartBal.getAmount(),16,RoundingMode.HALF_EVEN); String profitToDisplay = percentFormat.format(profitPercent);