Historical intraday volume specific data

Hi all,
Is there a way to get the specific 5 minute volume total for a specific stock at a specific time? For example AAPL 10/21 10:45am?

If so, could you point me in the right direction in the documentation? I’ve looked but could only see daily volume.


Yes, one can get specific 5 minute volume data a couple of ways. The first is using the Alpaca API which uses IEX (Investors Exchange LLC) data. The second is using Polygon data. There is information on the differences in the docs. Basically, IEX data is available to all Alpaca users but doesn’t include trades from all exchanges (so volume, for example, may be less than the total traded across all exchanges/venues). Polygon data is aggregated across all exchanges but one needs a live account to access the data.

The info on the low level API for IEX data is here and the Polygon data is here.

Alpaca includes ‘wrappers’ making it easier to use the low level API. The Python version can be found (and imported) here. I find the best way to see how to use a specific method is to look at the actual code. In this case, to fetch IEX data using python, one uses the get_barset method. The code showing how to use this method is here. If one wants to use Polygon data then use the historic_trades_v2 method. There’s info on that here.

So, as an example, in Python the code to get 5 minute volume for AAPL on 10/21/2020 at 10:45am would look like this

data = api.get_barset('AAPL', 
# Turn the data into a dataframe for easier manipulation
data_df = data.df

# Get just the volume data for AAPL
aapl_volume = data_df['AAPL'].volume

The Polygon data can be fetched like this

poly_data = api.polygon.historic_agg_v2(symbol= 'AAPL', 

# Turn the data into a dataframe for easier manipulation
poly_data_df = poly_data.df

# Polygon data can't be specified to the minute (even though it's given as a parameter)
# It will return the entire days data.
# So one needs to fetch just the time on wants from the dataframe
aapl_volume = poly_data_df.between_time('10:45', '10:45').volume

Hope that starts you in the right direction. Good luck.

1 Like

This is not working…
It seems my Alpaca API key is being passed to Polygon API for those API calls.

Given the Polygon is the only way to get historical data with adjusted prices, this makes long term price analysis impossible.

1 Like