From f9a1bc2aef3664a45ccb360abf561e724181e4b8 Mon Sep 17 00:00:00 2001 From: Andreas Buchen Date: Tue, 2 Apr 2024 21:23:09 +0200 Subject: [PATCH] Coingecko: Limit download of historical daily prices to 365 days The free API endpoint only allows up to 365 days now. Issue: #3896 Issue: https://forum.portfolio-performance.info/t/kryptowahrung-ckb-nervos-network-kurse-werden-nicht-dargestellt-coingecko/27981 --- .../abuchen/portfolio/online/impl/CoinGeckoQuoteFeed.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/online/impl/CoinGeckoQuoteFeed.java b/name.abuchen.portfolio/src/name/abuchen/portfolio/online/impl/CoinGeckoQuoteFeed.java index 113d4824ef..bff0f005e3 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/online/impl/CoinGeckoQuoteFeed.java +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/online/impl/CoinGeckoQuoteFeed.java @@ -227,7 +227,9 @@ private QuoteFeedData getHistoricalQuotes(Security security, boolean collectRawR coinGeckoId = getCoinGeckoIdForTicker(security.getTickerSymbol().toLowerCase()); String endpoint = "/api/v3/coins/" + coinGeckoId + "/market_chart"; //$NON-NLS-1$ //$NON-NLS-2$ - long days = ChronoUnit.DAYS.between(start, LocalDate.now()) + 1; + + // the free API only allows for 1 year of historical data (daily). + long days = Math.min(365, ChronoUnit.DAYS.between(start, LocalDate.now()) + 1); WebAccess webaccess = new WebAccess("api.coingecko.com", endpoint) //$NON-NLS-1$ .addParameter("vs_currency", security.getCurrencyCode()) //$NON-NLS-1$