diff --git a/src/main/java/bisq/price/spot/ArsBlueRateTransformer.java b/src/main/java/bisq/price/spot/ArsBlueRateTransformer.java index 5923256..5d6b2f9 100644 --- a/src/main/java/bisq/price/spot/ArsBlueRateTransformer.java +++ b/src/main/java/bisq/price/spot/ArsBlueRateTransformer.java @@ -19,12 +19,14 @@ import bisq.price.spot.providers.BlueRateProvider; import bisq.price.util.bluelytics.ArsBlueMarketGapProvider; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.util.Optional; import java.util.OptionalDouble; @Component +@Slf4j public class ArsBlueRateTransformer implements ExchangeRateTransformer { private final ArsBlueMarketGapProvider blueMarketGapProvider; @@ -51,6 +53,10 @@ public Optional apply(ExchangeRateProvider provider, ExchangeRate originalExchangeRate.getTimestamp(), originalExchangeRate.getProvider() ); + + log.info(String.format("%s transformed from %s to %s", + originalExchangeRate.getCurrency(), originalExchangeRate.getPrice(), blueRate)); + return Optional.of(newExchangeRate); } diff --git a/src/main/java/bisq/price/spot/ExchangeRateService.java b/src/main/java/bisq/price/spot/ExchangeRateService.java index ca9b2b8..04d3c91 100644 --- a/src/main/java/bisq/price/spot/ExchangeRateService.java +++ b/src/main/java/bisq/price/spot/ExchangeRateService.java @@ -175,7 +175,7 @@ private Map> getCurrencyCodeToExchangeRates() { for (ExchangeRate exchangeRate : exchangeRates) { String currencyCode = exchangeRate.getCurrency(); - List transformedExchangeRates = transformers.stream() + List finalExchangeRates = transformers.stream() .filter(transformer -> transformer.supportedCurrency() .equalsIgnoreCase(currencyCode) ) @@ -184,23 +184,19 @@ private Map> getCurrencyCodeToExchangeRates() { .map(Optional::get) .collect(Collectors.toList()); - if (!transformedExchangeRates.isEmpty()) { - log.info(String.format("%s transformed from %s to %s", currencyCode, exchangeRate.getPrice(), transformedExchangeRates.get(0).getPrice())); - } - if (currencyCodeToExchangeRates.containsKey(currencyCode)) { List l = new ArrayList<>(currencyCodeToExchangeRates.get(currencyCode)); - if (transformedExchangeRates.isEmpty()) { + if (finalExchangeRates.isEmpty()) { l.add(exchangeRate); } else { - l.addAll(transformedExchangeRates); + l.addAll(finalExchangeRates); } currencyCodeToExchangeRates.put(currencyCode, l); } else { - if (transformedExchangeRates.isEmpty()) { + if (finalExchangeRates.isEmpty()) { currencyCodeToExchangeRates.put(currencyCode, List.of(exchangeRate)); } else { - currencyCodeToExchangeRates.put(currencyCode, transformedExchangeRates); + currencyCodeToExchangeRates.put(currencyCode, finalExchangeRates); } } } diff --git a/src/main/java/bisq/price/spot/providers/Binance.java b/src/main/java/bisq/price/spot/providers/Binance.java index d630b80..74ef241 100644 --- a/src/main/java/bisq/price/spot/providers/Binance.java +++ b/src/main/java/bisq/price/spot/providers/Binance.java @@ -30,7 +30,7 @@ import java.util.Set; @Component -class Binance extends ExchangeRateProvider { +class Binance extends ExchangeRateProvider implements BlueRateProvider { public Binance(Environment env) { super(env, "BINANCE", "binance", Duration.ofMinutes(1));