Skip to content

Commit

Permalink
Revert "Update AlphaVantage to use the non-premium endpoint to read h…
Browse files Browse the repository at this point in the history
…istorical prices"

This reverts commit e9e6e00.

Closes #3605
  • Loading branch information
eztam- authored and buchen committed Nov 9, 2024
1 parent c61d5c0 commit d011771
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private QuoteFeedData getHistoricalQuotes(Security security, boolean collectRawR
{
@SuppressWarnings("nls")
WebAccess webaccess = new WebAccess("www.alphavantage.co", "/query") //
.addParameter("function", "TIME_SERIES_DAILY_ADJUSTED") //
.addParameter("function", "TIME_SERIES_DAILY") //
.addParameter("symbol", security.getTickerSymbol()) //
.addParameter("apikey", apiKey) //
.addParameter("datatype", "csv") //
Expand All @@ -208,8 +208,7 @@ private QuoteFeedData getHistoricalQuotes(Security security, boolean collectRawR
return data;

// poor man's check
if (!"timestamp,open,high,low,close,adjusted_close,volume,dividend_amount,split_coefficient" //$NON-NLS-1$
.equals(lines[0]))
if (!"timestamp,open,high,low,close,volume".equals(lines[0])) //$NON-NLS-1$
{
data.addError(new IOException(MessageFormat.format(Messages.MsgUnexpectedHeader, html)));
return data;
Expand All @@ -222,7 +221,7 @@ private QuoteFeedData getHistoricalQuotes(Security security, boolean collectRawR
String line = lines[ii];

String[] values = line.split(","); //$NON-NLS-1$
if (values.length != 9)
if (values.length != 6)
throw new IOException(MessageFormat.format(Messages.MsgUnexpectedValue, line));

LatestSecurityPrice price = new LatestSecurityPrice();
Expand All @@ -235,7 +234,7 @@ private QuoteFeedData getHistoricalQuotes(Security security, boolean collectRawR

price.setHigh(asPrice(values[2]));
price.setLow(asPrice(values[3]));
price.setVolume(Long.parseLong(values[6]));
price.setVolume(Long.parseLong(values[5]));

if (price.getValue() != 0)
data.addPrice(price);
Expand Down

0 comments on commit d011771

Please sign in to comment.