mirror of
https://github.com/bisq-network/bisq.git
synced 2025-01-19 05:44:05 +01:00
Format gettrades CLI outout
This commit is contained in:
parent
d98d795c77
commit
4c7ae49e18
@ -0,0 +1,61 @@
|
||||
package bisq.cli.table.builder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static bisq.cli.table.builder.TableType.CLOSED_TRADES_TBL;
|
||||
|
||||
|
||||
|
||||
import bisq.cli.table.Table;
|
||||
import bisq.cli.table.column.MixedPriceColumn;
|
||||
|
||||
class ClosedTradeTableBuilder extends AbstractTradeListBuilder {
|
||||
|
||||
ClosedTradeTableBuilder(List<?> protos) {
|
||||
super(CLOSED_TRADES_TBL, protos);
|
||||
}
|
||||
|
||||
public Table build() {
|
||||
populateColumns();
|
||||
return new Table(colTradeId,
|
||||
colCreateDate.asStringColumn(),
|
||||
colMarket,
|
||||
colPrice.asStringColumn(),
|
||||
colPriceDeviation.justify(),
|
||||
colAmountInBtc.asStringColumn(),
|
||||
colMixedAmount.asStringColumn(),
|
||||
colCurrency,
|
||||
colMinerTxFee.asStringColumn(),
|
||||
colMixedTradeFee.asStringColumn(),
|
||||
colBuyerDeposit.asStringColumn(),
|
||||
colSellerDeposit.asStringColumn(),
|
||||
colOfferType,
|
||||
colStatusDescription);
|
||||
}
|
||||
|
||||
private void populateColumns() {
|
||||
trades.stream().forEachOrdered(t -> {
|
||||
colTradeId.addRow(t.getTradeId());
|
||||
colCreateDate.addRow(t.getDate());
|
||||
colMarket.addRow(toMarket.apply(t));
|
||||
((MixedPriceColumn) colPrice).addRow(t.getTradePrice(), isFiatTrade.test(t));
|
||||
colPriceDeviation.addRow(toPriceDeviation.apply(t));
|
||||
colAmountInBtc.addRow(t.getTradeAmountAsLong());
|
||||
colMixedAmount.addRow(t.getTradeVolume(), toDisplayedVolumePrecision.apply(t));
|
||||
colCurrency.addRow(toPaymentCurrencyCode.apply(t));
|
||||
colMinerTxFee.addRow(toMyMinerTxFee.apply(t));
|
||||
|
||||
long tradeFeeBsq = toTradeFeeBsq.apply(t, true);
|
||||
long tradeFeeBtc = toTradeFeeBtc.apply(t, true);
|
||||
if (tradeFeeBsq > 0)
|
||||
colMixedTradeFee.addRow(tradeFeeBsq, true);
|
||||
else
|
||||
colMixedTradeFee.addRow(tradeFeeBtc, false);
|
||||
|
||||
colBuyerDeposit.addRow(t.getBuyerDeposit());
|
||||
colSellerDeposit.addRow(t.getSellerDeposit());
|
||||
colOfferType.addRow(toOfferType.apply(t));
|
||||
colStatusDescription.addRow(t.getStatusDescription());
|
||||
});
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ package bisq.cli.table.builder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static bisq.cli.table.builder.TableType.FAILED_TRADE_TBL;
|
||||
import static bisq.cli.table.builder.TableType.FAILED_TRADES_TBL;
|
||||
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ import bisq.cli.table.column.MixedPriceColumn;
|
||||
class FailedTradeTableBuilder extends AbstractTradeListBuilder {
|
||||
|
||||
FailedTradeTableBuilder(List<?> protos) {
|
||||
super(FAILED_TRADE_TBL, protos);
|
||||
super(FAILED_TRADES_TBL, protos);
|
||||
}
|
||||
|
||||
public Table build() {
|
||||
|
@ -2,7 +2,7 @@ package bisq.cli.table.builder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static bisq.cli.table.builder.TableType.OPEN_TRADE_TBL;
|
||||
import static bisq.cli.table.builder.TableType.OPEN_TRADES_TBL;
|
||||
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ import bisq.cli.table.column.MixedPriceColumn;
|
||||
class OpenTradeTableBuilder extends AbstractTradeListBuilder {
|
||||
|
||||
OpenTradeTableBuilder(List<?> protos) {
|
||||
super(OPEN_TRADE_TBL, protos);
|
||||
super(OPEN_TRADES_TBL, protos);
|
||||
}
|
||||
|
||||
public Table build() {
|
||||
|
@ -49,14 +49,14 @@ public class TableBuilder extends AbstractTableBuilder {
|
||||
return new BsqBalanceTableBuilder(protos).build();
|
||||
case BTC_BALANCE_TBL:
|
||||
return new BtcBalanceTableBuilder(protos).build();
|
||||
case CLOSED_TRADE_TBL:
|
||||
throw new UnsupportedOperationException("TODO return new ClosedTradeTableBuilder(protos).build()");
|
||||
case FAILED_TRADE_TBL:
|
||||
throw new UnsupportedOperationException("TODO return new FailedTradeTableBuilder(protos).build()");
|
||||
case CLOSED_TRADES_TBL:
|
||||
return new ClosedTradeTableBuilder(protos).build();
|
||||
case FAILED_TRADES_TBL:
|
||||
return new FailedTradeTableBuilder(protos).build();
|
||||
case OFFER_TBL:
|
||||
return new OfferTableBuilder(protos).build();
|
||||
case OPEN_TRADE_TBL:
|
||||
throw new UnsupportedOperationException("TODO return new OpenTradeTableBuilder(protos).build()");
|
||||
case OPEN_TRADES_TBL:
|
||||
return new OpenTradeTableBuilder(protos).build();
|
||||
case PAYMENT_ACCOUNT_TBL:
|
||||
return new PaymentAccountTableBuilder(protos).build();
|
||||
case TRADE_DETAIL_TBL:
|
||||
|
@ -25,10 +25,10 @@ public enum TableType {
|
||||
ADDRESS_BALANCE_TBL,
|
||||
BSQ_BALANCE_TBL,
|
||||
BTC_BALANCE_TBL,
|
||||
CLOSED_TRADE_TBL,
|
||||
FAILED_TRADE_TBL,
|
||||
CLOSED_TRADES_TBL,
|
||||
FAILED_TRADES_TBL,
|
||||
OFFER_TBL,
|
||||
OPEN_TRADE_TBL,
|
||||
OPEN_TRADES_TBL,
|
||||
PAYMENT_ACCOUNT_TBL,
|
||||
TRADE_DETAIL_TBL,
|
||||
TRANSACTION_TBL
|
||||
|
@ -32,9 +32,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static bisq.cli.table.builder.TableBuilderConstants.*;
|
||||
import static bisq.cli.table.builder.TableType.CLOSED_TRADE_TBL;
|
||||
import static bisq.cli.table.builder.TableType.FAILED_TRADE_TBL;
|
||||
import static bisq.cli.table.builder.TableType.OPEN_TRADE_TBL;
|
||||
import static bisq.cli.table.builder.TableType.CLOSED_TRADES_TBL;
|
||||
import static bisq.cli.table.builder.TableType.FAILED_TRADES_TBL;
|
||||
import static bisq.cli.table.builder.TableType.OPEN_TRADES_TBL;
|
||||
import static bisq.cli.table.builder.TableType.TRADE_DETAIL_TBL;
|
||||
import static bisq.cli.table.column.AltcoinColumn.DISPLAY_MODE.ALTCOIN_OFFER_VOLUME;
|
||||
import static bisq.cli.table.column.Column.JUSTIFICATION.LEFT;
|
||||
@ -75,9 +75,9 @@ class TradeTableColumnSupplier {
|
||||
}
|
||||
|
||||
private final Supplier<Boolean> isTradeDetailTblBuilder = () -> getTableType().equals(TRADE_DETAIL_TBL);
|
||||
private final Supplier<Boolean> isOpenTradeTblBuilder = () -> getTableType().equals(OPEN_TRADE_TBL);
|
||||
private final Supplier<Boolean> isClosedTradeTblBuilder = () -> getTableType().equals(CLOSED_TRADE_TBL);
|
||||
private final Supplier<Boolean> isFailedTradeTblBuilder = () -> getTableType().equals(FAILED_TRADE_TBL);
|
||||
private final Supplier<Boolean> isOpenTradeTblBuilder = () -> getTableType().equals(OPEN_TRADES_TBL);
|
||||
private final Supplier<Boolean> isClosedTradeTblBuilder = () -> getTableType().equals(CLOSED_TRADES_TBL);
|
||||
private final Supplier<Boolean> isFailedTradeTblBuilder = () -> getTableType().equals(FAILED_TRADES_TBL);
|
||||
private final Supplier<TradeInfo> firstRow = () -> getTrades().get(0);
|
||||
private final Predicate<OfferInfo> isFiatOffer = (o) -> o.getBaseCurrencyCode().equals("BTC");
|
||||
private final Predicate<TradeInfo> isFiatTrade = (t) -> isFiatOffer.test(t.getOffer());
|
||||
|
Loading…
Reference in New Issue
Block a user