Skip to content

Commit

Permalink
Fix reversed ordering in altcoin market
Browse files Browse the repository at this point in the history
  • Loading branch information
dmos62 committed May 25, 2020
1 parent 2b797da commit 3dc13b6
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,14 @@ private void updateChartData() {

// Offer price can be null (if price feed unavailable), thus a null-tolerant comparator is used.
Comparator<Offer> offerPriceComparator = Comparator.comparing(Offer::getPrice, Comparator.nullsLast(Comparator.naturalOrder()));

// Trading btc-fiat is considered as buying/selling BTC, but trading btc-altcoin is
// considered as buying/selling Altcoin. Because of this, when viewing a btc-altcoin pair,
// the buy column is actually the sell column and vice versa. To maintain the expected
// ordering, we have to reverse the price comparator.
boolean isCrypto = CurrencyUtil.isCryptoCurrency(getCurrencyCode());
if (isCrypto) offerPriceComparator = offerPriceComparator.reversed();

// Offer amounts are used for the secondary sort. They are sorted from high to low.
Comparator<Offer> offerAmountComparator = Comparator.comparing(Offer::getAmount).reversed();

Expand Down

0 comments on commit 3dc13b6

Please sign in to comment.