From e9e6e0097a7c09d12e4b1d0dbe51600ec3bbcd13 Mon Sep 17 00:00:00 2001 From: Andreas Buchen Date: Sat, 15 Apr 2023 08:27:48 +0200 Subject: [PATCH] Update AlphaVantage to use the non-premium endpoint to read historical prices Issue: #3275 --- .../portfolio/online/impl/AlphavantageQuoteFeed.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/online/impl/AlphavantageQuoteFeed.java b/name.abuchen.portfolio/src/name/abuchen/portfolio/online/impl/AlphavantageQuoteFeed.java index 094b7f444e..3c54e90051 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/online/impl/AlphavantageQuoteFeed.java +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/online/impl/AlphavantageQuoteFeed.java @@ -189,7 +189,7 @@ private QuoteFeedData getHistoricalQuotes(Security security, boolean collectRawR { @SuppressWarnings("nls") WebAccess webaccess = new WebAccess("www.alphavantage.co", "/query") // - .addParameter("function", "TIME_SERIES_DAILY") // + .addParameter("function", "TIME_SERIES_DAILY_ADJUSTED") // .addParameter("symbol", security.getTickerSymbol()) // .addParameter("apikey", apiKey) // .addParameter("datatype", "csv") // @@ -204,7 +204,8 @@ private QuoteFeedData getHistoricalQuotes(Security security, boolean collectRawR return data; // poor man's check - if (!"timestamp,open,high,low,close,volume".equals(lines[0])) //$NON-NLS-1$ + if (!"timestamp,open,high,low,close,adjusted_close,volume,dividend_amount,split_coefficient" //$NON-NLS-1$ + .equals(lines[0])) { data.addError(new IOException(MessageFormat.format(Messages.MsgUnexpectedHeader, html))); return data; @@ -217,7 +218,7 @@ private QuoteFeedData getHistoricalQuotes(Security security, boolean collectRawR String line = lines[ii]; String[] values = line.split(","); //$NON-NLS-1$ - if (values.length != 6) + if (values.length != 9) throw new IOException(MessageFormat.format(Messages.MsgUnexpectedValue, line)); LatestSecurityPrice price = new LatestSecurityPrice(); @@ -230,7 +231,7 @@ private QuoteFeedData getHistoricalQuotes(Security security, boolean collectRawR price.setHigh(asPrice(values[2])); price.setLow(asPrice(values[3])); - price.setVolume(Long.parseLong(values[5])); + price.setVolume(Long.parseLong(values[6])); if (price.getValue() != 0) data.addPrice(price);