You have to use the AlpacaDataClient class and GetBarSetAsync method. I’ll prepare PR for fixing documentation soon. Sorry for this inconvenience and best regards.
There is updated example for GetBarSetAsync method (still under review by Alpaca maintainers):
using Alpaca.Markets;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace CodeExamples
{
internal static class Example
{
private static string API_KEY = "your_api_key";
private static string API_SECRET = "your_secret_key";
public static async Task Main(string[] args)
{
// First, open the API connection
var client = Alpaca.Markets.Environments.Paper
.GetAlpacaDataClient(API_KEY, new SecretKey(API_SECRET));
// Get daily price data for AAPL over the last 5 trading days.
var bars = await client.GetBarSetAsync(new[] { "AAPL" }, TimeFrame.Day, 5);
// See how much AAPL moved in that timeframe.
var startPrice = bars["AAPL"].First().Open;
var endPrice = bars["AAPL"].Last().Close;
var percentChange = (endPrice - startPrice) / startPrice * 100;
Console.WriteLine($"AAPL moved {percentChange} over the last 5 days.");
Console.Read();
}
}
}