Fix CLI gettrades' Deviation column value format (do nothing)

This commit is contained in:
ghubstan 2022-02-20 18:11:24 -03:00
parent 2febe6b327
commit 8f93c27deb
No known key found for this signature in database
GPG Key ID: E35592D6800A861E

View File

@ -20,8 +20,6 @@ package bisq.cli.table.builder;
import bisq.proto.grpc.ContractInfo;
import bisq.proto.grpc.TradeInfo;
import java.text.DecimalFormat;
import java.math.BigDecimal;
import java.math.RoundingMode;
@ -215,9 +213,10 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
? t.getOffer().getCounterCurrencyCode()
: t.getOffer().getBaseCurrencyCode();
protected final Function<TradeInfo, String> toPriceDeviation = (t) ->
t.getOffer().getUseMarketBasedPrice()
? formatToPercent(t.getOffer().getMarketPriceMarginPct())
? t.getOffer().getMarketPriceMarginPct() + "%"
: "N/A";
protected final Function<TradeInfo, Long> toMyMinerTxFee = (t) -> {
@ -307,19 +306,6 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder {
}
};
// TODO Move to bisq/cli/CurrencyFormat.java ?
public static String formatToPercent(double value) {
DecimalFormat decimalFormat = new DecimalFormat("#.##");
decimalFormat.setMinimumFractionDigits(2);
decimalFormat.setMaximumFractionDigits(2);
return formatToPercent(value, decimalFormat);
}
public static String formatToPercent(double value, DecimalFormat decimalFormat) {
return decimalFormat.format(roundDouble(value * 100.0, 2)).replace(",", ".") + "%";
}
public static double roundDouble(double value, int precision) {
return roundDouble(value, precision, RoundingMode.HALF_UP);
}