I am using the AlpacaDataSubscriptionExtensions.AsAsyncEnumerable to convert the minute bars subscription into a AsyncEnumerable and then into a AsyncSeq. I am able to get about 4-5 bars and then the subscription just stops. When I switch over to using the more traditional subscription.add_Received way of subscribing to the events, it works fine. I am using F# and would prefer to use the more functional approach using AsyncSeq. Will attach to the error handler to see if it is throwing an exception. Appreciate any help.
Hi @kotharin, could you please report this issue on GitHub for better traceability?
Please, provide a code sample - it’s obvious from the description but it would be better if we will have the same code for investigation. I also need more information about your environment - OS/.NET/SDK versions can be important.
There is a code sample (in C#) that works on my side:
using var client = Environments.Paper.GetAlpacaDataStreamingClient(key);
Console.WriteLine(await client.ConnectAndAuthenticateAsync());
await using var subscription = await client.SubscribeQuoteAsync("AAPL");
var cts = new CancellationTokenSource(TimeSpan.FromMinutes(1));
try
{
await foreach (var quote in subscription.AsAsyncEnumerable(cts.Token))
{
Console.WriteLine(quote);
}
}
catch (OperationCanceledException)
{
// Expected one...
}
Hi Oleg,
Thanks for getting back to me. I re-ran my original code and it seems to be working fine now. I think there was some issue on my computer/network. Apologies for the false alarm. Side note: working with the AsyncSeq in F# for the minute bars and writing business logic around the async operations has been very good and easy to read. Thanks again!