I am trying to pull hourly data using the below code . But I am noticing that it always gives me only first 25 records , thought I am trying to pull last 100 hrs it gives me only for first 25 hours
This is expected (partially) behavior. See the Paging section of the documentation.
The SDK returns only first page of data and you have to re-request the rest using the NextPageToken property of response and original request parameters. You can do it manually in the 'whileloop or useGetHistoricalBarsAsAsyncEnumerableorGetHistoricalBarsPagesAsAsyncEnumerable` extension methods from the Alpaca.Markets.Extensions package.
I strongly recommend you the second approach but if you prefer to understand what happened under the hood of these methods see the next snippet:
var startTime = new DateTime(2021, 7, 21, 0, 0, 0, DateTimeKind.Utc);
var endTime = DateTime.UtcNow;
var bars = new List<IBar>();
var request = new HistoricalBarsRequest(
"AAPL", startTime, endTime, BarTimeFrame.Hour);
do
{
var page = await client.ListHistoricalBarsAsync(request);
bars.AddRange(page.Items);
Console.WriteLine(page.Items.Count);
request.WithPageToken(page.NextPageToken);
} while (request.Pagination.Token is not null);
Console.WriteLine();
Console.WriteLine(bars.Count);