YahooFinanceApiNext 2.3.8

dotnet add package YahooFinanceApiNext --version 2.3.8                
NuGet\Install-Package YahooFinanceApiNext -Version 2.3.8                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="YahooFinanceApiNext" Version="2.3.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add YahooFinanceApiNext --version 2.3.8                
#r "nuget: YahooFinanceApiNext, 2.3.8"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install YahooFinanceApiNext as a Cake Addin
#addin nuget:?package=YahooFinanceApiNext&version=2.3.8

// Install YahooFinanceApiNext as a Cake Tool
#tool nuget:?package=YahooFinanceApiNext&version=2.3.8                

YahooFinanceApi - Next

license

This library is the successor to the Yahoo! Finance API wrapper: a small tool for retrieving data from Yahoo Finance, written in .NET Standard 2.0.

Features

  • Get quotes
  • Get historical data
  • Get dividend data
  • Get stock split data
  • Get the portfolio of a security.

Changelog

YahooFinanceApi - Next is an independent open-source tool, not associated with, endorsed, or verified by Yahoo, Inc. It utilizes Yahoo's publicly available APIs and is meant strictly for personal use.

Supported Platforms

  • .NET Core 2.0
  • .NET framework 4.6.1 or above
  • Xamarin.iOS
  • Xamarin.Android
  • Universal Windows Platform

How To Install

You can find the package through Nuget

PM> Install-Package YahooFinanceApiNext

Install Note

For traditional .NET framework user, if you find a "System.Runtime.Serialization.Primitives" missing exception is thrown when using this library, you have to install the missing package manually as nuget does not auto install this reference for you (Bugged?)

How to Avoid ban from Yahoo

The new API used for historical data is more restrictive than the previous one. The following simple rules allow me to request data without any issues:

  • Request only one ticker at a time.
  • Wait 1 second between requests.

How To Use

Add reference

using YahooFinanceApi;

Get stock quotes

// You could query multiple symbols with multiple fields through the following steps:
var securities = await Yahoo.Symbols("AAPL", "GOOG").Fields(Field.Symbol, Field.RegularMarketPrice, Field.FiftyTwoWeekHigh).QueryAsync();
var aapl = securities["AAPL"];
var price = aapl[Field.RegularMarketPrice] // or, you could use aapl.RegularMarketPrice directly for typed-value

Supported fields for stock quote

Language, QuoteType, QuoteSourceName, Currency, MarketState, RegularMarketPrice, RegularMarketTime, RegularMarketChange, RegularMarketOpen, RegularMarketDayHigh, RegularMarketDayLow, RegularMarketVolume, ShortName, FiftyTwoWeekHighChange, FiftyTwoWeekHighChangePercent, FiftyTwoWeekLow, FiftyTwoWeekHigh, DividendDate, EarningsTimestamp, EarningsTimestampStart, EarningsTimestampEnd, TrailingAnnualDividendRate, TrailingPE, TrailingAnnualDividendYield, EpsTrailingTwelveMonths, EpsForward, SharesOutstanding, BookValue, RegularMarketChangePercent, RegularMarketPreviousClose, Bid, Ask, BidSize, AskSize, MessageBoardId, FullExchangeName, LongName, FinancialCurrency, AverageDailyVolume3Month, AverageDailyVolume10Day, FiftyTwoWeekLowChange, FiftyTwoWeekLowChangePercent, TwoHundredDayAverageChangePercent, MarketCap, ForwardPE, PriceToBook, SourceInterval, ExchangeTimezoneName, ExchangeTimezoneShortName, Market, Exchange, ExchangeDataDelayedBy, PriceHint, FiftyDayAverage, FiftyDayAverageChange, FiftyDayAverageChangePercent, TwoHundredDayAverage, TwoHundredDayAverageChange, Tradeable, GmtOffSetMilliseconds, Symbol

Ignore invalid rows

// Sometimes, yahoo returns broken rows for historical calls, you could decide if these invalid rows is ignored or not by the following statement
Yahoo.IgnoreEmptyRows = true;

Get historical data for a stock

// You should be able to query data from various markets including US, HK, TW
// The startTime & endTime here defaults to EST timezone
var history = await Yahoo.GetHistoricalAsync("AAPL", new DateTime(2016, 1, 1), new DateTime(2016, 7, 1), Period.Daily);

foreach (var candle in history)
{
    Console.WriteLine($"DateTime: {candle.DateTime}, Open: {candle.Open}, High: {candle.High}, Low: {candle.Low}, Close: {candle.Close}, Volume: {candle.Volume}, AdjustedClose: {candle.AdjustedClose}");
}

Get dividend history for a stock

// You should be able to query data from various markets including US, HK, TW
var dividends = await Yahoo.GetDividendsAsync("AAPL", new DateTime(2016, 1, 1), new DateTime(2016, 7, 1));
foreach (var candle in dividends)
{
    Console.WriteLine($"DateTime: {candle.DateTime}, Dividend: {candle.Dividend}");
}

Get stock split history for a stock

var splits = await Yahoo.GetSplitsAsync("AAPL", new DateTime(2014, 6, 8), new DateTime(2014, 6, 10));
foreach (var s in splits)
{
    Console.WriteLine($"DateTime: {s.DateTime}, AfterSplit: {s.AfterSplit}, BeforeSplit: {s.BeforeSplit}");
}

Powered by

  • Flurl (@tmenier) - A simple & elegant fluent-style REST api library
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.3.8 100 11/19/2024
2.3.7 82 11/14/2024
2.3.6 82 11/13/2024
2.3.5 85 11/12/2024
2.3.4 140 10/23/2024