Streaming quotes from Yahoo Finance.
- .NET 10 library
- simple and intuitive API
- fault-tolerant
- dependencies: protobuf-net, Reactive Extensions, NodaTime
- note that data is available only when the particular market is open
PM> Install-Package YahooQuotesObservableusing System.Reactive.Linq;
using YahooQuotesObservable;
// Create the observable.
IObservable<PricingData> observable = YahooQuotes.CreateObservable(["AAPL", "EURUSD=X"]);
// Subscribe to the observable.
IDisposable subscription = observable.Subscribe(pricingData =>
{
Console.Write($"Symbol: {pricingData.Symbol}, Price: {pricingData.Price}, Time: {pricingData.Time.ToInstant()}");
});
await Task.Delay(TimeSpan.FromSeconds(10));
// Unsubscribe from the observable.
subscription.Dispose();string symbol = "EURUSD=X";
// Create the observable.
IObservable<PricingData> observable = YahooQuotes.CreateObservable(symbol);
// Subscribe to the observable, wait to receive the first output, then unsubscribe.
PricingData pricingData = await observable.FirstAsync();
Assert.Equal(symbol, pricingData.Symbol);