mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Fix deviation in open portfolio offers & history.
This commit is contained in:
parent
175a0946e5
commit
7f4bde8669
@ -26,6 +26,7 @@ import bisq.core.offer.OpenOffer;
|
|||||||
import bisq.core.trade.model.Tradable;
|
import bisq.core.trade.model.Tradable;
|
||||||
import bisq.core.trade.model.bisq_v1.Trade;
|
import bisq.core.trade.model.bisq_v1.Trade;
|
||||||
import bisq.core.util.FormattingUtils;
|
import bisq.core.util.FormattingUtils;
|
||||||
|
import bisq.core.util.PriceUtil;
|
||||||
import bisq.core.util.coin.BsqFormatter;
|
import bisq.core.util.coin.BsqFormatter;
|
||||||
import bisq.core.util.coin.CoinFormatter;
|
import bisq.core.util.coin.CoinFormatter;
|
||||||
|
|
||||||
@ -49,7 +50,6 @@ import static bisq.core.trade.model.bisq_v1.Trade.DisputeState.DISPUTE_CLOSED;
|
|||||||
import static bisq.core.trade.model.bisq_v1.Trade.DisputeState.MEDIATION_CLOSED;
|
import static bisq.core.trade.model.bisq_v1.Trade.DisputeState.MEDIATION_CLOSED;
|
||||||
import static bisq.core.trade.model.bisq_v1.Trade.DisputeState.REFUND_REQUEST_CLOSED;
|
import static bisq.core.trade.model.bisq_v1.Trade.DisputeState.REFUND_REQUEST_CLOSED;
|
||||||
import static bisq.core.util.FormattingUtils.BTC_FORMATTER_KEY;
|
import static bisq.core.util.FormattingUtils.BTC_FORMATTER_KEY;
|
||||||
import static bisq.core.util.FormattingUtils.formatPercentagePrice;
|
|
||||||
import static bisq.core.util.FormattingUtils.formatToPercentWithSymbol;
|
import static bisq.core.util.FormattingUtils.formatToPercentWithSymbol;
|
||||||
import static bisq.core.util.VolumeUtil.formatVolume;
|
import static bisq.core.util.VolumeUtil.formatVolume;
|
||||||
import static bisq.core.util.VolumeUtil.formatVolumeWithCode;
|
import static bisq.core.util.VolumeUtil.formatVolumeWithCode;
|
||||||
@ -142,11 +142,9 @@ public class ClosedTradableFormatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getPriceDeviationAsString(Tradable tradable) {
|
public String getPriceDeviationAsString(Tradable tradable) {
|
||||||
if (tradable.getOffer().isUseMarketBasedPrice()) {
|
return PriceUtil.offerPercentageToDeviation(tradable.getOffer())
|
||||||
return formatPercentagePrice(tradable.getOffer().getMarketPriceMargin());
|
.map(FormattingUtils::formatPercentagePrice)
|
||||||
} else {
|
.orElse(Res.get("shared.na"));
|
||||||
return Res.get("shared.na");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVolumeAsString(Tradable tradable, boolean appendCode) {
|
public String getVolumeAsString(Tradable tradable, boolean appendCode) {
|
||||||
|
@ -129,6 +129,15 @@ public class PriceUtil {
|
|||||||
return bsq30DayAveragePrice;
|
return bsq30DayAveragePrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Optional<Double> offerPercentageToDeviation(Offer offer) {
|
||||||
|
if (offer.isUseMarketBasedPrice()) {
|
||||||
|
return Optional.of(offer.getDirection() == OfferDirection.SELL ?
|
||||||
|
offer.getMarketPriceMargin() : -offer.getMarketPriceMargin());
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasMarketPrice(Offer offer) {
|
public boolean hasMarketPrice(Offer offer) {
|
||||||
String currencyCode = offer.getCurrencyCode();
|
String currencyCode = offer.getCurrencyCode();
|
||||||
checkNotNull(priceFeedService, "priceFeed must not be null");
|
checkNotNull(priceFeedService, "priceFeed must not be null");
|
||||||
|
@ -85,12 +85,12 @@ class OpenOfferListItem implements FilterableListItem {
|
|||||||
|
|
||||||
public Double getPriceDeviationAsDouble() {
|
public Double getPriceDeviationAsDouble() {
|
||||||
Offer offer = getOffer();
|
Offer offer = getOffer();
|
||||||
return priceUtil.getMarketBasedPrice(offer, offer.getMirroredDirection()).orElse(0d);
|
return PriceUtil.offerPercentageToDeviation(offer).orElse(0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPriceDeviationAsString() {
|
public String getPriceDeviationAsString() {
|
||||||
Offer offer = getOffer();
|
Offer offer = getOffer();
|
||||||
return priceUtil.getMarketBasedPrice(offer, offer.getMirroredDirection())
|
return PriceUtil.offerPercentageToDeviation(offer)
|
||||||
.map(FormattingUtils::formatPercentagePrice)
|
.map(FormattingUtils::formatPercentagePrice)
|
||||||
.orElse("");
|
.orElse("");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user