Remove filter for offerbook teaser tables

This commit is contained in:
Christoph Atteneder 2019-01-24 19:48:37 +01:00
parent e847a863c9
commit ee55aa3e09
No known key found for this signature in database
GPG key ID: CD5DC1C529CDFD3B

View file

@ -297,8 +297,6 @@ class OfferBookChartViewModel extends ActivatableViewModel {
})
.collect(Collectors.toList());
allBuyOffers = filterOffersWithRelevantPrices(allBuyOffers);
final Optional<Offer> highestBuyPriceOffer = allBuyOffers.stream()
.filter(o -> o.getPrice() != null)
.max(Comparator.comparingLong(o -> o.getPrice().getValue()));
@ -339,8 +337,6 @@ class OfferBookChartViewModel extends ActivatableViewModel {
})
.collect(Collectors.toList());
allSellOffers = filterOffersWithRelevantPrices(allSellOffers);
final Optional<Offer> highestSellPriceOffer = allSellOffers.stream()
.filter(o -> o.getPrice() != null)
.max(Comparator.comparingLong(o -> o.getPrice().getValue()));
@ -362,26 +358,6 @@ class OfferBookChartViewModel extends ActivatableViewModel {
buildChartAndTableEntries(allSellOffers, OfferPayload.Direction.SELL, sellData, topSellOfferList);
}
// If there are more then 3 offers we ignore the offers which are further than 30% from the best price
private List<Offer> filterOffersWithRelevantPrices(List<Offer> offers) {
if (offers.size() > 3) {
Price bestPrice = offers.get(0).getPrice();
if (bestPrice != null) {
long bestPriceAsLong = bestPrice.getValue();
return offers.stream()
.filter(e -> {
if (e.getPrice() == null)
return false;
double ratio = (double) e.getPrice().getValue() / (double) bestPriceAsLong;
return Math.abs(1 - ratio) < 0.3;
})
.collect(Collectors.toList());
}
}
return offers;
}
private void buildChartAndTableEntries(List<Offer> sortedList, OfferPayload.Direction direction, List<XYChart.Data> data, ObservableList<OfferListItem> offerTableList) {
data.clear();
double accumulatedAmount = 0;