crazzyghost / alphavantage-java

Fluent Java wrapper for Alpha Vantage API
MIT License
80 stars 35 forks source link

Stock Dividends & Adjusted Close don't work #7

Closed aoberai closed 4 years ago

aoberai commented 4 years ago

As can be seen in this example output, both dividend and adjusted close figures remain at 0 regardless of the stock. Is this happening just to me or others as well?

TimeSeriesResponse{metaData=MetaData{information='Monthly Prices (open, high, low, close) and Volumes', symbol='AAPL', lastRefreshed='2020-05-15', timeZone='null', interval='null', outputSize='null'}, stockUnits=[ StockUnit{open=286.25, high=319.688, low=285.85, close=307.71, adjustedClose=0.0, volume=436351291, dividendAmount=0.0, splitCoefficient=0.0, date=2020-05-15}, StockUnit{open=246.5, high=294.53, low=236.9, close=293.8, adjustedClose=0.0, volume=816530808, dividendAmount=0.0, splitCoefficient=0.0, date=2020-04-30}, StockUnit{open=282.28, high=304.0, low=212.61, close=254.29, adjustedClose=0.0, volume=1570331732, dividendAmount=0.0, splitCoefficient=0.0, date=2020-03-31},

crazzyghost commented 4 years ago

@aoberai those values are only set when the series you are fetching are "adjusted". The metadata output shows you are fetching monthly values (using the TIME_SERIES_MONTHLY function) not monthly adjusted values. The response pertaining to this call has only open, high, low, close and volume set. To get the adjusted values, call the adjusted() method. This will set the function to TIME_SERIES_MONTHLY_ADJUSTED in this case.

Alphavantage.api()
    .monthly()
    .adjusted()
    ...

https://crazzyghost.github.io/alphavantage-java/timeseries/#monthly-adjusted