Skip to content

Commit

Permalink
Merge pull request #6227 from jmacxx/pricenode_config_provider_ccy_excl
Browse files Browse the repository at this point in the history
Pricenode: configurable exclusion by provider currency
  • Loading branch information
ripcurlx authored May 30, 2022
2 parents 0ced87c + 0310958 commit a0e73d7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public abstract class ExchangeRateProvider extends PriceProvider<Set<ExchangeRat

private static Set<String> SUPPORTED_CRYPTO_CURRENCIES = new HashSet<>();
private static Set<String> SUPPORTED_FIAT_CURRENCIES = new HashSet<>();
private Set<String> providerExclusionList = new HashSet<>();
private final String name;
private final String prefix;
private final Environment env;
Expand All @@ -73,6 +74,18 @@ public ExchangeRateProvider(Environment env, String name, String prefix, Duratio
this.name = name;
this.prefix = prefix;
this.env = env;
List<String> excludedByProvider =
Arrays.asList(env.getProperty("bisq.price.fiatcurrency.excludedByProvider", "")
.toUpperCase().trim().split("\\s*,\\s*"));
for (String s: excludedByProvider) {
String[] splits = s.split(":");
if (splits.length == 2 && splits[0].equalsIgnoreCase(name) && CurrencyUtil.isFiatCurrency(splits[1])) {
providerExclusionList.add(splits[1]);
}
}
if (providerExclusionList.size() > 0) {
log.info("{} specific exclusion list={}", name, providerExclusionList.toString());
}
}

public Set<String> getSupportedFiatCurrencies() {
Expand All @@ -91,7 +104,10 @@ public Set<String> getSupportedFiatCurrencies() {
log.info("fiat currencies excluded: {}", validatedExclusionList);
log.info("fiat currencies supported: {}", SUPPORTED_FIAT_CURRENCIES.size());
}
return SUPPORTED_FIAT_CURRENCIES;
// filter out any provider specific ccy exclusions
return SUPPORTED_FIAT_CURRENCIES.stream()
.filter(ccy -> !providerExclusionList.contains(ccy.toUpperCase()))
.collect(Collectors.toSet());
}

public Set<String> getSupportedCryptoCurrencies() {
Expand Down
46 changes: 0 additions & 46 deletions pricenode/src/main/java/bisq/price/spot/providers/Huobi.java

This file was deleted.

1 change: 1 addition & 0 deletions pricenode/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ bisq.price.mining.providers.mempoolHostname.3=mempool.ninja
bisq.price.mining.providers.mempoolHostname.4=mempool.bisq.services
# bisq.price.mining.providers.mempoolHostname.5=someHostOrIP
bisq.price.fiatcurrency.excluded=LBP,ARS
bisq.price.fiatcurrency.excludedByProvider=HUOBI:BRL
bisq.price.cryptocurrency.excluded=
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ public void getAllMarketPrices_withMultipleProviders_overlappingCurrencyCodes()
@Test
public void getAllMarketPrices_withMultipleProviders_excludedCurrencyCodes() {
String excludedCcyString = "LBP,USD,EUR";
String providerExcludedCcyString = "HUOBI:BRL,BINANCE:GBP,BINANCE:SEK";
Environment mockedEnvironment = mock(Environment.class);
when(mockedEnvironment.getProperty(eq("bisq.price.fiatcurrency.excluded"), anyString())).thenReturn(excludedCcyString);
when(mockedEnvironment.getProperty(eq("bisq.price.fiatcurrency.excludedByProvider"), anyString())).thenReturn(providerExcludedCcyString);

class MockedExchangeRateProvider extends ExchangeRateProvider {
MockedExchangeRateProvider() {
Expand Down
36 changes: 0 additions & 36 deletions pricenode/src/test/java/bisq/price/spot/providers/HuobiTest.java

This file was deleted.

0 comments on commit a0e73d7

Please sign in to comment.