Is there a pagination option in python sdk?

I am trying to download some historical trades data for a stock (e.g. TSLA) for one or more days. Even per minute data has several thousand entries. Is it possible to request only few thousand entries per response using python SDK but get the entire day’s data with a single request?


@AmarDes The python alpaca-py SDK takes care of the pagination for you. There isn’t any way to set the trades per call, but simply put in a start datetime and an end datetime and it will do the rest. It may take awhile and can use a bit of memory. For example, there were 2,583,040 trades in the following query. It took me about 400 seconds to download.

trades = client.get_stock_trades(StockTradesRequest(
                                     start=pd.to_datetime('2023-09-05 00:00:00').tz_localize('America/New_York'),
                                     end=pd.to_datetime('2023-09-07 00:00:00').tz_localize('America/New_York')
1 Like