Yahoo Finance API to retrieve quote snapshots, and quote, dividend and split history
- asynchronous
- supports .NET Standard 2.0
- dependencies: NodaTime, Flurl, CsvHelper
- simple and intuitive API
- tested
using NodaTime;
using YahooQuotesApi;
YahooSnapshot Snapshot = new YahooSnapshot();
Security? security = await Snapshot.GetAsync("IBM");
if (security == null)
throw new Exception("Unknown symbol: IBM");
Assert.True(security.RegularMarketPrice > 0);
Assert.NotNull(security.LongName);
YahooHistory History = new YahooHistory();
List<PriceTick>? prices = await History.FromDays(90).GetPricesAsync("IBM");
if (prices == null)
throw new Exception("Unknown symbol: IBM");
Assert.True(prices[0].Close > 10);
YahooHistory History = new YahooHistory();
List<DividendTick>? dividends = await History.GetDividendsAsync("IBM");
if (dividends == null)
throw new Exception("Unknown symbol: IBM");
Assert.True(dividends[0].Dividend > 0);
YahooHistory History = new YahooHistory();
List<SplitTick>? splits = await History.GetSplitsAsync("IBM");
if (splits == null)
throw new Exception("Unknown symbol: IBM");
Assert.True(splits[0].BeforeSplit < splits[0].AfterSplit);
Currency Rate History (https://www.bankofengland.co.uk)
CurrencyHistory CurrencyHistory = new CurrencyHistory();
string currency = "EUR";
string baseCurrency = "USD";
List<RateTick>? rates = await CurrencyHistory
.FromDate(new LocalDate(2010,1,1))
.GetRatesAsync(currency, baseCurrency);
if (rates == null)
throw new Exception($"Unsupported currency: {symbol}/{baseCurrency}");
Assert.True(rates[0].Rate > 0);