get_barset function returns a specified number of bars of data for a stock. The number of bars it returns is determined by the
limit parameter. If nothing is specified the default is 100 bars (ie
until parameters can be set to fetch data over specific time frames. If no timeframe is specified the default is to return the most recent bars. The bars are returned in ascending order. The first is the earliest date and the last is the most recent date. The data is not split or dividend adjusted. It is the actual trade data on that date.
So, the following will fetch a list of the 100 most recent trading days of data (the default) for AAPL. The first bar in the list (ie datadata[‘AAPL’]) will be the earliest data from 100 trading days ago. The last bar (ie datadata[‘AAPL’][-1]) will be the most recent data. The data is not split or dividend adjusted.
data = api.get_barset('AAPL', 'day',)
It’s often easier to turn the result into a dataframe. This can be done easily with the
df method like this.
data_df = data.df
The result is the following dataframe
A couple things to note. The last row is the most recent data and it does indeed match the current close price of 118.64 in the chart (apparently from Yahoo). The first row (100 trading days ago) is 2020-7-7 data. AAPL indeed had a close price of 364.01 on that date. The chart data appears different because it reflects split adjusted prices. AAPL had a 4:1 stock split on 2020-8-28. This makes the chart data appear to have prices which are all 1/4 the actual prices before that split.
So, to get the most recent data look at the last bar, and remember that previous bars are not split or dividend adjusted (which may make them appear different from other sources if they adjust their data).