Download realtime and historical end of day stock data and historical dividend data via the Yahoo Finance API
Install-Package YahooFinance.NET
using YahooFinance.NET;
string cookie = "YOUR_COOKIE";
string crumb = "YOUR_CRUMB";
string exchange = "ASX";
string symbol = "AFI";
YahooFinanceClient yahooFinance = new YahooFinanceClient(cookie, crumb);
string yahooStockCode = yahooFinance.GetYahooStockCode(exchange, symbol);
List<YahooHistoricalPriceData> yahooPriceHistory = yahooFinance.GetDailyHistoricalPriceData(yahooStockCode);
List<YahooHistoricalDividendData> yahooDividendHistory = yahooFinance.GetHistoricalDividendData(yahooStockCode);
YahooRealTimeData yahooRealTimeData = yahooFinance.GetRealTimeData(yahooStockCode);
- Go to the Yahoo finance URL and search for a stock. eg. https://finance.yahoo.com/quote/AFI.AX/history?p=AFI.AX
- In Chrome open Settings > Show advanced settings... > Privacy > Content Settings... > All cookies and site data...
- Find the site yahoo.com and the cookie name sould be 'B'
- Copy the 'Content'
- This is your cookie
- Go to the Yahoo finance URL and search for a stock. eg. https://finance.yahoo.com/quote/AFI.AX/history?p=AFI.AX
- Right click on 'Download Data' and copy the link address
- Paste the link somewhere and your crumb will be at the and after the &crumb= eg. https://query1.finance.yahoo.com/v7/finance/download/AFI.AX?period1=1493432127&period2=1496024127&interval=1d&events=history&crumb=YOURCRUMB
- Open up a Powershell prompt and execute
PS> .\build.ps1
- Set the NuGet API key via the commandline if its not already set
nuget.exe setApiKey <API-Key> -Source https://www.nuget.org/api/v2/package
- Increment the AssemblyVersion in AssemblyInfo.cs of the YahooFinance.NET project
- Open up a Powershell prompt and execute
PS> .\build.ps1 -Target Deploy