mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-11-05 11:56:37 +00:00
restore coingecko historical rate support by limiting to the last 365 days
This commit is contained in:
parent
fa10714844
commit
c7e9a0a161
1 changed files with 6 additions and 1 deletions
|
|
@ -124,7 +124,7 @@ public enum ExchangeSource {
|
||||||
return historicalRates;
|
return historicalRates;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
COINGECKO("Coingecko", "No historical rates") {
|
COINGECKO("Coingecko", "Historical rates for the last 365 days") {
|
||||||
@Override
|
@Override
|
||||||
public List<Currency> getSupportedCurrencies() {
|
public List<Currency> getSupportedCurrencies() {
|
||||||
return getRates().rates.entrySet().stream().filter(rate -> "fiat".equals(rate.getValue().type) && isValidISO4217Code(rate.getKey().toUpperCase(Locale.ROOT)))
|
return getRates().rates.entrySet().stream().filter(rate -> "fiat".equals(rate.getValue().type) && isValidISO4217Code(rate.getKey().toUpperCase(Locale.ROOT)))
|
||||||
|
|
@ -167,6 +167,11 @@ public enum ExchangeSource {
|
||||||
long startDate = start.getTime() / 1000;
|
long startDate = start.getTime() / 1000;
|
||||||
long endDate = end.getTime() / 1000;
|
long endDate = end.getTime() / 1000;
|
||||||
|
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.add(Calendar.YEAR, -1);
|
||||||
|
startDate = Math.max(cal.getTimeInMillis() / 1000, startDate);
|
||||||
|
endDate = Math.max(cal.getTimeInMillis() / 1000, endDate);
|
||||||
|
|
||||||
String url = "https://api.coingecko.com/api/v3/coins/bitcoin/market_chart/range?vs_currency=" + currency.getCurrencyCode() + "&from=" + startDate + "&to=" + endDate;
|
String url = "https://api.coingecko.com/api/v3/coins/bitcoin/market_chart/range?vs_currency=" + currency.getCurrencyCode() + "&from=" + startDate + "&to=" + endDate;
|
||||||
|
|
||||||
if(log.isInfoEnabled()) {
|
if(log.isInfoEnabled()) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue