mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 11:39:29 +00:00
pricenode: remove provider huobi and leftover coinpaprika
This commit is contained in:
parent
8035162502
commit
8d63b89d5c
3 changed files with 0 additions and 184 deletions
|
@ -1,102 +0,0 @@
|
|||
/*
|
||||
* This file is part of Haveno.
|
||||
*
|
||||
* Haveno is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Haveno is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Haveno. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.price.spot.providers;
|
||||
|
||||
import bisq.price.spot.ExchangeRate;
|
||||
import bisq.price.spot.ExchangeRateProvider;
|
||||
import bisq.price.util.coinpaprika.CoinpaprikaMarketData;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
class Coinpaprika extends ExchangeRateProvider {
|
||||
|
||||
private final RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
/**
|
||||
* Used to determine the currencies in which the BTC price can be quoted. There seems
|
||||
* to be no programatic way to retrieve it, so we get the value from the API
|
||||
* documentation (see "quotes" param decsribed at
|
||||
* https://api.coinpaprika.com/#operation/getTickersById ). The hardcoded value below
|
||||
* is the list of allowed values as per the API documentation, but without BTC and ETH
|
||||
* as it makes no sense to quote the BTC price in them.
|
||||
*/
|
||||
private final static String SUPPORTED_CURRENCIES =
|
||||
("USD, EUR, PLN, KRW, GBP, CAD, JPY, RUB, TRY, NZD, AUD, CHF, UAH, HKD, " +
|
||||
"SGD, NGN, PHP, MXN, BRL, THB, CLP, CNY, CZK, DKK, HUF, IDR, ILS," +
|
||||
"INR, MYR, NOK, PKR, SEK, TWD, ZAR, VND, BOB, COP, PEN, ARS, ISK")
|
||||
.replace(" ", ""); // Strip any spaces
|
||||
|
||||
public Coinpaprika(Environment env) {
|
||||
super(env, "COINPAPRIKA", "coinpaprika", Duration.ofMinutes(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ExchangeRate> doGet() {
|
||||
|
||||
// Single IP address can send less than 10 requests per second
|
||||
// We make only 1 API call per provider poll, so we're not at risk of reaching it
|
||||
|
||||
Set<ExchangeRate> result = new HashSet<ExchangeRate>();
|
||||
|
||||
Predicate<Map.Entry> isDesiredFiatPair = t -> getSupportedFiatCurrencies().contains(t.getKey());
|
||||
|
||||
getMarketData().getQuotes().entrySet().stream()
|
||||
.filter(isDesiredFiatPair)
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))
|
||||
.forEach((key, ticker) -> {
|
||||
|
||||
result.add(new ExchangeRate(
|
||||
key,
|
||||
ticker.getPrice(),
|
||||
new Date(),
|
||||
this.getName()
|
||||
));
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private CoinpaprikaMarketData getMarketData() {
|
||||
return restTemplate.exchange(
|
||||
RequestEntity
|
||||
.get(UriComponentsBuilder
|
||||
.fromUriString(
|
||||
"https://api.coinpaprika.com/v1/tickers/btc-bitcoin?quotes=" +
|
||||
SUPPORTED_CURRENCIES).build()
|
||||
.toUri())
|
||||
.build(),
|
||||
new ParameterizedTypeReference<CoinpaprikaMarketData>() {
|
||||
}
|
||||
).getBody();
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* This file is part of Haveno.
|
||||
*
|
||||
* Haveno is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Haveno is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Haveno. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.price.spot.providers;
|
||||
|
||||
import bisq.price.spot.ExchangeRate;
|
||||
import bisq.price.spot.ExchangeRateProvider;
|
||||
|
||||
import org.knowm.xchange.huobi.HuobiExchange;
|
||||
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
class Huobi extends ExchangeRateProvider {
|
||||
|
||||
public Huobi(Environment env) {
|
||||
super(env, "HUOBI", "huobi", Duration.ofMinutes(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ExchangeRate> doGet() {
|
||||
// Supported fiat: -
|
||||
// Supported alts: BTM, DASH, DCR, DOGE, ETC, ETH, FAIR, LTC, XMR, XZC, ZEC, ZEN
|
||||
return doGet(HuobiExchange.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* This file is part of Haveno.
|
||||
*
|
||||
* Haveno is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Haveno is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Haveno. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.price.spot.providers;
|
||||
|
||||
import bisq.price.AbstractExchangeRateProviderTest;
|
||||
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Slf4j
|
||||
public class HuobiTest extends AbstractExchangeRateProviderTest {
|
||||
|
||||
@Test
|
||||
public void doGet_successfulCall() {
|
||||
doGet_successfulCall(new Huobi(new StandardEnvironment()));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue