Historical intraday volume specific data

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', 
                      '5Min', 
                      start='2020-10-21T10:45:00-04:00', 
                      end='2020-10-21T10:45:00-04:00',
                     )
# 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', 
                            multiplier=5, 
                            timespan='minute', 
                            _from='2020-10-21T10:45:00-04:00', 
                            to='2020-10-21T10:45:00-04:00')

# 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