Repository files navigation

Banner

CICoverageQuality GateNuGetDownloads.NET StandardStars

An easy-to-use .NET library for accessing and aggregating financial data from multiple sources.

This library enables developers to retrieve financial data via APIs and HTML scraping from a variety of providers. It's ideal for building analytical tools, dashboards, or financial applications that require access to market data.


⭐ Features

  • Retrieve Instruments: Get tradable ticker symbols and associated details.
  • Fundamentals: Access key financial metrics and company fundamentals.
  • Historical Records: Fetch historical data for analysis or charting.
  • Real-Time Quotes: Receive live updates on stock prices and market data.

🚀 Getting started

This section guides you through installing Finance.NET, configuring services, and basic data retrieval.

Installation

Install via NuGet:

dotnet add package Finance.NET

Register in Service Collection

Add Finance.NET to your service collection for dependency injection:

services.AddFinanceNet();

Optional: Configure with custom settings.

services.AddFinanceNet(newFinanceNetConfiguration{HttpTimeout=5,// seconds (default: 20)HttpRetryCount=3,// default: 10HttpRetrySleepTime=5,// seconds, base for exponential back-off; capped at 30s per attempt, plus jitter (default: 5)AlphaVantageApiKey="ALPHA_VANTAGE__API_KEY"});

Basic Usage

Example: Retrieve historical and real-time data for Tesla (TSLA):

publicasyncTaskRun(IYahooFinanceServiceyahooService){varsymbol="TSLA";varstartDate=newDateTime(2020,1,1);varrecords=awaityahooService.GetRecordsAsync(symbol,startDate);foreach(varrecordinrecords){Console.WriteLine($"Date={record.Date}: {record.Open} / {record.Close}");}varquote=awaityahooService.GetQuoteAsync(symbol);Console.WriteLine($"Bid={quote.Bid}, Ask={quote.Ask}");}

🔌Finance.NET Service Interfaces

Finance.NET exposes modular service interfaces for accessing diverse financial data through a consistent API. Each interface corresponds to a specific provider and supports its unique features.

Yahoo! Finance

Provides market data, company fundamentals, historical records, and real-time quotes.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of financial instruments.

Parameters

  • EInstrumentType? filterByType: An optional filter to specify the type of asset. If not provided, all asset types will be included. Possible values:
    • Stock: Most active stocks.
    • ETF: Most active exchange-traded funds (ETFs)
    • Forex: Available currencies (foreign exchange).
    • Crypto: Available cryptocurrencies.
    • Index: Available world indices.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.AAPL
InstrumentTypeEInstrumentType?The type of the financial instrument.Stock

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve all instrumentsvarinstruments=awaityahooService.GetInstrumentsAsync();// Retrieve only stock instrumentsvarstockInstruments=awaityahooService.GetInstrumentsAsync(EInstrumentType.Stock);foreach(varinstrumentinstockInstruments){Console.WriteLine($"Symbol: {instrument.Symbol}, Type: {instrument.InstrumentType}");}}
GetProfileAsync

Description

Retrieves the profile of a specific entity based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Profile containing the following properties:

PropertyTypeDescriptionExample
Adressstring?The address.One Apple Park Way, Cupertino, CA 95014
Phonestring?The phone number.+1-800-MY-APPLE
Websitestring?The website URL.https://www.apple.com
Sectorstring?The sector in which the entity operates.Technology
Industrystring?The industry the entity belongs to.Consumer Electronics
CntEmployeeslong?The number of employees.164000
Descriptionstring?A brief description.Apple designs and ...

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){varprofile=awaityahooService.GetProfileAsync("AAPL");Console.WriteLine($"Address: {profile.Adress}");Console.WriteLine($"Sector: {profile.Sector}");Console.WriteLine($"Industry: {profile.Industry}");Console.WriteLine($"Description: {profile.Description}");}
GetSummaryAsync

Description

Retrieves the summary of a specific asset based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Summary containing the following properties:

PropertyTypeDescriptionExample
Namestring?Name of the asset.Apple Inc.
MarketTimeNoticestring?Notice of market status.Market Closed
PreviousClosedecimal?Previous closing price.180.14
Opendecimal?Opening price of the stock.182.20
Biddecimal?Current bid price.180.00
Askdecimal?Current ask price.181.00
DaysRange_Mindecimal?Minimum price today.179.50
DaysRange_Maxdecimal?Maximum price today.183.00
WeekRange52_Mindecimal?Minimum price in 52 weeks.130.20
WeekRange52_Maxdecimal?Maximum price in 52 weeks.190.50
Volumedecimal?Total volume traded today.25,000,000
AvgVolumedecimal?Average daily volume.30,000,000
MarketCap_Intradaydecimal?Market cap in the current session.2.85T
Beta_5Y_Monthlydecimal?5-year beta (monthly data).1.20
PE_Ratio_TTMdecimal?Price-to-earnings ratio (TTM).28.90
EPS_TTMdecimal?Earnings per share (TTM).6.22
EarningsDateDateTime?Date of the next earnings report.2025-02-15
Forward_Dividenddecimal?Expected forward dividend.0.88
Forward_Yielddecimal?Forward dividend yield.0.49%
Ex_DividendDateDateTime?Ex-dividend date.2025-01-10
OneYearTargetEstdecimal?One-year target price estimate.200.00

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve the summary for Apple Inc.varsummary=awaityahooService.GetSummaryAsync("AAPL");Console.WriteLine($"Name: {summary.Name}");Console.WriteLine($"Previous Close: {summary.PreviousClose}");Console.WriteLine($"Open: {summary.Open}");Console.WriteLine($"Bid: {summary.Bid}");Console.WriteLine($"Ask: {summary.Ask}");Console.WriteLine($"Average Volume: {summary.AvgVolume}");Console.WriteLine($"EPS (TTM): {summary.EPS_TTM}");}
GetFinancialsAsync

Description

Retrieves the financial reports for a specified asset identified by its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Dictionary<string, FinancialReport> where the key is the label (e.g., "Annual Report 2024") and the value is a FinancialReport containing the following properties:

PropertyTypeDescriptionExample
TickerSymbolstring?The company's stock symbol.AAPL
TotalRevenuedecimal?Total revenue generated.394,328,000,000
CostOfRevenuedecimal?Direct costs of goods/services sold.213,459,000,000
GrossProfitdecimal?Gross profit (Revenue - Cost of Revenue).180,869,000,000
OperatingExpensedecimal?Operating expenses incurred.34,152,000,000
OperatingIncomedecimal?Operating income (Gross Profit - Operating Expenses).146,717,000,000
NetNonOperatingInterestIncomeExpensedecimal?Net non-operating interest income/expense.2,500,000,000
OtherIncomeExpensedecimal?Other non-core income/expenses.-1,200,000,000
PretaxIncomedecimal?Pretax income before taxes.148,017,000,000
TaxProvisiondecimal?Income taxes provisioned.25,000,000,000
NetIncomeCommonStockholdersdecimal?Net income for common stockholders.123,017,000,000
DilutedNIAvailableToComStockholdersdecimal?Diluted net income for common stockholders.120,517,000,000
BasicEPSdecimal?Basic earnings per share.6.25
DilutedEPSdecimal?Diluted earnings per share.6.15
BasicAverageSharesdecimal?Basic average shares for EPS.19,700,000,000
DilutedAverageSharesdecimal?Diluted average shares for EPS.19,600,000,000
TotalOperatingIncomeAsReporteddecimal?Reported total operating income.146,700,000,000
TotalExpensesdecimal?Total expenses incurred.247,611,000,000
NetIncomeFromContinuingAndDiscontinuedOperationdecimal?Net income from all operations.123,017,000,000
NormalizedIncomedecimal?Normalized income adjusted for irregularities.125,500,000,000
InterestIncomedecimal?Interest income earned.5,000,000,000
InterestExpensedecimal?Interest expense incurred.2,500,000,000
NetInterestIncomedecimal?Net interest income (Income - Expense).2,500,000,000
EBITdecimal?Earnings Before Interest and Taxes.148,217,000,000
EBITDAdecimal?Earnings Before Interest, Taxes, Depreciation, and Amortization.151,217,000,000
ReconciledCostOfRevenuedecimal?Adjusted cost of revenue.212,000,000,000
ReconciledDepreciationdecimal?Adjusted depreciation expense.3,000,000,000
NetIncomeFromContinuingOperationNetMinorityInterestdecimal?Net income from continuing operations.121,017,000,000
TotalUnusualItemsExcludingGoodwilldecimal?Total unusual items, excluding goodwill.-2,000,000,000
TotalUnusualItemsdecimal?Total unusual items, including goodwill.-2,000,000,000
NormalizedEBITDAdecimal?Adjusted EBITDA for unusual items.153,217,000,000
TaxRateForCalcsdecimal?Tax rate used in calculations.16.9%
TaxEffectOfUnusualItemsdecimal?Tax effect of unusual items.-500,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve financial reports for Apple Inc.varfinancialReports=awaityahooService.GetFinancialsAsync("AAPL");foreach(varlabelinfinancialReports.Keys){varreport=financialReports[label];Console.WriteLine($"Label: {label}");Console.WriteLine($"Ticker Symbol: {report.TickerSymbol}");Console.WriteLine($"Total Revenue: {report.TotalRevenue}");Console.WriteLine($"Cost of Revenue: {report.CostOfRevenue}");Console.WriteLine($"Gross Profit: {report.GrossProfit}");Console.WriteLine($"Operating Income: {report.OperatingIncome}");Console.WriteLine($"Net Income: {report.NetIncomeCommonStockholders}");Console.WriteLine();}}
GetRecordsAsync

Description

Retrieves historical stock market data records for a specified asset identified by its symbol. Users can specify an optional date range.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for retrieving historical records. Defaults to 7 days before the current date if not provided.
  • DateTime? endDate: (Optional) End date for retrieving historical records. Defaults to the current date if not provided.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Record>, where each Record represents a historical data point with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record.2025-01-01
Opendecimal?The opening price.150.25
Highdecimal?The highest price during the trading session.155.00
Lowdecimal?The lowest price during the trading session.148.50
Closedecimal?The closing price at the end of the trading session.152.75
AdjustedClosedecimal?The adjusted closing price, accounting for stock splits and dividends.153.00
Volumelong?The trading volume (number of shares traded).10,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve historical records for Apple Inc. for the last 30 daysvarstartDate=DateTime.UtcNow.AddDays(-30);varendDate=DateTime.UtcNow;varrecords=awaityahooService.GetRecordsAsync("AAPL",startDate,endDate);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date:yyyy-MM-dd}");Console.WriteLine($"Open: {record.Open:C}");Console.WriteLine($"Close: {record.Close:C}");Console.WriteLine();}}
GetQuoteAsync

Description

Retrieves detailed information about a specific financial quote, identified by its symbol. This API is useful for accessing comprehensive data about a stock, ETF, or other traded financial instruments.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A cancellation token that can be used to cancel the operation if needed.

Returns

A task that resolves to a Quote object. The Quote record contains detailed information about the requested financial instrument, as described in the table below.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskDisplayQuote(IYahooFinanceServiceyahooService){// Retrieve a quote for Apple Inc.varquote=awaityahooService.GetQuoteAsync("AAPL");Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.ShortName}");Console.WriteLine($"Market Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Currency: {quote.Currency}");}
GetQuotesAsync

Description

Retrieves quote data for multiple financial instruments identified by their symbols. The data includes detailed information about each instrument, such as pricing, market performance, and other financial metrics.

Parameters

  • List<string> symbols: A list of symbols for which to retrieve data (e.g., ["AAPL", "MSFT", "GOOGL"]).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Quote>, where each Quote provides comprehensive data about a specific instrument.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve quotes for Apple, Microsoft, and Googlevarsymbols=newList<string>{"AAPL","MSFT","GOOGL"};varquotes=awaityahooService.GetQuotesAsync(symbols);foreach(varquoteinquotes){Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.DisplayName}");Console.WriteLine($"Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Dividend Yield: {quote.DividendYield:P}");Console.WriteLine($"Earnings Date: {quote.EarningsDate:yyyy-MM-dd}");Console.WriteLine();}}

Alpha Vantage

Offers stock, forex, and cryptocurrency data including intraday and historical records.

Get an API key

To get started, obtain a free API key from Alpha Vantage.

Configure API key

After acquiring your API key, configure it in your service collection:

services.AddFinanceNet(newFinanceNetConfiguration{AlphaVantageApiKey="API_KEY"});

Methods

GetOverviewAsync

Description

Retrieves an instrument overview for a specified stock symbol.

Parameters

  • string symbol: The symbol of the asset (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A token to cancel the operation if needed.

Returns

A task that resolves to an InstrumentOverview?. The InstrumentOverview contains the following properties that provide key information about the company:

PropertyTypeDescriptionExample
Symbolstring?The stock symbol."AAPL"
AssetTypestring?The type of asset (e.g., stock, ETF)."Equity"
Namestring?The name of the ticker or company."Apple Inc."
Descriptionstring?A brief company description."Designs ... ."
CIKstring?The Central Index Key (CIK) of the company."0000320193"
Exchangestring?The exchange where the company is listed."NASDAQ"
Currencystring?The currency used for financials."USD"
Countrystring?The country where the company is located."United States"
Sectorstring?The company's sector (e.g., Technology)."Technology"
Industrystring?The industry the company operates in."Consumer Electronics"
Addressstring?The company's headquarters address."Cupertino, CA"
OfficialSitestring?The official website of the company."https://www.apple.com"
FiscalYearEndstring?The fiscal year end date."September 30"
LatestQuarterstring?The most recent available quarter."Q3 2024"
MarketCapitalizationlong?The market capitalization.2320000000000
EBITDAstring?EBITDA."11200000000"
PERatiostring?The Price-to-Earnings ratio."27.5"
PEGRatiostring?The Price/Earnings-to-Growth ratio."1.4"
BookValuestring?The company's book value."10.52"
DividendPerSharestring?The dividend per share."0.82"
DividendYieldstring?The dividend yield."1.5%"
EPSstring?Earnings per share."5.26"
RevenuePerShareTTMstring?Revenue per share for the trailing twelve months."30.5"
ProfitMarginstring?Profit margin."25%"
OperatingMarginTTMstring?Operating margin for the trailing twelve months."22%"
ReturnOnAssetsTTMstring?Return on assets for the trailing twelve months."14%"
ReturnOnEquityTTMstring?Return on equity for the trailing twelve months."40%"
RevenueTTMstring?Revenue for the trailing twelve months."386000000000"
GrossProfitTTMstring?Gross profit for the trailing twelve months."160000000000"
DilutedEPSTTMstring?Diluted earnings per share for the trailing twelve months."5.10"
QuarterlyEarningsGrowthYOYstring?Quarterly earnings growth year-over-year."15%"
QuarterlyRevenueGrowthYOYstring?Quarterly revenue growth year-over-year."10%"
AnalystTargetPricestring?Analyst target price for the stock."175.00"
AnalystRatingStrongBuystring?Percentage of analysts recommending a strong buy."60%"
AnalystRatingBuystring?Percentage of analysts recommending a buy."30%"
AnalystRatingHoldstring?Percentage of analysts recommending a hold."10%"
AnalystRatingSellstring?Percentage of analysts recommending a sell."0%"
AnalystRatingStrongSellstring?Percentage of analysts recommending a strong sell."0%"
TrailingPEstring?Trailing Price-to-Earnings ratio."28"
ForwardPEstring?Forward Price-to-Earnings ratio."25"
PriceToSalesRatioTTMstring?Price-to-Sales ratio for the trailing twelve months."6.5"
PriceToBookRatiostring?Price-to-Book ratio."4.3"
EVToRevenuestring?Enterprise value-to-revenue ratio."8.2"
EVToEBITDAstring?Enterprise value-to-EBITDA ratio."14.5"
Betastring?Beta value, measuring stock volatility."1.2"
FiftySecondWeekHighstring?52-week high stock price."179.50"
FiftySecondWeekLowstring?52-week low stock price."120.10"
FiftyDayMovingAveragestring?50-day moving average."153.25"
TwoHundredDayMovingAveragestring?200-day moving average."157.80"
SharesOutstandingstring?Number of shares outstanding."5000000000"
DividendDatestring?Next dividend payment date."2025-02-01"
ExDividendDatestring?Ex-dividend date."2025-01-10"

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve the overview for Apple Inc.varoverview=awaitalphaVantageService.GetOverviewAsync("AAPL");if(overview!=null){Console.WriteLine($"Symbol: {overview.Symbol}");Console.WriteLine($"Name: {overview.Name}");Console.WriteLine($"Sector: {overview.Sector}");Console.WriteLine($"Market Capitalization: {overview.MarketCapitalization}");Console.WriteLine($"Dividend Yield: {overview.DividendYield}");Console.WriteLine($"P/E Ratio: {overview.PERatio}");Console.WriteLine($"Revenue (TTM): {overview.RevenueTTM}");}}
GetRecordsAsync

Description

Retrieves historical daily stock records for a given symbol within an optional date range.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for the records. Defaults to 7 days ago.
  • DateTime? endDate: (Optional) End date for the records. Defaults to current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<Record>, with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record."2024-12-15"
Opendouble?The opening price of the asset.150.25
Lowdouble?The lowest price of the asset on that date.148.75
Highdouble?The highest price of the asset on that date.153.50
Closedouble?The closing price of the asset.151.00
AdjustedClosedouble?The adjusted closing price, considering stock splits and dividends.150.80
Volumelong?The trading volume of the asset on that date.1000000
SplitCoefficientdouble?The stock split coefficient, if any, for the given date.1.0

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical records for Apple Inc. (AAPL)varrecords=awaitalphaVantageService.GetRecordsAsync("AAPL",DateTime.Now.AddDays(-7),DateTime.Now);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date.ToShortDateString()}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"High: {record.High}");Console.WriteLine($"Low: {record.Low}");Console.WriteLine($"Close: {record.Close}");Console.WriteLine($"Adjusted Close: {record.AdjustedClose}");Console.WriteLine($"Volume: {record.Volume}");Console.WriteLine($"Split Coefficient: {record.SplitCoefficient}");Console.WriteLine();}}
GetForexRecordsAsync

Description

Retrieves historical daily forex (foreign exchange) records for a given currency pair within a specified date range.

Parameters

  • string currency1: The source currency (e.g., "USD").
  • string currency2: The target currency (e.g., "EUR").
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<ForexRecord>, with the following properties:

PropertyTypeDescriptionExample
DateDateTime?The date of the forex record."2024-12-15"
Opendouble?The opening price of the currency pair for that date.1.1215
Highdouble?The highest price of the currency pair for that date.1.1250
Lowdouble?The lowest price of the currency pair for that date.1.1180
Closedouble?The closing price of the currency pair for that date.1.1220

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical forex records for USD to EURvarforexRecords=awaitalphaVantageService.GetForexRecordsAsync("USD","EUR",DateTime.Now.AddDays(-7));foreach(varrecordinforexRecords){Console.WriteLine($"Date: {record.Date}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}
GetIntradayRecordsAsync

Description

Retrieves intraday stock records for a given symbol within a specified date range and time interval.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • EInterval interval: The time interval between data points. Default is 15 minutes. Possible values:
    • Interval_1Min
    • Interval_5Min
    • Interval_15Min
    • Interval_30Min
    • Interval_60Min
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<IntradayRecord>, with the following properties:

PropertyTypeDescriptionExample
DateTimeDateTimeThe date and time of the record."2024-12-15 09:30"
OpendoubleThe opening price of the stock for that interval.145.32
HighdoubleThe highest price of the stock for that interval.147.10
LowdoubleThe lowest price of the stock for that interval.144.98
ClosedoubleThe closing price of the stock for that interval.146.30
VolumelongThe trading volume during that interval.1234567

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve intraday stock records for AAPL with a 15-minute intervalvarintradayRecords=awaitalphaVantageService.GetIntradayRecordsAsync("AAPL",DateTime.Now.AddDays(-1),DateTime.Now,EInterval.Interval_15Min);foreach(varrecordinintradayRecords){Console.WriteLine($"DateTime: {record.DateTime}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}

DataHub

Accesses datasets like Nasdaq and S&P 500 companies.

Methods

GetNasdaqInstrumentsAsync

Description

Retrieves a collection of more than 4,000 Nasdaq instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<NasdaqInstrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.TSLA
Namestring?The company name associated with the instrument.Tesla, Inc.

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetNasdaqInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}");}}
GetSp500InstrumentsAsync

Description

Retrieves a collection of S&P 500 instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Sp500Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the instrument.TSLA
Namestring?Name of the instrument/company.Tesla, Inc.
Sectorstring?Sector of the instrument.Automobile Manufacturers
Pricedouble?Current price of the instrument.345.16
PriceEarningsdouble?Price-to-earnings ratio.94.31
DividendYielddouble?Dividend yield.0.89
EarningsSharedouble?Earnings per share.3.66
FiftyTwoWeekLowdouble?52-week low price.338.8
FiftyTwoWeekHighdouble?52-week high price.361.93
MarketCaplong?Market capitalization.1107284384000
EBITDAlong?EBITDA value.13244000256
PriceSalesdouble?Price-to-sales ratio.11.41
PriceBookdouble?Price-to-book ratio.15.82

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetSp500InstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}, Sector: {item.Sector}");}}

Xetra

A major European trading platform offering data on Xetra-listed instruments.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of more than 3,000 Xetra instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the financial instrument.TL0.DE
InstrumentStatusstring?Current status of the instrument.Active
InstrumentNamestring?Full name of the financial instrument.TESLA INC. DL -,001
ISINstring?International Securities Identification Number.US88160R1014
WKNstring?German securities identification number.000A1CX3T
Mnemonicstring?Shorthand or mnemonic code for the instrument.TL0
InstrumentTypestring?Type of financial instrument (e.g., CS, ETF, ETN).CS
Currencystring?Currency in which the instrument is traded.EUR

Example

publicasyncTaskRun(IXetraServicexetraService){varinstruments=awaitxetraService.GetInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.InstrumentName}");}}

🤝 How to Contribute

We welcome contributions to Finance.NET! If you’d like to improve the project, please:

  1. Check out our contributing guidelines.
  2. Ideally, open an issue before starting work.
  3. Submit a pull request with your changes.

Thank you for helping make Finance.NET better!


ℹ️ Disclaimer

Finance.NET is an open-source project using publicly accessible APIs and scraping techniques. It is intended for educational and research purposes.

For legal usage, refer to the terms of each data provider:

For additional licensing and attribution details, see NOTICE.md.


🐞 Report a Bug

If you encounter any issues or bugs, please report them here.

About

A .NET library for retrieving real-time and historical financial data from Yahoo Finance and other popular sources.

Topics

Resources

Code of conduct

Contributing

Stars

22 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

Banner

CICoverageQuality GateNuGetDownloads.NET StandardStars

An easy-to-use .NET library for accessing and aggregating financial data from multiple sources.

This library enables developers to retrieve financial data via APIs and HTML scraping from a variety of providers. It's ideal for building analytical tools, dashboards, or financial applications that require access to market data.


⭐ Features

  • Retrieve Instruments: Get tradable ticker symbols and associated details.
  • Fundamentals: Access key financial metrics and company fundamentals.
  • Historical Records: Fetch historical data for analysis or charting.
  • Real-Time Quotes: Receive live updates on stock prices and market data.

🚀 Getting started

This section guides you through installing Finance.NET, configuring services, and basic data retrieval.

Installation

Install via NuGet:

dotnet add package Finance.NET

Register in Service Collection

Add Finance.NET to your service collection for dependency injection:

services.AddFinanceNet();

Optional: Configure with custom settings.

services.AddFinanceNet(newFinanceNetConfiguration{HttpTimeout=5,// seconds (default: 20)HttpRetryCount=3,// default: 10HttpRetrySleepTime=5,// seconds, base for exponential back-off; capped at 30s per attempt, plus jitter (default: 5)AlphaVantageApiKey="ALPHA_VANTAGE__API_KEY"});

Basic Usage

Example: Retrieve historical and real-time data for Tesla (TSLA):

publicasyncTaskRun(IYahooFinanceServiceyahooService){varsymbol="TSLA";varstartDate=newDateTime(2020,1,1);varrecords=awaityahooService.GetRecordsAsync(symbol,startDate);foreach(varrecordinrecords){Console.WriteLine($"Date={record.Date}: {record.Open} / {record.Close}");}varquote=awaityahooService.GetQuoteAsync(symbol);Console.WriteLine($"Bid={quote.Bid}, Ask={quote.Ask}");}

🔌Finance.NET Service Interfaces

Finance.NET exposes modular service interfaces for accessing diverse financial data through a consistent API. Each interface corresponds to a specific provider and supports its unique features.

Yahoo! Finance

Provides market data, company fundamentals, historical records, and real-time quotes.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of financial instruments.

Parameters

  • EInstrumentType? filterByType: An optional filter to specify the type of asset. If not provided, all asset types will be included. Possible values:
    • Stock: Most active stocks.
    • ETF: Most active exchange-traded funds (ETFs)
    • Forex: Available currencies (foreign exchange).
    • Crypto: Available cryptocurrencies.
    • Index: Available world indices.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.AAPL
InstrumentTypeEInstrumentType?The type of the financial instrument.Stock

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve all instrumentsvarinstruments=awaityahooService.GetInstrumentsAsync();// Retrieve only stock instrumentsvarstockInstruments=awaityahooService.GetInstrumentsAsync(EInstrumentType.Stock);foreach(varinstrumentinstockInstruments){Console.WriteLine($"Symbol: {instrument.Symbol}, Type: {instrument.InstrumentType}");}}
GetProfileAsync

Description

Retrieves the profile of a specific entity based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Profile containing the following properties:

PropertyTypeDescriptionExample
Adressstring?The address.One Apple Park Way, Cupertino, CA 95014
Phonestring?The phone number.+1-800-MY-APPLE
Websitestring?The website URL.https://www.apple.com
Sectorstring?The sector in which the entity operates.Technology
Industrystring?The industry the entity belongs to.Consumer Electronics
CntEmployeeslong?The number of employees.164000
Descriptionstring?A brief description.Apple designs and ...

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){varprofile=awaityahooService.GetProfileAsync("AAPL");Console.WriteLine($"Address: {profile.Adress}");Console.WriteLine($"Sector: {profile.Sector}");Console.WriteLine($"Industry: {profile.Industry}");Console.WriteLine($"Description: {profile.Description}");}
GetSummaryAsync

Description

Retrieves the summary of a specific asset based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Summary containing the following properties:

PropertyTypeDescriptionExample
Namestring?Name of the asset.Apple Inc.
MarketTimeNoticestring?Notice of market status.Market Closed
PreviousClosedecimal?Previous closing price.180.14
Opendecimal?Opening price of the stock.182.20
Biddecimal?Current bid price.180.00
Askdecimal?Current ask price.181.00
DaysRange_Mindecimal?Minimum price today.179.50
DaysRange_Maxdecimal?Maximum price today.183.00
WeekRange52_Mindecimal?Minimum price in 52 weeks.130.20
WeekRange52_Maxdecimal?Maximum price in 52 weeks.190.50
Volumedecimal?Total volume traded today.25,000,000
AvgVolumedecimal?Average daily volume.30,000,000
MarketCap_Intradaydecimal?Market cap in the current session.2.85T
Beta_5Y_Monthlydecimal?5-year beta (monthly data).1.20
PE_Ratio_TTMdecimal?Price-to-earnings ratio (TTM).28.90
EPS_TTMdecimal?Earnings per share (TTM).6.22
EarningsDateDateTime?Date of the next earnings report.2025-02-15
Forward_Dividenddecimal?Expected forward dividend.0.88
Forward_Yielddecimal?Forward dividend yield.0.49%
Ex_DividendDateDateTime?Ex-dividend date.2025-01-10
OneYearTargetEstdecimal?One-year target price estimate.200.00

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve the summary for Apple Inc.varsummary=awaityahooService.GetSummaryAsync("AAPL");Console.WriteLine($"Name: {summary.Name}");Console.WriteLine($"Previous Close: {summary.PreviousClose}");Console.WriteLine($"Open: {summary.Open}");Console.WriteLine($"Bid: {summary.Bid}");Console.WriteLine($"Ask: {summary.Ask}");Console.WriteLine($"Average Volume: {summary.AvgVolume}");Console.WriteLine($"EPS (TTM): {summary.EPS_TTM}");}
GetFinancialsAsync

Description

Retrieves the financial reports for a specified asset identified by its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Dictionary<string, FinancialReport> where the key is the label (e.g., "Annual Report 2024") and the value is a FinancialReport containing the following properties:

PropertyTypeDescriptionExample
TickerSymbolstring?The company's stock symbol.AAPL
TotalRevenuedecimal?Total revenue generated.394,328,000,000
CostOfRevenuedecimal?Direct costs of goods/services sold.213,459,000,000
GrossProfitdecimal?Gross profit (Revenue - Cost of Revenue).180,869,000,000
OperatingExpensedecimal?Operating expenses incurred.34,152,000,000
OperatingIncomedecimal?Operating income (Gross Profit - Operating Expenses).146,717,000,000
NetNonOperatingInterestIncomeExpensedecimal?Net non-operating interest income/expense.2,500,000,000
OtherIncomeExpensedecimal?Other non-core income/expenses.-1,200,000,000
PretaxIncomedecimal?Pretax income before taxes.148,017,000,000
TaxProvisiondecimal?Income taxes provisioned.25,000,000,000
NetIncomeCommonStockholdersdecimal?Net income for common stockholders.123,017,000,000
DilutedNIAvailableToComStockholdersdecimal?Diluted net income for common stockholders.120,517,000,000
BasicEPSdecimal?Basic earnings per share.6.25
DilutedEPSdecimal?Diluted earnings per share.6.15
BasicAverageSharesdecimal?Basic average shares for EPS.19,700,000,000
DilutedAverageSharesdecimal?Diluted average shares for EPS.19,600,000,000
TotalOperatingIncomeAsReporteddecimal?Reported total operating income.146,700,000,000
TotalExpensesdecimal?Total expenses incurred.247,611,000,000
NetIncomeFromContinuingAndDiscontinuedOperationdecimal?Net income from all operations.123,017,000,000
NormalizedIncomedecimal?Normalized income adjusted for irregularities.125,500,000,000
InterestIncomedecimal?Interest income earned.5,000,000,000
InterestExpensedecimal?Interest expense incurred.2,500,000,000
NetInterestIncomedecimal?Net interest income (Income - Expense).2,500,000,000
EBITdecimal?Earnings Before Interest and Taxes.148,217,000,000
EBITDAdecimal?Earnings Before Interest, Taxes, Depreciation, and Amortization.151,217,000,000
ReconciledCostOfRevenuedecimal?Adjusted cost of revenue.212,000,000,000
ReconciledDepreciationdecimal?Adjusted depreciation expense.3,000,000,000
NetIncomeFromContinuingOperationNetMinorityInterestdecimal?Net income from continuing operations.121,017,000,000
TotalUnusualItemsExcludingGoodwilldecimal?Total unusual items, excluding goodwill.-2,000,000,000
TotalUnusualItemsdecimal?Total unusual items, including goodwill.-2,000,000,000
NormalizedEBITDAdecimal?Adjusted EBITDA for unusual items.153,217,000,000
TaxRateForCalcsdecimal?Tax rate used in calculations.16.9%
TaxEffectOfUnusualItemsdecimal?Tax effect of unusual items.-500,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve financial reports for Apple Inc.varfinancialReports=awaityahooService.GetFinancialsAsync("AAPL");foreach(varlabelinfinancialReports.Keys){varreport=financialReports[label];Console.WriteLine($"Label: {label}");Console.WriteLine($"Ticker Symbol: {report.TickerSymbol}");Console.WriteLine($"Total Revenue: {report.TotalRevenue}");Console.WriteLine($"Cost of Revenue: {report.CostOfRevenue}");Console.WriteLine($"Gross Profit: {report.GrossProfit}");Console.WriteLine($"Operating Income: {report.OperatingIncome}");Console.WriteLine($"Net Income: {report.NetIncomeCommonStockholders}");Console.WriteLine();}}
GetRecordsAsync

Description

Retrieves historical stock market data records for a specified asset identified by its symbol. Users can specify an optional date range.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for retrieving historical records. Defaults to 7 days before the current date if not provided.
  • DateTime? endDate: (Optional) End date for retrieving historical records. Defaults to the current date if not provided.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Record>, where each Record represents a historical data point with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record.2025-01-01
Opendecimal?The opening price.150.25
Highdecimal?The highest price during the trading session.155.00
Lowdecimal?The lowest price during the trading session.148.50
Closedecimal?The closing price at the end of the trading session.152.75
AdjustedClosedecimal?The adjusted closing price, accounting for stock splits and dividends.153.00
Volumelong?The trading volume (number of shares traded).10,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve historical records for Apple Inc. for the last 30 daysvarstartDate=DateTime.UtcNow.AddDays(-30);varendDate=DateTime.UtcNow;varrecords=awaityahooService.GetRecordsAsync("AAPL",startDate,endDate);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date:yyyy-MM-dd}");Console.WriteLine($"Open: {record.Open:C}");Console.WriteLine($"Close: {record.Close:C}");Console.WriteLine();}}
GetQuoteAsync

Description

Retrieves detailed information about a specific financial quote, identified by its symbol. This API is useful for accessing comprehensive data about a stock, ETF, or other traded financial instruments.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A cancellation token that can be used to cancel the operation if needed.

Returns

A task that resolves to a Quote object. The Quote record contains detailed information about the requested financial instrument, as described in the table below.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskDisplayQuote(IYahooFinanceServiceyahooService){// Retrieve a quote for Apple Inc.varquote=awaityahooService.GetQuoteAsync("AAPL");Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.ShortName}");Console.WriteLine($"Market Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Currency: {quote.Currency}");}
GetQuotesAsync

Description

Retrieves quote data for multiple financial instruments identified by their symbols. The data includes detailed information about each instrument, such as pricing, market performance, and other financial metrics.

Parameters

  • List<string> symbols: A list of symbols for which to retrieve data (e.g., ["AAPL", "MSFT", "GOOGL"]).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Quote>, where each Quote provides comprehensive data about a specific instrument.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve quotes for Apple, Microsoft, and Googlevarsymbols=newList<string>{"AAPL","MSFT","GOOGL"};varquotes=awaityahooService.GetQuotesAsync(symbols);foreach(varquoteinquotes){Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.DisplayName}");Console.WriteLine($"Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Dividend Yield: {quote.DividendYield:P}");Console.WriteLine($"Earnings Date: {quote.EarningsDate:yyyy-MM-dd}");Console.WriteLine();}}

Alpha Vantage

Offers stock, forex, and cryptocurrency data including intraday and historical records.

Get an API key

To get started, obtain a free API key from Alpha Vantage.

Configure API key

After acquiring your API key, configure it in your service collection:

services.AddFinanceNet(newFinanceNetConfiguration{AlphaVantageApiKey="API_KEY"});

Methods

GetOverviewAsync

Description

Retrieves an instrument overview for a specified stock symbol.

Parameters

  • string symbol: The symbol of the asset (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A token to cancel the operation if needed.

Returns

A task that resolves to an InstrumentOverview?. The InstrumentOverview contains the following properties that provide key information about the company:

PropertyTypeDescriptionExample
Symbolstring?The stock symbol."AAPL"
AssetTypestring?The type of asset (e.g., stock, ETF)."Equity"
Namestring?The name of the ticker or company."Apple Inc."
Descriptionstring?A brief company description."Designs ... ."
CIKstring?The Central Index Key (CIK) of the company."0000320193"
Exchangestring?The exchange where the company is listed."NASDAQ"
Currencystring?The currency used for financials."USD"
Countrystring?The country where the company is located."United States"
Sectorstring?The company's sector (e.g., Technology)."Technology"
Industrystring?The industry the company operates in."Consumer Electronics"
Addressstring?The company's headquarters address."Cupertino, CA"
OfficialSitestring?The official website of the company."https://www.apple.com"
FiscalYearEndstring?The fiscal year end date."September 30"
LatestQuarterstring?The most recent available quarter."Q3 2024"
MarketCapitalizationlong?The market capitalization.2320000000000
EBITDAstring?EBITDA."11200000000"
PERatiostring?The Price-to-Earnings ratio."27.5"
PEGRatiostring?The Price/Earnings-to-Growth ratio."1.4"
BookValuestring?The company's book value."10.52"
DividendPerSharestring?The dividend per share."0.82"
DividendYieldstring?The dividend yield."1.5%"
EPSstring?Earnings per share."5.26"
RevenuePerShareTTMstring?Revenue per share for the trailing twelve months."30.5"
ProfitMarginstring?Profit margin."25%"
OperatingMarginTTMstring?Operating margin for the trailing twelve months."22%"
ReturnOnAssetsTTMstring?Return on assets for the trailing twelve months."14%"
ReturnOnEquityTTMstring?Return on equity for the trailing twelve months."40%"
RevenueTTMstring?Revenue for the trailing twelve months."386000000000"
GrossProfitTTMstring?Gross profit for the trailing twelve months."160000000000"
DilutedEPSTTMstring?Diluted earnings per share for the trailing twelve months."5.10"
QuarterlyEarningsGrowthYOYstring?Quarterly earnings growth year-over-year."15%"
QuarterlyRevenueGrowthYOYstring?Quarterly revenue growth year-over-year."10%"
AnalystTargetPricestring?Analyst target price for the stock."175.00"
AnalystRatingStrongBuystring?Percentage of analysts recommending a strong buy."60%"
AnalystRatingBuystring?Percentage of analysts recommending a buy."30%"
AnalystRatingHoldstring?Percentage of analysts recommending a hold."10%"
AnalystRatingSellstring?Percentage of analysts recommending a sell."0%"
AnalystRatingStrongSellstring?Percentage of analysts recommending a strong sell."0%"
TrailingPEstring?Trailing Price-to-Earnings ratio."28"
ForwardPEstring?Forward Price-to-Earnings ratio."25"
PriceToSalesRatioTTMstring?Price-to-Sales ratio for the trailing twelve months."6.5"
PriceToBookRatiostring?Price-to-Book ratio."4.3"
EVToRevenuestring?Enterprise value-to-revenue ratio."8.2"
EVToEBITDAstring?Enterprise value-to-EBITDA ratio."14.5"
Betastring?Beta value, measuring stock volatility."1.2"
FiftySecondWeekHighstring?52-week high stock price."179.50"
FiftySecondWeekLowstring?52-week low stock price."120.10"
FiftyDayMovingAveragestring?50-day moving average."153.25"
TwoHundredDayMovingAveragestring?200-day moving average."157.80"
SharesOutstandingstring?Number of shares outstanding."5000000000"
DividendDatestring?Next dividend payment date."2025-02-01"
ExDividendDatestring?Ex-dividend date."2025-01-10"

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve the overview for Apple Inc.varoverview=awaitalphaVantageService.GetOverviewAsync("AAPL");if(overview!=null){Console.WriteLine($"Symbol: {overview.Symbol}");Console.WriteLine($"Name: {overview.Name}");Console.WriteLine($"Sector: {overview.Sector}");Console.WriteLine($"Market Capitalization: {overview.MarketCapitalization}");Console.WriteLine($"Dividend Yield: {overview.DividendYield}");Console.WriteLine($"P/E Ratio: {overview.PERatio}");Console.WriteLine($"Revenue (TTM): {overview.RevenueTTM}");}}
GetRecordsAsync

Description

Retrieves historical daily stock records for a given symbol within an optional date range.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for the records. Defaults to 7 days ago.
  • DateTime? endDate: (Optional) End date for the records. Defaults to current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<Record>, with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record."2024-12-15"
Opendouble?The opening price of the asset.150.25
Lowdouble?The lowest price of the asset on that date.148.75
Highdouble?The highest price of the asset on that date.153.50
Closedouble?The closing price of the asset.151.00
AdjustedClosedouble?The adjusted closing price, considering stock splits and dividends.150.80
Volumelong?The trading volume of the asset on that date.1000000
SplitCoefficientdouble?The stock split coefficient, if any, for the given date.1.0

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical records for Apple Inc. (AAPL)varrecords=awaitalphaVantageService.GetRecordsAsync("AAPL",DateTime.Now.AddDays(-7),DateTime.Now);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date.ToShortDateString()}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"High: {record.High}");Console.WriteLine($"Low: {record.Low}");Console.WriteLine($"Close: {record.Close}");Console.WriteLine($"Adjusted Close: {record.AdjustedClose}");Console.WriteLine($"Volume: {record.Volume}");Console.WriteLine($"Split Coefficient: {record.SplitCoefficient}");Console.WriteLine();}}
GetForexRecordsAsync

Description

Retrieves historical daily forex (foreign exchange) records for a given currency pair within a specified date range.

Parameters

  • string currency1: The source currency (e.g., "USD").
  • string currency2: The target currency (e.g., "EUR").
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<ForexRecord>, with the following properties:

PropertyTypeDescriptionExample
DateDateTime?The date of the forex record."2024-12-15"
Opendouble?The opening price of the currency pair for that date.1.1215
Highdouble?The highest price of the currency pair for that date.1.1250
Lowdouble?The lowest price of the currency pair for that date.1.1180
Closedouble?The closing price of the currency pair for that date.1.1220

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical forex records for USD to EURvarforexRecords=awaitalphaVantageService.GetForexRecordsAsync("USD","EUR",DateTime.Now.AddDays(-7));foreach(varrecordinforexRecords){Console.WriteLine($"Date: {record.Date}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}
GetIntradayRecordsAsync

Description

Retrieves intraday stock records for a given symbol within a specified date range and time interval.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • EInterval interval: The time interval between data points. Default is 15 minutes. Possible values:
    • Interval_1Min
    • Interval_5Min
    • Interval_15Min
    • Interval_30Min
    • Interval_60Min
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<IntradayRecord>, with the following properties:

PropertyTypeDescriptionExample
DateTimeDateTimeThe date and time of the record."2024-12-15 09:30"
OpendoubleThe opening price of the stock for that interval.145.32
HighdoubleThe highest price of the stock for that interval.147.10
LowdoubleThe lowest price of the stock for that interval.144.98
ClosedoubleThe closing price of the stock for that interval.146.30
VolumelongThe trading volume during that interval.1234567

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve intraday stock records for AAPL with a 15-minute intervalvarintradayRecords=awaitalphaVantageService.GetIntradayRecordsAsync("AAPL",DateTime.Now.AddDays(-1),DateTime.Now,EInterval.Interval_15Min);foreach(varrecordinintradayRecords){Console.WriteLine($"DateTime: {record.DateTime}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}

DataHub

Accesses datasets like Nasdaq and S&P 500 companies.

Methods

GetNasdaqInstrumentsAsync

Description

Retrieves a collection of more than 4,000 Nasdaq instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<NasdaqInstrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.TSLA
Namestring?The company name associated with the instrument.Tesla, Inc.

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetNasdaqInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}");}}
GetSp500InstrumentsAsync

Description

Retrieves a collection of S&P 500 instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Sp500Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the instrument.TSLA
Namestring?Name of the instrument/company.Tesla, Inc.
Sectorstring?Sector of the instrument.Automobile Manufacturers
Pricedouble?Current price of the instrument.345.16
PriceEarningsdouble?Price-to-earnings ratio.94.31
DividendYielddouble?Dividend yield.0.89
EarningsSharedouble?Earnings per share.3.66
FiftyTwoWeekLowdouble?52-week low price.338.8
FiftyTwoWeekHighdouble?52-week high price.361.93
MarketCaplong?Market capitalization.1107284384000
EBITDAlong?EBITDA value.13244000256
PriceSalesdouble?Price-to-sales ratio.11.41
PriceBookdouble?Price-to-book ratio.15.82

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetSp500InstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}, Sector: {item.Sector}");}}

Xetra

A major European trading platform offering data on Xetra-listed instruments.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of more than 3,000 Xetra instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the financial instrument.TL0.DE
InstrumentStatusstring?Current status of the instrument.Active
InstrumentNamestring?Full name of the financial instrument.TESLA INC. DL -,001
ISINstring?International Securities Identification Number.US88160R1014
WKNstring?German securities identification number.000A1CX3T
Mnemonicstring?Shorthand or mnemonic code for the instrument.TL0
InstrumentTypestring?Type of financial instrument (e.g., CS, ETF, ETN).CS
Currencystring?Currency in which the instrument is traded.EUR

Example

publicasyncTaskRun(IXetraServicexetraService){varinstruments=awaitxetraService.GetInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.InstrumentName}");}}

🤝 How to Contribute

We welcome contributions to Finance.NET! If you’d like to improve the project, please:

  1. Check out our contributing guidelines.
  2. Ideally, open an issue before starting work.
  3. Submit a pull request with your changes.

Thank you for helping make Finance.NET better!


ℹ️ Disclaimer

Finance.NET is an open-source project using publicly accessible APIs and scraping techniques. It is intended for educational and research purposes.

For legal usage, refer to the terms of each data provider:

For additional licensing and attribution details, see NOTICE.md.


🐞 Report a Bug

If you encounter any issues or bugs, please report them here.

About

A .NET library for retrieving real-time and historical financial data from Yahoo Finance and other popular sources.

Topics

Resources

Code of conduct

Contributing

Stars

22 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Banner

CICoverageQuality GateNuGetDownloads.NET StandardStars

An easy-to-use .NET library for accessing and aggregating financial data from multiple sources.

This library enables developers to retrieve financial data via APIs and HTML scraping from a variety of providers. It's ideal for building analytical tools, dashboards, or financial applications that require access to market data.


⭐ Features

  • Retrieve Instruments: Get tradable ticker symbols and associated details.
  • Fundamentals: Access key financial metrics and company fundamentals.
  • Historical Records: Fetch historical data for analysis or charting.
  • Real-Time Quotes: Receive live updates on stock prices and market data.

🚀 Getting started

This section guides you through installing Finance.NET, configuring services, and basic data retrieval.

Installation

Install via NuGet:

dotnet add package Finance.NET

Register in Service Collection

Add Finance.NET to your service collection for dependency injection:

services.AddFinanceNet();

Optional: Configure with custom settings.

services.AddFinanceNet(newFinanceNetConfiguration{HttpTimeout=5,// seconds (default: 20)HttpRetryCount=3,// default: 10HttpRetrySleepTime=5,// seconds, base for exponential back-off; capped at 30s per attempt, plus jitter (default: 5)AlphaVantageApiKey="ALPHA_VANTAGE__API_KEY"});

Basic Usage

Example: Retrieve historical and real-time data for Tesla (TSLA):

publicasyncTaskRun(IYahooFinanceServiceyahooService){varsymbol="TSLA";varstartDate=newDateTime(2020,1,1);varrecords=awaityahooService.GetRecordsAsync(symbol,startDate);foreach(varrecordinrecords){Console.WriteLine($"Date={record.Date}: {record.Open} / {record.Close}");}varquote=awaityahooService.GetQuoteAsync(symbol);Console.WriteLine($"Bid={quote.Bid}, Ask={quote.Ask}");}

🔌Finance.NET Service Interfaces

Finance.NET exposes modular service interfaces for accessing diverse financial data through a consistent API. Each interface corresponds to a specific provider and supports its unique features.

Yahoo! Finance

Provides market data, company fundamentals, historical records, and real-time quotes.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of financial instruments.

Parameters

  • EInstrumentType? filterByType: An optional filter to specify the type of asset. If not provided, all asset types will be included. Possible values:
    • Stock: Most active stocks.
    • ETF: Most active exchange-traded funds (ETFs)
    • Forex: Available currencies (foreign exchange).
    • Crypto: Available cryptocurrencies.
    • Index: Available world indices.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.AAPL
InstrumentTypeEInstrumentType?The type of the financial instrument.Stock

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve all instrumentsvarinstruments=awaityahooService.GetInstrumentsAsync();// Retrieve only stock instrumentsvarstockInstruments=awaityahooService.GetInstrumentsAsync(EInstrumentType.Stock);foreach(varinstrumentinstockInstruments){Console.WriteLine($"Symbol: {instrument.Symbol}, Type: {instrument.InstrumentType}");}}
GetProfileAsync

Description

Retrieves the profile of a specific entity based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Profile containing the following properties:

PropertyTypeDescriptionExample
Adressstring?The address.One Apple Park Way, Cupertino, CA 95014
Phonestring?The phone number.+1-800-MY-APPLE
Websitestring?The website URL.https://www.apple.com
Sectorstring?The sector in which the entity operates.Technology
Industrystring?The industry the entity belongs to.Consumer Electronics
CntEmployeeslong?The number of employees.164000
Descriptionstring?A brief description.Apple designs and ...

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){varprofile=awaityahooService.GetProfileAsync("AAPL");Console.WriteLine($"Address: {profile.Adress}");Console.WriteLine($"Sector: {profile.Sector}");Console.WriteLine($"Industry: {profile.Industry}");Console.WriteLine($"Description: {profile.Description}");}
GetSummaryAsync

Description

Retrieves the summary of a specific asset based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Summary containing the following properties:

PropertyTypeDescriptionExample
Namestring?Name of the asset.Apple Inc.
MarketTimeNoticestring?Notice of market status.Market Closed
PreviousClosedecimal?Previous closing price.180.14
Opendecimal?Opening price of the stock.182.20
Biddecimal?Current bid price.180.00
Askdecimal?Current ask price.181.00
DaysRange_Mindecimal?Minimum price today.179.50
DaysRange_Maxdecimal?Maximum price today.183.00
WeekRange52_Mindecimal?Minimum price in 52 weeks.130.20
WeekRange52_Maxdecimal?Maximum price in 52 weeks.190.50
Volumedecimal?Total volume traded today.25,000,000
AvgVolumedecimal?Average daily volume.30,000,000
MarketCap_Intradaydecimal?Market cap in the current session.2.85T
Beta_5Y_Monthlydecimal?5-year beta (monthly data).1.20
PE_Ratio_TTMdecimal?Price-to-earnings ratio (TTM).28.90
EPS_TTMdecimal?Earnings per share (TTM).6.22
EarningsDateDateTime?Date of the next earnings report.2025-02-15
Forward_Dividenddecimal?Expected forward dividend.0.88
Forward_Yielddecimal?Forward dividend yield.0.49%
Ex_DividendDateDateTime?Ex-dividend date.2025-01-10
OneYearTargetEstdecimal?One-year target price estimate.200.00

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve the summary for Apple Inc.varsummary=awaityahooService.GetSummaryAsync("AAPL");Console.WriteLine($"Name: {summary.Name}");Console.WriteLine($"Previous Close: {summary.PreviousClose}");Console.WriteLine($"Open: {summary.Open}");Console.WriteLine($"Bid: {summary.Bid}");Console.WriteLine($"Ask: {summary.Ask}");Console.WriteLine($"Average Volume: {summary.AvgVolume}");Console.WriteLine($"EPS (TTM): {summary.EPS_TTM}");}
GetFinancialsAsync

Description

Retrieves the financial reports for a specified asset identified by its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Dictionary<string, FinancialReport> where the key is the label (e.g., "Annual Report 2024") and the value is a FinancialReport containing the following properties:

PropertyTypeDescriptionExample
TickerSymbolstring?The company's stock symbol.AAPL
TotalRevenuedecimal?Total revenue generated.394,328,000,000
CostOfRevenuedecimal?Direct costs of goods/services sold.213,459,000,000
GrossProfitdecimal?Gross profit (Revenue - Cost of Revenue).180,869,000,000
OperatingExpensedecimal?Operating expenses incurred.34,152,000,000
OperatingIncomedecimal?Operating income (Gross Profit - Operating Expenses).146,717,000,000
NetNonOperatingInterestIncomeExpensedecimal?Net non-operating interest income/expense.2,500,000,000
OtherIncomeExpensedecimal?Other non-core income/expenses.-1,200,000,000
PretaxIncomedecimal?Pretax income before taxes.148,017,000,000
TaxProvisiondecimal?Income taxes provisioned.25,000,000,000
NetIncomeCommonStockholdersdecimal?Net income for common stockholders.123,017,000,000
DilutedNIAvailableToComStockholdersdecimal?Diluted net income for common stockholders.120,517,000,000
BasicEPSdecimal?Basic earnings per share.6.25
DilutedEPSdecimal?Diluted earnings per share.6.15
BasicAverageSharesdecimal?Basic average shares for EPS.19,700,000,000
DilutedAverageSharesdecimal?Diluted average shares for EPS.19,600,000,000
TotalOperatingIncomeAsReporteddecimal?Reported total operating income.146,700,000,000
TotalExpensesdecimal?Total expenses incurred.247,611,000,000
NetIncomeFromContinuingAndDiscontinuedOperationdecimal?Net income from all operations.123,017,000,000
NormalizedIncomedecimal?Normalized income adjusted for irregularities.125,500,000,000
InterestIncomedecimal?Interest income earned.5,000,000,000
InterestExpensedecimal?Interest expense incurred.2,500,000,000
NetInterestIncomedecimal?Net interest income (Income - Expense).2,500,000,000
EBITdecimal?Earnings Before Interest and Taxes.148,217,000,000
EBITDAdecimal?Earnings Before Interest, Taxes, Depreciation, and Amortization.151,217,000,000
ReconciledCostOfRevenuedecimal?Adjusted cost of revenue.212,000,000,000
ReconciledDepreciationdecimal?Adjusted depreciation expense.3,000,000,000
NetIncomeFromContinuingOperationNetMinorityInterestdecimal?Net income from continuing operations.121,017,000,000
TotalUnusualItemsExcludingGoodwilldecimal?Total unusual items, excluding goodwill.-2,000,000,000
TotalUnusualItemsdecimal?Total unusual items, including goodwill.-2,000,000,000
NormalizedEBITDAdecimal?Adjusted EBITDA for unusual items.153,217,000,000
TaxRateForCalcsdecimal?Tax rate used in calculations.16.9%
TaxEffectOfUnusualItemsdecimal?Tax effect of unusual items.-500,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve financial reports for Apple Inc.varfinancialReports=awaityahooService.GetFinancialsAsync("AAPL");foreach(varlabelinfinancialReports.Keys){varreport=financialReports[label];Console.WriteLine($"Label: {label}");Console.WriteLine($"Ticker Symbol: {report.TickerSymbol}");Console.WriteLine($"Total Revenue: {report.TotalRevenue}");Console.WriteLine($"Cost of Revenue: {report.CostOfRevenue}");Console.WriteLine($"Gross Profit: {report.GrossProfit}");Console.WriteLine($"Operating Income: {report.OperatingIncome}");Console.WriteLine($"Net Income: {report.NetIncomeCommonStockholders}");Console.WriteLine();}}
GetRecordsAsync

Description

Retrieves historical stock market data records for a specified asset identified by its symbol. Users can specify an optional date range.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for retrieving historical records. Defaults to 7 days before the current date if not provided.
  • DateTime? endDate: (Optional) End date for retrieving historical records. Defaults to the current date if not provided.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Record>, where each Record represents a historical data point with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record.2025-01-01
Opendecimal?The opening price.150.25
Highdecimal?The highest price during the trading session.155.00
Lowdecimal?The lowest price during the trading session.148.50
Closedecimal?The closing price at the end of the trading session.152.75
AdjustedClosedecimal?The adjusted closing price, accounting for stock splits and dividends.153.00
Volumelong?The trading volume (number of shares traded).10,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve historical records for Apple Inc. for the last 30 daysvarstartDate=DateTime.UtcNow.AddDays(-30);varendDate=DateTime.UtcNow;varrecords=awaityahooService.GetRecordsAsync("AAPL",startDate,endDate);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date:yyyy-MM-dd}");Console.WriteLine($"Open: {record.Open:C}");Console.WriteLine($"Close: {record.Close:C}");Console.WriteLine();}}
GetQuoteAsync

Description

Retrieves detailed information about a specific financial quote, identified by its symbol. This API is useful for accessing comprehensive data about a stock, ETF, or other traded financial instruments.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A cancellation token that can be used to cancel the operation if needed.

Returns

A task that resolves to a Quote object. The Quote record contains detailed information about the requested financial instrument, as described in the table below.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskDisplayQuote(IYahooFinanceServiceyahooService){// Retrieve a quote for Apple Inc.varquote=awaityahooService.GetQuoteAsync("AAPL");Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.ShortName}");Console.WriteLine($"Market Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Currency: {quote.Currency}");}
GetQuotesAsync

Description

Retrieves quote data for multiple financial instruments identified by their symbols. The data includes detailed information about each instrument, such as pricing, market performance, and other financial metrics.

Parameters

  • List<string> symbols: A list of symbols for which to retrieve data (e.g., ["AAPL", "MSFT", "GOOGL"]).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Quote>, where each Quote provides comprehensive data about a specific instrument.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve quotes for Apple, Microsoft, and Googlevarsymbols=newList<string>{"AAPL","MSFT","GOOGL"};varquotes=awaityahooService.GetQuotesAsync(symbols);foreach(varquoteinquotes){Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.DisplayName}");Console.WriteLine($"Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Dividend Yield: {quote.DividendYield:P}");Console.WriteLine($"Earnings Date: {quote.EarningsDate:yyyy-MM-dd}");Console.WriteLine();}}

Alpha Vantage

Offers stock, forex, and cryptocurrency data including intraday and historical records.

Get an API key

To get started, obtain a free API key from Alpha Vantage.

Configure API key

After acquiring your API key, configure it in your service collection:

services.AddFinanceNet(newFinanceNetConfiguration{AlphaVantageApiKey="API_KEY"});

Methods

GetOverviewAsync

Description

Retrieves an instrument overview for a specified stock symbol.

Parameters

  • string symbol: The symbol of the asset (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A token to cancel the operation if needed.

Returns

A task that resolves to an InstrumentOverview?. The InstrumentOverview contains the following properties that provide key information about the company:

PropertyTypeDescriptionExample
Symbolstring?The stock symbol."AAPL"
AssetTypestring?The type of asset (e.g., stock, ETF)."Equity"
Namestring?The name of the ticker or company."Apple Inc."
Descriptionstring?A brief company description."Designs ... ."
CIKstring?The Central Index Key (CIK) of the company."0000320193"
Exchangestring?The exchange where the company is listed."NASDAQ"
Currencystring?The currency used for financials."USD"
Countrystring?The country where the company is located."United States"
Sectorstring?The company's sector (e.g., Technology)."Technology"
Industrystring?The industry the company operates in."Consumer Electronics"
Addressstring?The company's headquarters address."Cupertino, CA"
OfficialSitestring?The official website of the company."https://www.apple.com"
FiscalYearEndstring?The fiscal year end date."September 30"
LatestQuarterstring?The most recent available quarter."Q3 2024"
MarketCapitalizationlong?The market capitalization.2320000000000
EBITDAstring?EBITDA."11200000000"
PERatiostring?The Price-to-Earnings ratio."27.5"
PEGRatiostring?The Price/Earnings-to-Growth ratio."1.4"
BookValuestring?The company's book value."10.52"
DividendPerSharestring?The dividend per share."0.82"
DividendYieldstring?The dividend yield."1.5%"
EPSstring?Earnings per share."5.26"
RevenuePerShareTTMstring?Revenue per share for the trailing twelve months."30.5"
ProfitMarginstring?Profit margin."25%"
OperatingMarginTTMstring?Operating margin for the trailing twelve months."22%"
ReturnOnAssetsTTMstring?Return on assets for the trailing twelve months."14%"
ReturnOnEquityTTMstring?Return on equity for the trailing twelve months."40%"
RevenueTTMstring?Revenue for the trailing twelve months."386000000000"
GrossProfitTTMstring?Gross profit for the trailing twelve months."160000000000"
DilutedEPSTTMstring?Diluted earnings per share for the trailing twelve months."5.10"
QuarterlyEarningsGrowthYOYstring?Quarterly earnings growth year-over-year."15%"
QuarterlyRevenueGrowthYOYstring?Quarterly revenue growth year-over-year."10%"
AnalystTargetPricestring?Analyst target price for the stock."175.00"
AnalystRatingStrongBuystring?Percentage of analysts recommending a strong buy."60%"
AnalystRatingBuystring?Percentage of analysts recommending a buy."30%"
AnalystRatingHoldstring?Percentage of analysts recommending a hold."10%"
AnalystRatingSellstring?Percentage of analysts recommending a sell."0%"
AnalystRatingStrongSellstring?Percentage of analysts recommending a strong sell."0%"
TrailingPEstring?Trailing Price-to-Earnings ratio."28"
ForwardPEstring?Forward Price-to-Earnings ratio."25"
PriceToSalesRatioTTMstring?Price-to-Sales ratio for the trailing twelve months."6.5"
PriceToBookRatiostring?Price-to-Book ratio."4.3"
EVToRevenuestring?Enterprise value-to-revenue ratio."8.2"
EVToEBITDAstring?Enterprise value-to-EBITDA ratio."14.5"
Betastring?Beta value, measuring stock volatility."1.2"
FiftySecondWeekHighstring?52-week high stock price."179.50"
FiftySecondWeekLowstring?52-week low stock price."120.10"
FiftyDayMovingAveragestring?50-day moving average."153.25"
TwoHundredDayMovingAveragestring?200-day moving average."157.80"
SharesOutstandingstring?Number of shares outstanding."5000000000"
DividendDatestring?Next dividend payment date."2025-02-01"
ExDividendDatestring?Ex-dividend date."2025-01-10"

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve the overview for Apple Inc.varoverview=awaitalphaVantageService.GetOverviewAsync("AAPL");if(overview!=null){Console.WriteLine($"Symbol: {overview.Symbol}");Console.WriteLine($"Name: {overview.Name}");Console.WriteLine($"Sector: {overview.Sector}");Console.WriteLine($"Market Capitalization: {overview.MarketCapitalization}");Console.WriteLine($"Dividend Yield: {overview.DividendYield}");Console.WriteLine($"P/E Ratio: {overview.PERatio}");Console.WriteLine($"Revenue (TTM): {overview.RevenueTTM}");}}
GetRecordsAsync

Description

Retrieves historical daily stock records for a given symbol within an optional date range.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for the records. Defaults to 7 days ago.
  • DateTime? endDate: (Optional) End date for the records. Defaults to current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<Record>, with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record."2024-12-15"
Opendouble?The opening price of the asset.150.25
Lowdouble?The lowest price of the asset on that date.148.75
Highdouble?The highest price of the asset on that date.153.50
Closedouble?The closing price of the asset.151.00
AdjustedClosedouble?The adjusted closing price, considering stock splits and dividends.150.80
Volumelong?The trading volume of the asset on that date.1000000
SplitCoefficientdouble?The stock split coefficient, if any, for the given date.1.0

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical records for Apple Inc. (AAPL)varrecords=awaitalphaVantageService.GetRecordsAsync("AAPL",DateTime.Now.AddDays(-7),DateTime.Now);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date.ToShortDateString()}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"High: {record.High}");Console.WriteLine($"Low: {record.Low}");Console.WriteLine($"Close: {record.Close}");Console.WriteLine($"Adjusted Close: {record.AdjustedClose}");Console.WriteLine($"Volume: {record.Volume}");Console.WriteLine($"Split Coefficient: {record.SplitCoefficient}");Console.WriteLine();}}
GetForexRecordsAsync

Description

Retrieves historical daily forex (foreign exchange) records for a given currency pair within a specified date range.

Parameters

  • string currency1: The source currency (e.g., "USD").
  • string currency2: The target currency (e.g., "EUR").
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<ForexRecord>, with the following properties:

PropertyTypeDescriptionExample
DateDateTime?The date of the forex record."2024-12-15"
Opendouble?The opening price of the currency pair for that date.1.1215
Highdouble?The highest price of the currency pair for that date.1.1250
Lowdouble?The lowest price of the currency pair for that date.1.1180
Closedouble?The closing price of the currency pair for that date.1.1220

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical forex records for USD to EURvarforexRecords=awaitalphaVantageService.GetForexRecordsAsync("USD","EUR",DateTime.Now.AddDays(-7));foreach(varrecordinforexRecords){Console.WriteLine($"Date: {record.Date}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}
GetIntradayRecordsAsync

Description

Retrieves intraday stock records for a given symbol within a specified date range and time interval.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • EInterval interval: The time interval between data points. Default is 15 minutes. Possible values:
    • Interval_1Min
    • Interval_5Min
    • Interval_15Min
    • Interval_30Min
    • Interval_60Min
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<IntradayRecord>, with the following properties:

PropertyTypeDescriptionExample
DateTimeDateTimeThe date and time of the record."2024-12-15 09:30"
OpendoubleThe opening price of the stock for that interval.145.32
HighdoubleThe highest price of the stock for that interval.147.10
LowdoubleThe lowest price of the stock for that interval.144.98
ClosedoubleThe closing price of the stock for that interval.146.30
VolumelongThe trading volume during that interval.1234567

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve intraday stock records for AAPL with a 15-minute intervalvarintradayRecords=awaitalphaVantageService.GetIntradayRecordsAsync("AAPL",DateTime.Now.AddDays(-1),DateTime.Now,EInterval.Interval_15Min);foreach(varrecordinintradayRecords){Console.WriteLine($"DateTime: {record.DateTime}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}

DataHub

Accesses datasets like Nasdaq and S&P 500 companies.

Methods

GetNasdaqInstrumentsAsync

Description

Retrieves a collection of more than 4,000 Nasdaq instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<NasdaqInstrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.TSLA
Namestring?The company name associated with the instrument.Tesla, Inc.

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetNasdaqInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}");}}
GetSp500InstrumentsAsync

Description

Retrieves a collection of S&P 500 instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Sp500Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the instrument.TSLA
Namestring?Name of the instrument/company.Tesla, Inc.
Sectorstring?Sector of the instrument.Automobile Manufacturers
Pricedouble?Current price of the instrument.345.16
PriceEarningsdouble?Price-to-earnings ratio.94.31
DividendYielddouble?Dividend yield.0.89
EarningsSharedouble?Earnings per share.3.66
FiftyTwoWeekLowdouble?52-week low price.338.8
FiftyTwoWeekHighdouble?52-week high price.361.93
MarketCaplong?Market capitalization.1107284384000
EBITDAlong?EBITDA value.13244000256
PriceSalesdouble?Price-to-sales ratio.11.41
PriceBookdouble?Price-to-book ratio.15.82

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetSp500InstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}, Sector: {item.Sector}");}}

Xetra

A major European trading platform offering data on Xetra-listed instruments.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of more than 3,000 Xetra instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the financial instrument.TL0.DE
InstrumentStatusstring?Current status of the instrument.Active
InstrumentNamestring?Full name of the financial instrument.TESLA INC. DL -,001
ISINstring?International Securities Identification Number.US88160R1014
WKNstring?German securities identification number.000A1CX3T
Mnemonicstring?Shorthand or mnemonic code for the instrument.TL0
InstrumentTypestring?Type of financial instrument (e.g., CS, ETF, ETN).CS
Currencystring?Currency in which the instrument is traded.EUR

Example

publicasyncTaskRun(IXetraServicexetraService){varinstruments=awaitxetraService.GetInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.InstrumentName}");}}

🤝 How to Contribute

We welcome contributions to Finance.NET! If you’d like to improve the project, please:

  1. Check out our contributing guidelines.
  2. Ideally, open an issue before starting work.
  3. Submit a pull request with your changes.

Thank you for helping make Finance.NET better!


ℹ️ Disclaimer

Finance.NET is an open-source project using publicly accessible APIs and scraping techniques. It is intended for educational and research purposes.

For legal usage, refer to the terms of each data provider:

For additional licensing and attribution details, see NOTICE.md.


🐞 Report a Bug

If you encounter any issues or bugs, please report them here.

About

A .NET library for retrieving real-time and historical financial data from Yahoo Finance and other popular sources.

Topics

Resources

Code of conduct

Contributing

Stars

22 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Banner

CICoverageQuality GateNuGetDownloads.NET StandardStars

An easy-to-use .NET library for accessing and aggregating financial data from multiple sources.

This library enables developers to retrieve financial data via APIs and HTML scraping from a variety of providers. It's ideal for building analytical tools, dashboards, or financial applications that require access to market data.


⭐ Features

  • Retrieve Instruments: Get tradable ticker symbols and associated details.
  • Fundamentals: Access key financial metrics and company fundamentals.
  • Historical Records: Fetch historical data for analysis or charting.
  • Real-Time Quotes: Receive live updates on stock prices and market data.

🚀 Getting started

This section guides you through installing Finance.NET, configuring services, and basic data retrieval.

Installation

Install via NuGet:

dotnet add package Finance.NET

Register in Service Collection

Add Finance.NET to your service collection for dependency injection:

services.AddFinanceNet();

Optional: Configure with custom settings.

services.AddFinanceNet(newFinanceNetConfiguration{HttpTimeout=5,// seconds (default: 20)HttpRetryCount=3,// default: 10HttpRetrySleepTime=5,// seconds, base for exponential back-off; capped at 30s per attempt, plus jitter (default: 5)AlphaVantageApiKey="ALPHA_VANTAGE__API_KEY"});

Basic Usage

Example: Retrieve historical and real-time data for Tesla (TSLA):

publicasyncTaskRun(IYahooFinanceServiceyahooService){varsymbol="TSLA";varstartDate=newDateTime(2020,1,1);varrecords=awaityahooService.GetRecordsAsync(symbol,startDate);foreach(varrecordinrecords){Console.WriteLine($"Date={record.Date}: {record.Open} / {record.Close}");}varquote=awaityahooService.GetQuoteAsync(symbol);Console.WriteLine($"Bid={quote.Bid}, Ask={quote.Ask}");}

🔌Finance.NET Service Interfaces

Finance.NET exposes modular service interfaces for accessing diverse financial data through a consistent API. Each interface corresponds to a specific provider and supports its unique features.

Yahoo! Finance

Provides market data, company fundamentals, historical records, and real-time quotes.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of financial instruments.

Parameters

  • EInstrumentType? filterByType: An optional filter to specify the type of asset. If not provided, all asset types will be included. Possible values:
    • Stock: Most active stocks.
    • ETF: Most active exchange-traded funds (ETFs)
    • Forex: Available currencies (foreign exchange).
    • Crypto: Available cryptocurrencies.
    • Index: Available world indices.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.AAPL
InstrumentTypeEInstrumentType?The type of the financial instrument.Stock

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve all instrumentsvarinstruments=awaityahooService.GetInstrumentsAsync();// Retrieve only stock instrumentsvarstockInstruments=awaityahooService.GetInstrumentsAsync(EInstrumentType.Stock);foreach(varinstrumentinstockInstruments){Console.WriteLine($"Symbol: {instrument.Symbol}, Type: {instrument.InstrumentType}");}}
GetProfileAsync

Description

Retrieves the profile of a specific entity based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Profile containing the following properties:

PropertyTypeDescriptionExample
Adressstring?The address.One Apple Park Way, Cupertino, CA 95014
Phonestring?The phone number.+1-800-MY-APPLE
Websitestring?The website URL.https://www.apple.com
Sectorstring?The sector in which the entity operates.Technology
Industrystring?The industry the entity belongs to.Consumer Electronics
CntEmployeeslong?The number of employees.164000
Descriptionstring?A brief description.Apple designs and ...

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){varprofile=awaityahooService.GetProfileAsync("AAPL");Console.WriteLine($"Address: {profile.Adress}");Console.WriteLine($"Sector: {profile.Sector}");Console.WriteLine($"Industry: {profile.Industry}");Console.WriteLine($"Description: {profile.Description}");}
GetSummaryAsync

Description

Retrieves the summary of a specific asset based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Summary containing the following properties:

PropertyTypeDescriptionExample
Namestring?Name of the asset.Apple Inc.
MarketTimeNoticestring?Notice of market status.Market Closed
PreviousClosedecimal?Previous closing price.180.14
Opendecimal?Opening price of the stock.182.20
Biddecimal?Current bid price.180.00
Askdecimal?Current ask price.181.00
DaysRange_Mindecimal?Minimum price today.179.50
DaysRange_Maxdecimal?Maximum price today.183.00
WeekRange52_Mindecimal?Minimum price in 52 weeks.130.20
WeekRange52_Maxdecimal?Maximum price in 52 weeks.190.50
Volumedecimal?Total volume traded today.25,000,000
AvgVolumedecimal?Average daily volume.30,000,000
MarketCap_Intradaydecimal?Market cap in the current session.2.85T
Beta_5Y_Monthlydecimal?5-year beta (monthly data).1.20
PE_Ratio_TTMdecimal?Price-to-earnings ratio (TTM).28.90
EPS_TTMdecimal?Earnings per share (TTM).6.22
EarningsDateDateTime?Date of the next earnings report.2025-02-15
Forward_Dividenddecimal?Expected forward dividend.0.88
Forward_Yielddecimal?Forward dividend yield.0.49%
Ex_DividendDateDateTime?Ex-dividend date.2025-01-10
OneYearTargetEstdecimal?One-year target price estimate.200.00

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve the summary for Apple Inc.varsummary=awaityahooService.GetSummaryAsync("AAPL");Console.WriteLine($"Name: {summary.Name}");Console.WriteLine($"Previous Close: {summary.PreviousClose}");Console.WriteLine($"Open: {summary.Open}");Console.WriteLine($"Bid: {summary.Bid}");Console.WriteLine($"Ask: {summary.Ask}");Console.WriteLine($"Average Volume: {summary.AvgVolume}");Console.WriteLine($"EPS (TTM): {summary.EPS_TTM}");}
GetFinancialsAsync

Description

Retrieves the financial reports for a specified asset identified by its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Dictionary<string, FinancialReport> where the key is the label (e.g., "Annual Report 2024") and the value is a FinancialReport containing the following properties:

PropertyTypeDescriptionExample
TickerSymbolstring?The company's stock symbol.AAPL
TotalRevenuedecimal?Total revenue generated.394,328,000,000
CostOfRevenuedecimal?Direct costs of goods/services sold.213,459,000,000
GrossProfitdecimal?Gross profit (Revenue - Cost of Revenue).180,869,000,000
OperatingExpensedecimal?Operating expenses incurred.34,152,000,000
OperatingIncomedecimal?Operating income (Gross Profit - Operating Expenses).146,717,000,000
NetNonOperatingInterestIncomeExpensedecimal?Net non-operating interest income/expense.2,500,000,000
OtherIncomeExpensedecimal?Other non-core income/expenses.-1,200,000,000
PretaxIncomedecimal?Pretax income before taxes.148,017,000,000
TaxProvisiondecimal?Income taxes provisioned.25,000,000,000
NetIncomeCommonStockholdersdecimal?Net income for common stockholders.123,017,000,000
DilutedNIAvailableToComStockholdersdecimal?Diluted net income for common stockholders.120,517,000,000
BasicEPSdecimal?Basic earnings per share.6.25
DilutedEPSdecimal?Diluted earnings per share.6.15
BasicAverageSharesdecimal?Basic average shares for EPS.19,700,000,000
DilutedAverageSharesdecimal?Diluted average shares for EPS.19,600,000,000
TotalOperatingIncomeAsReporteddecimal?Reported total operating income.146,700,000,000
TotalExpensesdecimal?Total expenses incurred.247,611,000,000
NetIncomeFromContinuingAndDiscontinuedOperationdecimal?Net income from all operations.123,017,000,000
NormalizedIncomedecimal?Normalized income adjusted for irregularities.125,500,000,000
InterestIncomedecimal?Interest income earned.5,000,000,000
InterestExpensedecimal?Interest expense incurred.2,500,000,000
NetInterestIncomedecimal?Net interest income (Income - Expense).2,500,000,000
EBITdecimal?Earnings Before Interest and Taxes.148,217,000,000
EBITDAdecimal?Earnings Before Interest, Taxes, Depreciation, and Amortization.151,217,000,000
ReconciledCostOfRevenuedecimal?Adjusted cost of revenue.212,000,000,000
ReconciledDepreciationdecimal?Adjusted depreciation expense.3,000,000,000
NetIncomeFromContinuingOperationNetMinorityInterestdecimal?Net income from continuing operations.121,017,000,000
TotalUnusualItemsExcludingGoodwilldecimal?Total unusual items, excluding goodwill.-2,000,000,000
TotalUnusualItemsdecimal?Total unusual items, including goodwill.-2,000,000,000
NormalizedEBITDAdecimal?Adjusted EBITDA for unusual items.153,217,000,000
TaxRateForCalcsdecimal?Tax rate used in calculations.16.9%
TaxEffectOfUnusualItemsdecimal?Tax effect of unusual items.-500,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve financial reports for Apple Inc.varfinancialReports=awaityahooService.GetFinancialsAsync("AAPL");foreach(varlabelinfinancialReports.Keys){varreport=financialReports[label];Console.WriteLine($"Label: {label}");Console.WriteLine($"Ticker Symbol: {report.TickerSymbol}");Console.WriteLine($"Total Revenue: {report.TotalRevenue}");Console.WriteLine($"Cost of Revenue: {report.CostOfRevenue}");Console.WriteLine($"Gross Profit: {report.GrossProfit}");Console.WriteLine($"Operating Income: {report.OperatingIncome}");Console.WriteLine($"Net Income: {report.NetIncomeCommonStockholders}");Console.WriteLine();}}
GetRecordsAsync

Description

Retrieves historical stock market data records for a specified asset identified by its symbol. Users can specify an optional date range.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for retrieving historical records. Defaults to 7 days before the current date if not provided.
  • DateTime? endDate: (Optional) End date for retrieving historical records. Defaults to the current date if not provided.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Record>, where each Record represents a historical data point with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record.2025-01-01
Opendecimal?The opening price.150.25
Highdecimal?The highest price during the trading session.155.00
Lowdecimal?The lowest price during the trading session.148.50
Closedecimal?The closing price at the end of the trading session.152.75
AdjustedClosedecimal?The adjusted closing price, accounting for stock splits and dividends.153.00
Volumelong?The trading volume (number of shares traded).10,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve historical records for Apple Inc. for the last 30 daysvarstartDate=DateTime.UtcNow.AddDays(-30);varendDate=DateTime.UtcNow;varrecords=awaityahooService.GetRecordsAsync("AAPL",startDate,endDate);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date:yyyy-MM-dd}");Console.WriteLine($"Open: {record.Open:C}");Console.WriteLine($"Close: {record.Close:C}");Console.WriteLine();}}
GetQuoteAsync

Description

Retrieves detailed information about a specific financial quote, identified by its symbol. This API is useful for accessing comprehensive data about a stock, ETF, or other traded financial instruments.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A cancellation token that can be used to cancel the operation if needed.

Returns

A task that resolves to a Quote object. The Quote record contains detailed information about the requested financial instrument, as described in the table below.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskDisplayQuote(IYahooFinanceServiceyahooService){// Retrieve a quote for Apple Inc.varquote=awaityahooService.GetQuoteAsync("AAPL");Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.ShortName}");Console.WriteLine($"Market Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Currency: {quote.Currency}");}
GetQuotesAsync

Description

Retrieves quote data for multiple financial instruments identified by their symbols. The data includes detailed information about each instrument, such as pricing, market performance, and other financial metrics.

Parameters

  • List<string> symbols: A list of symbols for which to retrieve data (e.g., ["AAPL", "MSFT", "GOOGL"]).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Quote>, where each Quote provides comprehensive data about a specific instrument.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve quotes for Apple, Microsoft, and Googlevarsymbols=newList<string>{"AAPL","MSFT","GOOGL"};varquotes=awaityahooService.GetQuotesAsync(symbols);foreach(varquoteinquotes){Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.DisplayName}");Console.WriteLine($"Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Dividend Yield: {quote.DividendYield:P}");Console.WriteLine($"Earnings Date: {quote.EarningsDate:yyyy-MM-dd}");Console.WriteLine();}}

Alpha Vantage

Offers stock, forex, and cryptocurrency data including intraday and historical records.

Get an API key

To get started, obtain a free API key from Alpha Vantage.

Configure API key

After acquiring your API key, configure it in your service collection:

services.AddFinanceNet(newFinanceNetConfiguration{AlphaVantageApiKey="API_KEY"});

Methods

GetOverviewAsync

Description

Retrieves an instrument overview for a specified stock symbol.

Parameters

  • string symbol: The symbol of the asset (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A token to cancel the operation if needed.

Returns

A task that resolves to an InstrumentOverview?. The InstrumentOverview contains the following properties that provide key information about the company:

PropertyTypeDescriptionExample
Symbolstring?The stock symbol."AAPL"
AssetTypestring?The type of asset (e.g., stock, ETF)."Equity"
Namestring?The name of the ticker or company."Apple Inc."
Descriptionstring?A brief company description."Designs ... ."
CIKstring?The Central Index Key (CIK) of the company."0000320193"
Exchangestring?The exchange where the company is listed."NASDAQ"
Currencystring?The currency used for financials."USD"
Countrystring?The country where the company is located."United States"
Sectorstring?The company's sector (e.g., Technology)."Technology"
Industrystring?The industry the company operates in."Consumer Electronics"
Addressstring?The company's headquarters address."Cupertino, CA"
OfficialSitestring?The official website of the company."https://www.apple.com"
FiscalYearEndstring?The fiscal year end date."September 30"
LatestQuarterstring?The most recent available quarter."Q3 2024"
MarketCapitalizationlong?The market capitalization.2320000000000
EBITDAstring?EBITDA."11200000000"
PERatiostring?The Price-to-Earnings ratio."27.5"
PEGRatiostring?The Price/Earnings-to-Growth ratio."1.4"
BookValuestring?The company's book value."10.52"
DividendPerSharestring?The dividend per share."0.82"
DividendYieldstring?The dividend yield."1.5%"
EPSstring?Earnings per share."5.26"
RevenuePerShareTTMstring?Revenue per share for the trailing twelve months."30.5"
ProfitMarginstring?Profit margin."25%"
OperatingMarginTTMstring?Operating margin for the trailing twelve months."22%"
ReturnOnAssetsTTMstring?Return on assets for the trailing twelve months."14%"
ReturnOnEquityTTMstring?Return on equity for the trailing twelve months."40%"
RevenueTTMstring?Revenue for the trailing twelve months."386000000000"
GrossProfitTTMstring?Gross profit for the trailing twelve months."160000000000"
DilutedEPSTTMstring?Diluted earnings per share for the trailing twelve months."5.10"
QuarterlyEarningsGrowthYOYstring?Quarterly earnings growth year-over-year."15%"
QuarterlyRevenueGrowthYOYstring?Quarterly revenue growth year-over-year."10%"
AnalystTargetPricestring?Analyst target price for the stock."175.00"
AnalystRatingStrongBuystring?Percentage of analysts recommending a strong buy."60%"
AnalystRatingBuystring?Percentage of analysts recommending a buy."30%"
AnalystRatingHoldstring?Percentage of analysts recommending a hold."10%"
AnalystRatingSellstring?Percentage of analysts recommending a sell."0%"
AnalystRatingStrongSellstring?Percentage of analysts recommending a strong sell."0%"
TrailingPEstring?Trailing Price-to-Earnings ratio."28"
ForwardPEstring?Forward Price-to-Earnings ratio."25"
PriceToSalesRatioTTMstring?Price-to-Sales ratio for the trailing twelve months."6.5"
PriceToBookRatiostring?Price-to-Book ratio."4.3"
EVToRevenuestring?Enterprise value-to-revenue ratio."8.2"
EVToEBITDAstring?Enterprise value-to-EBITDA ratio."14.5"
Betastring?Beta value, measuring stock volatility."1.2"
FiftySecondWeekHighstring?52-week high stock price."179.50"
FiftySecondWeekLowstring?52-week low stock price."120.10"
FiftyDayMovingAveragestring?50-day moving average."153.25"
TwoHundredDayMovingAveragestring?200-day moving average."157.80"
SharesOutstandingstring?Number of shares outstanding."5000000000"
DividendDatestring?Next dividend payment date."2025-02-01"
ExDividendDatestring?Ex-dividend date."2025-01-10"

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve the overview for Apple Inc.varoverview=awaitalphaVantageService.GetOverviewAsync("AAPL");if(overview!=null){Console.WriteLine($"Symbol: {overview.Symbol}");Console.WriteLine($"Name: {overview.Name}");Console.WriteLine($"Sector: {overview.Sector}");Console.WriteLine($"Market Capitalization: {overview.MarketCapitalization}");Console.WriteLine($"Dividend Yield: {overview.DividendYield}");Console.WriteLine($"P/E Ratio: {overview.PERatio}");Console.WriteLine($"Revenue (TTM): {overview.RevenueTTM}");}}
GetRecordsAsync

Description

Retrieves historical daily stock records for a given symbol within an optional date range.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for the records. Defaults to 7 days ago.
  • DateTime? endDate: (Optional) End date for the records. Defaults to current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<Record>, with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record."2024-12-15"
Opendouble?The opening price of the asset.150.25
Lowdouble?The lowest price of the asset on that date.148.75
Highdouble?The highest price of the asset on that date.153.50
Closedouble?The closing price of the asset.151.00
AdjustedClosedouble?The adjusted closing price, considering stock splits and dividends.150.80
Volumelong?The trading volume of the asset on that date.1000000
SplitCoefficientdouble?The stock split coefficient, if any, for the given date.1.0

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical records for Apple Inc. (AAPL)varrecords=awaitalphaVantageService.GetRecordsAsync("AAPL",DateTime.Now.AddDays(-7),DateTime.Now);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date.ToShortDateString()}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"High: {record.High}");Console.WriteLine($"Low: {record.Low}");Console.WriteLine($"Close: {record.Close}");Console.WriteLine($"Adjusted Close: {record.AdjustedClose}");Console.WriteLine($"Volume: {record.Volume}");Console.WriteLine($"Split Coefficient: {record.SplitCoefficient}");Console.WriteLine();}}
GetForexRecordsAsync

Description

Retrieves historical daily forex (foreign exchange) records for a given currency pair within a specified date range.

Parameters

  • string currency1: The source currency (e.g., "USD").
  • string currency2: The target currency (e.g., "EUR").
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<ForexRecord>, with the following properties:

PropertyTypeDescriptionExample
DateDateTime?The date of the forex record."2024-12-15"
Opendouble?The opening price of the currency pair for that date.1.1215
Highdouble?The highest price of the currency pair for that date.1.1250
Lowdouble?The lowest price of the currency pair for that date.1.1180
Closedouble?The closing price of the currency pair for that date.1.1220

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical forex records for USD to EURvarforexRecords=awaitalphaVantageService.GetForexRecordsAsync("USD","EUR",DateTime.Now.AddDays(-7));foreach(varrecordinforexRecords){Console.WriteLine($"Date: {record.Date}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}
GetIntradayRecordsAsync

Description

Retrieves intraday stock records for a given symbol within a specified date range and time interval.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • EInterval interval: The time interval between data points. Default is 15 minutes. Possible values:
    • Interval_1Min
    • Interval_5Min
    • Interval_15Min
    • Interval_30Min
    • Interval_60Min
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<IntradayRecord>, with the following properties:

PropertyTypeDescriptionExample
DateTimeDateTimeThe date and time of the record."2024-12-15 09:30"
OpendoubleThe opening price of the stock for that interval.145.32
HighdoubleThe highest price of the stock for that interval.147.10
LowdoubleThe lowest price of the stock for that interval.144.98
ClosedoubleThe closing price of the stock for that interval.146.30
VolumelongThe trading volume during that interval.1234567

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve intraday stock records for AAPL with a 15-minute intervalvarintradayRecords=awaitalphaVantageService.GetIntradayRecordsAsync("AAPL",DateTime.Now.AddDays(-1),DateTime.Now,EInterval.Interval_15Min);foreach(varrecordinintradayRecords){Console.WriteLine($"DateTime: {record.DateTime}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}

DataHub

Accesses datasets like Nasdaq and S&P 500 companies.

Methods

GetNasdaqInstrumentsAsync

Description

Retrieves a collection of more than 4,000 Nasdaq instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<NasdaqInstrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.TSLA
Namestring?The company name associated with the instrument.Tesla, Inc.

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetNasdaqInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}");}}
GetSp500InstrumentsAsync

Description

Retrieves a collection of S&P 500 instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Sp500Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the instrument.TSLA
Namestring?Name of the instrument/company.Tesla, Inc.
Sectorstring?Sector of the instrument.Automobile Manufacturers
Pricedouble?Current price of the instrument.345.16
PriceEarningsdouble?Price-to-earnings ratio.94.31
DividendYielddouble?Dividend yield.0.89
EarningsSharedouble?Earnings per share.3.66
FiftyTwoWeekLowdouble?52-week low price.338.8
FiftyTwoWeekHighdouble?52-week high price.361.93
MarketCaplong?Market capitalization.1107284384000
EBITDAlong?EBITDA value.13244000256
PriceSalesdouble?Price-to-sales ratio.11.41
PriceBookdouble?Price-to-book ratio.15.82

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetSp500InstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}, Sector: {item.Sector}");}}

Xetra

A major European trading platform offering data on Xetra-listed instruments.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of more than 3,000 Xetra instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the financial instrument.TL0.DE
InstrumentStatusstring?Current status of the instrument.Active
InstrumentNamestring?Full name of the financial instrument.TESLA INC. DL -,001
ISINstring?International Securities Identification Number.US88160R1014
WKNstring?German securities identification number.000A1CX3T
Mnemonicstring?Shorthand or mnemonic code for the instrument.TL0
InstrumentTypestring?Type of financial instrument (e.g., CS, ETF, ETN).CS
Currencystring?Currency in which the instrument is traded.EUR

Example

publicasyncTaskRun(IXetraServicexetraService){varinstruments=awaitxetraService.GetInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.InstrumentName}");}}

🤝 How to Contribute

We welcome contributions to Finance.NET! If you’d like to improve the project, please:

  1. Check out our contributing guidelines.
  2. Ideally, open an issue before starting work.
  3. Submit a pull request with your changes.

Thank you for helping make Finance.NET better!


ℹ️ Disclaimer

Finance.NET is an open-source project using publicly accessible APIs and scraping techniques. It is intended for educational and research purposes.

For legal usage, refer to the terms of each data provider:

For additional licensing and attribution details, see NOTICE.md.


🐞 Report a Bug

If you encounter any issues or bugs, please report them here.

About

A .NET library for retrieving real-time and historical financial data from Yahoo Finance and other popular sources.

Topics

Resources

Code of conduct

Contributing

Stars

22 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

Banner

CICoverageQuality GateNuGetDownloads.NET StandardStars

An easy-to-use .NET library for accessing and aggregating financial data from multiple sources.

This library enables developers to retrieve financial data via APIs and HTML scraping from a variety of providers. It's ideal for building analytical tools, dashboards, or financial applications that require access to market data.


⭐ Features

  • Retrieve Instruments: Get tradable ticker symbols and associated details.
  • Fundamentals: Access key financial metrics and company fundamentals.
  • Historical Records: Fetch historical data for analysis or charting.
  • Real-Time Quotes: Receive live updates on stock prices and market data.

🚀 Getting started

This section guides you through installing Finance.NET, configuring services, and basic data retrieval.

Installation

Install via NuGet:

dotnet add package Finance.NET

Register in Service Collection

Add Finance.NET to your service collection for dependency injection:

services.AddFinanceNet();

Optional: Configure with custom settings.

services.AddFinanceNet(newFinanceNetConfiguration{HttpTimeout=5,// seconds (default: 20)HttpRetryCount=3,// default: 10HttpRetrySleepTime=5,// seconds, base for exponential back-off; capped at 30s per attempt, plus jitter (default: 5)AlphaVantageApiKey="ALPHA_VANTAGE__API_KEY"});

Basic Usage

Example: Retrieve historical and real-time data for Tesla (TSLA):

publicasyncTaskRun(IYahooFinanceServiceyahooService){varsymbol="TSLA";varstartDate=newDateTime(2020,1,1);varrecords=awaityahooService.GetRecordsAsync(symbol,startDate);foreach(varrecordinrecords){Console.WriteLine($"Date={record.Date}: {record.Open} / {record.Close}");}varquote=awaityahooService.GetQuoteAsync(symbol);Console.WriteLine($"Bid={quote.Bid}, Ask={quote.Ask}");}

🔌Finance.NET Service Interfaces

Finance.NET exposes modular service interfaces for accessing diverse financial data through a consistent API. Each interface corresponds to a specific provider and supports its unique features.

Yahoo! Finance

Provides market data, company fundamentals, historical records, and real-time quotes.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of financial instruments.

Parameters

  • EInstrumentType? filterByType: An optional filter to specify the type of asset. If not provided, all asset types will be included. Possible values:
    • Stock: Most active stocks.
    • ETF: Most active exchange-traded funds (ETFs)
    • Forex: Available currencies (foreign exchange).
    • Crypto: Available cryptocurrencies.
    • Index: Available world indices.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.AAPL
InstrumentTypeEInstrumentType?The type of the financial instrument.Stock

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve all instrumentsvarinstruments=awaityahooService.GetInstrumentsAsync();// Retrieve only stock instrumentsvarstockInstruments=awaityahooService.GetInstrumentsAsync(EInstrumentType.Stock);foreach(varinstrumentinstockInstruments){Console.WriteLine($"Symbol: {instrument.Symbol}, Type: {instrument.InstrumentType}");}}
GetProfileAsync

Description

Retrieves the profile of a specific entity based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Profile containing the following properties:

PropertyTypeDescriptionExample
Adressstring?The address.One Apple Park Way, Cupertino, CA 95014
Phonestring?The phone number.+1-800-MY-APPLE
Websitestring?The website URL.https://www.apple.com
Sectorstring?The sector in which the entity operates.Technology
Industrystring?The industry the entity belongs to.Consumer Electronics
CntEmployeeslong?The number of employees.164000
Descriptionstring?A brief description.Apple designs and ...

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){varprofile=awaityahooService.GetProfileAsync("AAPL");Console.WriteLine($"Address: {profile.Adress}");Console.WriteLine($"Sector: {profile.Sector}");Console.WriteLine($"Industry: {profile.Industry}");Console.WriteLine($"Description: {profile.Description}");}
GetSummaryAsync

Description

Retrieves the summary of a specific asset based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Summary containing the following properties:

PropertyTypeDescriptionExample
Namestring?Name of the asset.Apple Inc.
MarketTimeNoticestring?Notice of market status.Market Closed
PreviousClosedecimal?Previous closing price.180.14
Opendecimal?Opening price of the stock.182.20
Biddecimal?Current bid price.180.00
Askdecimal?Current ask price.181.00
DaysRange_Mindecimal?Minimum price today.179.50
DaysRange_Maxdecimal?Maximum price today.183.00
WeekRange52_Mindecimal?Minimum price in 52 weeks.130.20
WeekRange52_Maxdecimal?Maximum price in 52 weeks.190.50
Volumedecimal?Total volume traded today.25,000,000
AvgVolumedecimal?Average daily volume.30,000,000
MarketCap_Intradaydecimal?Market cap in the current session.2.85T
Beta_5Y_Monthlydecimal?5-year beta (monthly data).1.20
PE_Ratio_TTMdecimal?Price-to-earnings ratio (TTM).28.90
EPS_TTMdecimal?Earnings per share (TTM).6.22
EarningsDateDateTime?Date of the next earnings report.2025-02-15
Forward_Dividenddecimal?Expected forward dividend.0.88
Forward_Yielddecimal?Forward dividend yield.0.49%
Ex_DividendDateDateTime?Ex-dividend date.2025-01-10
OneYearTargetEstdecimal?One-year target price estimate.200.00

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve the summary for Apple Inc.varsummary=awaityahooService.GetSummaryAsync("AAPL");Console.WriteLine($"Name: {summary.Name}");Console.WriteLine($"Previous Close: {summary.PreviousClose}");Console.WriteLine($"Open: {summary.Open}");Console.WriteLine($"Bid: {summary.Bid}");Console.WriteLine($"Ask: {summary.Ask}");Console.WriteLine($"Average Volume: {summary.AvgVolume}");Console.WriteLine($"EPS (TTM): {summary.EPS_TTM}");}
GetFinancialsAsync

Description

Retrieves the financial reports for a specified asset identified by its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Dictionary<string, FinancialReport> where the key is the label (e.g., "Annual Report 2024") and the value is a FinancialReport containing the following properties:

PropertyTypeDescriptionExample
TickerSymbolstring?The company's stock symbol.AAPL
TotalRevenuedecimal?Total revenue generated.394,328,000,000
CostOfRevenuedecimal?Direct costs of goods/services sold.213,459,000,000
GrossProfitdecimal?Gross profit (Revenue - Cost of Revenue).180,869,000,000
OperatingExpensedecimal?Operating expenses incurred.34,152,000,000
OperatingIncomedecimal?Operating income (Gross Profit - Operating Expenses).146,717,000,000
NetNonOperatingInterestIncomeExpensedecimal?Net non-operating interest income/expense.2,500,000,000
OtherIncomeExpensedecimal?Other non-core income/expenses.-1,200,000,000
PretaxIncomedecimal?Pretax income before taxes.148,017,000,000
TaxProvisiondecimal?Income taxes provisioned.25,000,000,000
NetIncomeCommonStockholdersdecimal?Net income for common stockholders.123,017,000,000
DilutedNIAvailableToComStockholdersdecimal?Diluted net income for common stockholders.120,517,000,000
BasicEPSdecimal?Basic earnings per share.6.25
DilutedEPSdecimal?Diluted earnings per share.6.15
BasicAverageSharesdecimal?Basic average shares for EPS.19,700,000,000
DilutedAverageSharesdecimal?Diluted average shares for EPS.19,600,000,000
TotalOperatingIncomeAsReporteddecimal?Reported total operating income.146,700,000,000
TotalExpensesdecimal?Total expenses incurred.247,611,000,000
NetIncomeFromContinuingAndDiscontinuedOperationdecimal?Net income from all operations.123,017,000,000
NormalizedIncomedecimal?Normalized income adjusted for irregularities.125,500,000,000
InterestIncomedecimal?Interest income earned.5,000,000,000
InterestExpensedecimal?Interest expense incurred.2,500,000,000
NetInterestIncomedecimal?Net interest income (Income - Expense).2,500,000,000
EBITdecimal?Earnings Before Interest and Taxes.148,217,000,000
EBITDAdecimal?Earnings Before Interest, Taxes, Depreciation, and Amortization.151,217,000,000
ReconciledCostOfRevenuedecimal?Adjusted cost of revenue.212,000,000,000
ReconciledDepreciationdecimal?Adjusted depreciation expense.3,000,000,000
NetIncomeFromContinuingOperationNetMinorityInterestdecimal?Net income from continuing operations.121,017,000,000
TotalUnusualItemsExcludingGoodwilldecimal?Total unusual items, excluding goodwill.-2,000,000,000
TotalUnusualItemsdecimal?Total unusual items, including goodwill.-2,000,000,000
NormalizedEBITDAdecimal?Adjusted EBITDA for unusual items.153,217,000,000
TaxRateForCalcsdecimal?Tax rate used in calculations.16.9%
TaxEffectOfUnusualItemsdecimal?Tax effect of unusual items.-500,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve financial reports for Apple Inc.varfinancialReports=awaityahooService.GetFinancialsAsync("AAPL");foreach(varlabelinfinancialReports.Keys){varreport=financialReports[label];Console.WriteLine($"Label: {label}");Console.WriteLine($"Ticker Symbol: {report.TickerSymbol}");Console.WriteLine($"Total Revenue: {report.TotalRevenue}");Console.WriteLine($"Cost of Revenue: {report.CostOfRevenue}");Console.WriteLine($"Gross Profit: {report.GrossProfit}");Console.WriteLine($"Operating Income: {report.OperatingIncome}");Console.WriteLine($"Net Income: {report.NetIncomeCommonStockholders}");Console.WriteLine();}}
GetRecordsAsync

Description

Retrieves historical stock market data records for a specified asset identified by its symbol. Users can specify an optional date range.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for retrieving historical records. Defaults to 7 days before the current date if not provided.
  • DateTime? endDate: (Optional) End date for retrieving historical records. Defaults to the current date if not provided.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Record>, where each Record represents a historical data point with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record.2025-01-01
Opendecimal?The opening price.150.25
Highdecimal?The highest price during the trading session.155.00
Lowdecimal?The lowest price during the trading session.148.50
Closedecimal?The closing price at the end of the trading session.152.75
AdjustedClosedecimal?The adjusted closing price, accounting for stock splits and dividends.153.00
Volumelong?The trading volume (number of shares traded).10,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve historical records for Apple Inc. for the last 30 daysvarstartDate=DateTime.UtcNow.AddDays(-30);varendDate=DateTime.UtcNow;varrecords=awaityahooService.GetRecordsAsync("AAPL",startDate,endDate);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date:yyyy-MM-dd}");Console.WriteLine($"Open: {record.Open:C}");Console.WriteLine($"Close: {record.Close:C}");Console.WriteLine();}}
GetQuoteAsync

Description

Retrieves detailed information about a specific financial quote, identified by its symbol. This API is useful for accessing comprehensive data about a stock, ETF, or other traded financial instruments.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A cancellation token that can be used to cancel the operation if needed.

Returns

A task that resolves to a Quote object. The Quote record contains detailed information about the requested financial instrument, as described in the table below.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskDisplayQuote(IYahooFinanceServiceyahooService){// Retrieve a quote for Apple Inc.varquote=awaityahooService.GetQuoteAsync("AAPL");Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.ShortName}");Console.WriteLine($"Market Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Currency: {quote.Currency}");}
GetQuotesAsync

Description

Retrieves quote data for multiple financial instruments identified by their symbols. The data includes detailed information about each instrument, such as pricing, market performance, and other financial metrics.

Parameters

  • List<string> symbols: A list of symbols for which to retrieve data (e.g., ["AAPL", "MSFT", "GOOGL"]).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Quote>, where each Quote provides comprehensive data about a specific instrument.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve quotes for Apple, Microsoft, and Googlevarsymbols=newList<string>{"AAPL","MSFT","GOOGL"};varquotes=awaityahooService.GetQuotesAsync(symbols);foreach(varquoteinquotes){Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.DisplayName}");Console.WriteLine($"Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Dividend Yield: {quote.DividendYield:P}");Console.WriteLine($"Earnings Date: {quote.EarningsDate:yyyy-MM-dd}");Console.WriteLine();}}

Alpha Vantage

Offers stock, forex, and cryptocurrency data including intraday and historical records.

Get an API key

To get started, obtain a free API key from Alpha Vantage.

Configure API key

After acquiring your API key, configure it in your service collection:

services.AddFinanceNet(newFinanceNetConfiguration{AlphaVantageApiKey="API_KEY"});

Methods

GetOverviewAsync

Description

Retrieves an instrument overview for a specified stock symbol.

Parameters

  • string symbol: The symbol of the asset (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A token to cancel the operation if needed.

Returns

A task that resolves to an InstrumentOverview?. The InstrumentOverview contains the following properties that provide key information about the company:

PropertyTypeDescriptionExample
Symbolstring?The stock symbol."AAPL"
AssetTypestring?The type of asset (e.g., stock, ETF)."Equity"
Namestring?The name of the ticker or company."Apple Inc."
Descriptionstring?A brief company description."Designs ... ."
CIKstring?The Central Index Key (CIK) of the company."0000320193"
Exchangestring?The exchange where the company is listed."NASDAQ"
Currencystring?The currency used for financials."USD"
Countrystring?The country where the company is located."United States"
Sectorstring?The company's sector (e.g., Technology)."Technology"
Industrystring?The industry the company operates in."Consumer Electronics"
Addressstring?The company's headquarters address."Cupertino, CA"
OfficialSitestring?The official website of the company."https://www.apple.com"
FiscalYearEndstring?The fiscal year end date."September 30"
LatestQuarterstring?The most recent available quarter."Q3 2024"
MarketCapitalizationlong?The market capitalization.2320000000000
EBITDAstring?EBITDA."11200000000"
PERatiostring?The Price-to-Earnings ratio."27.5"
PEGRatiostring?The Price/Earnings-to-Growth ratio."1.4"
BookValuestring?The company's book value."10.52"
DividendPerSharestring?The dividend per share."0.82"
DividendYieldstring?The dividend yield."1.5%"
EPSstring?Earnings per share."5.26"
RevenuePerShareTTMstring?Revenue per share for the trailing twelve months."30.5"
ProfitMarginstring?Profit margin."25%"
OperatingMarginTTMstring?Operating margin for the trailing twelve months."22%"
ReturnOnAssetsTTMstring?Return on assets for the trailing twelve months."14%"
ReturnOnEquityTTMstring?Return on equity for the trailing twelve months."40%"
RevenueTTMstring?Revenue for the trailing twelve months."386000000000"
GrossProfitTTMstring?Gross profit for the trailing twelve months."160000000000"
DilutedEPSTTMstring?Diluted earnings per share for the trailing twelve months."5.10"
QuarterlyEarningsGrowthYOYstring?Quarterly earnings growth year-over-year."15%"
QuarterlyRevenueGrowthYOYstring?Quarterly revenue growth year-over-year."10%"
AnalystTargetPricestring?Analyst target price for the stock."175.00"
AnalystRatingStrongBuystring?Percentage of analysts recommending a strong buy."60%"
AnalystRatingBuystring?Percentage of analysts recommending a buy."30%"
AnalystRatingHoldstring?Percentage of analysts recommending a hold."10%"
AnalystRatingSellstring?Percentage of analysts recommending a sell."0%"
AnalystRatingStrongSellstring?Percentage of analysts recommending a strong sell."0%"
TrailingPEstring?Trailing Price-to-Earnings ratio."28"
ForwardPEstring?Forward Price-to-Earnings ratio."25"
PriceToSalesRatioTTMstring?Price-to-Sales ratio for the trailing twelve months."6.5"
PriceToBookRatiostring?Price-to-Book ratio."4.3"
EVToRevenuestring?Enterprise value-to-revenue ratio."8.2"
EVToEBITDAstring?Enterprise value-to-EBITDA ratio."14.5"
Betastring?Beta value, measuring stock volatility."1.2"
FiftySecondWeekHighstring?52-week high stock price."179.50"
FiftySecondWeekLowstring?52-week low stock price."120.10"
FiftyDayMovingAveragestring?50-day moving average."153.25"
TwoHundredDayMovingAveragestring?200-day moving average."157.80"
SharesOutstandingstring?Number of shares outstanding."5000000000"
DividendDatestring?Next dividend payment date."2025-02-01"
ExDividendDatestring?Ex-dividend date."2025-01-10"

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve the overview for Apple Inc.varoverview=awaitalphaVantageService.GetOverviewAsync("AAPL");if(overview!=null){Console.WriteLine($"Symbol: {overview.Symbol}");Console.WriteLine($"Name: {overview.Name}");Console.WriteLine($"Sector: {overview.Sector}");Console.WriteLine($"Market Capitalization: {overview.MarketCapitalization}");Console.WriteLine($"Dividend Yield: {overview.DividendYield}");Console.WriteLine($"P/E Ratio: {overview.PERatio}");Console.WriteLine($"Revenue (TTM): {overview.RevenueTTM}");}}
GetRecordsAsync

Description

Retrieves historical daily stock records for a given symbol within an optional date range.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for the records. Defaults to 7 days ago.
  • DateTime? endDate: (Optional) End date for the records. Defaults to current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<Record>, with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record."2024-12-15"
Opendouble?The opening price of the asset.150.25
Lowdouble?The lowest price of the asset on that date.148.75
Highdouble?The highest price of the asset on that date.153.50
Closedouble?The closing price of the asset.151.00
AdjustedClosedouble?The adjusted closing price, considering stock splits and dividends.150.80
Volumelong?The trading volume of the asset on that date.1000000
SplitCoefficientdouble?The stock split coefficient, if any, for the given date.1.0

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical records for Apple Inc. (AAPL)varrecords=awaitalphaVantageService.GetRecordsAsync("AAPL",DateTime.Now.AddDays(-7),DateTime.Now);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date.ToShortDateString()}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"High: {record.High}");Console.WriteLine($"Low: {record.Low}");Console.WriteLine($"Close: {record.Close}");Console.WriteLine($"Adjusted Close: {record.AdjustedClose}");Console.WriteLine($"Volume: {record.Volume}");Console.WriteLine($"Split Coefficient: {record.SplitCoefficient}");Console.WriteLine();}}
GetForexRecordsAsync

Description

Retrieves historical daily forex (foreign exchange) records for a given currency pair within a specified date range.

Parameters

  • string currency1: The source currency (e.g., "USD").
  • string currency2: The target currency (e.g., "EUR").
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<ForexRecord>, with the following properties:

PropertyTypeDescriptionExample
DateDateTime?The date of the forex record."2024-12-15"
Opendouble?The opening price of the currency pair for that date.1.1215
Highdouble?The highest price of the currency pair for that date.1.1250
Lowdouble?The lowest price of the currency pair for that date.1.1180
Closedouble?The closing price of the currency pair for that date.1.1220

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical forex records for USD to EURvarforexRecords=awaitalphaVantageService.GetForexRecordsAsync("USD","EUR",DateTime.Now.AddDays(-7));foreach(varrecordinforexRecords){Console.WriteLine($"Date: {record.Date}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}
GetIntradayRecordsAsync

Description

Retrieves intraday stock records for a given symbol within a specified date range and time interval.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • EInterval interval: The time interval between data points. Default is 15 minutes. Possible values:
    • Interval_1Min
    • Interval_5Min
    • Interval_15Min
    • Interval_30Min
    • Interval_60Min
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<IntradayRecord>, with the following properties:

PropertyTypeDescriptionExample
DateTimeDateTimeThe date and time of the record."2024-12-15 09:30"
OpendoubleThe opening price of the stock for that interval.145.32
HighdoubleThe highest price of the stock for that interval.147.10
LowdoubleThe lowest price of the stock for that interval.144.98
ClosedoubleThe closing price of the stock for that interval.146.30
VolumelongThe trading volume during that interval.1234567

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve intraday stock records for AAPL with a 15-minute intervalvarintradayRecords=awaitalphaVantageService.GetIntradayRecordsAsync("AAPL",DateTime.Now.AddDays(-1),DateTime.Now,EInterval.Interval_15Min);foreach(varrecordinintradayRecords){Console.WriteLine($"DateTime: {record.DateTime}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}

DataHub

Accesses datasets like Nasdaq and S&P 500 companies.

Methods

GetNasdaqInstrumentsAsync

Description

Retrieves a collection of more than 4,000 Nasdaq instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<NasdaqInstrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.TSLA
Namestring?The company name associated with the instrument.Tesla, Inc.

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetNasdaqInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}");}}
GetSp500InstrumentsAsync

Description

Retrieves a collection of S&P 500 instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Sp500Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the instrument.TSLA
Namestring?Name of the instrument/company.Tesla, Inc.
Sectorstring?Sector of the instrument.Automobile Manufacturers
Pricedouble?Current price of the instrument.345.16
PriceEarningsdouble?Price-to-earnings ratio.94.31
DividendYielddouble?Dividend yield.0.89
EarningsSharedouble?Earnings per share.3.66
FiftyTwoWeekLowdouble?52-week low price.338.8
FiftyTwoWeekHighdouble?52-week high price.361.93
MarketCaplong?Market capitalization.1107284384000
EBITDAlong?EBITDA value.13244000256
PriceSalesdouble?Price-to-sales ratio.11.41
PriceBookdouble?Price-to-book ratio.15.82

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetSp500InstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}, Sector: {item.Sector}");}}

Xetra

A major European trading platform offering data on Xetra-listed instruments.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of more than 3,000 Xetra instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the financial instrument.TL0.DE
InstrumentStatusstring?Current status of the instrument.Active
InstrumentNamestring?Full name of the financial instrument.TESLA INC. DL -,001
ISINstring?International Securities Identification Number.US88160R1014
WKNstring?German securities identification number.000A1CX3T
Mnemonicstring?Shorthand or mnemonic code for the instrument.TL0
InstrumentTypestring?Type of financial instrument (e.g., CS, ETF, ETN).CS
Currencystring?Currency in which the instrument is traded.EUR

Example

publicasyncTaskRun(IXetraServicexetraService){varinstruments=awaitxetraService.GetInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.InstrumentName}");}}

🤝 How to Contribute

We welcome contributions to Finance.NET! If you’d like to improve the project, please:

  1. Check out our contributing guidelines.
  2. Ideally, open an issue before starting work.
  3. Submit a pull request with your changes.

Thank you for helping make Finance.NET better!


ℹ️ Disclaimer

Finance.NET is an open-source project using publicly accessible APIs and scraping techniques. It is intended for educational and research purposes.

For legal usage, refer to the terms of each data provider:

For additional licensing and attribution details, see NOTICE.md.


🐞 Report a Bug

If you encounter any issues or bugs, please report them here.

About

A .NET library for retrieving real-time and historical financial data from Yahoo Finance and other popular sources.

Topics

Resources

Code of conduct

Contributing

Stars

22 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Banner

CICoverageQuality GateNuGetDownloads.NET StandardStars

An easy-to-use .NET library for accessing and aggregating financial data from multiple sources.

This library enables developers to retrieve financial data via APIs and HTML scraping from a variety of providers. It's ideal for building analytical tools, dashboards, or financial applications that require access to market data.


⭐ Features

  • Retrieve Instruments: Get tradable ticker symbols and associated details.
  • Fundamentals: Access key financial metrics and company fundamentals.
  • Historical Records: Fetch historical data for analysis or charting.
  • Real-Time Quotes: Receive live updates on stock prices and market data.

🚀 Getting started

This section guides you through installing Finance.NET, configuring services, and basic data retrieval.

Installation

Install via NuGet:

dotnet add package Finance.NET

Register in Service Collection

Add Finance.NET to your service collection for dependency injection:

services.AddFinanceNet();

Optional: Configure with custom settings.

services.AddFinanceNet(newFinanceNetConfiguration{HttpTimeout=5,// seconds (default: 20)HttpRetryCount=3,// default: 10HttpRetrySleepTime=5,// seconds, base for exponential back-off; capped at 30s per attempt, plus jitter (default: 5)AlphaVantageApiKey="ALPHA_VANTAGE__API_KEY"});

Basic Usage

Example: Retrieve historical and real-time data for Tesla (TSLA):

publicasyncTaskRun(IYahooFinanceServiceyahooService){varsymbol="TSLA";varstartDate=newDateTime(2020,1,1);varrecords=awaityahooService.GetRecordsAsync(symbol,startDate);foreach(varrecordinrecords){Console.WriteLine($"Date={record.Date}: {record.Open} / {record.Close}");}varquote=awaityahooService.GetQuoteAsync(symbol);Console.WriteLine($"Bid={quote.Bid}, Ask={quote.Ask}");}

🔌Finance.NET Service Interfaces

Finance.NET exposes modular service interfaces for accessing diverse financial data through a consistent API. Each interface corresponds to a specific provider and supports its unique features.

Yahoo! Finance

Provides market data, company fundamentals, historical records, and real-time quotes.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of financial instruments.

Parameters

  • EInstrumentType? filterByType: An optional filter to specify the type of asset. If not provided, all asset types will be included. Possible values:
    • Stock: Most active stocks.
    • ETF: Most active exchange-traded funds (ETFs)
    • Forex: Available currencies (foreign exchange).
    • Crypto: Available cryptocurrencies.
    • Index: Available world indices.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.AAPL
InstrumentTypeEInstrumentType?The type of the financial instrument.Stock

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve all instrumentsvarinstruments=awaityahooService.GetInstrumentsAsync();// Retrieve only stock instrumentsvarstockInstruments=awaityahooService.GetInstrumentsAsync(EInstrumentType.Stock);foreach(varinstrumentinstockInstruments){Console.WriteLine($"Symbol: {instrument.Symbol}, Type: {instrument.InstrumentType}");}}
GetProfileAsync

Description

Retrieves the profile of a specific entity based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Profile containing the following properties:

PropertyTypeDescriptionExample
Adressstring?The address.One Apple Park Way, Cupertino, CA 95014
Phonestring?The phone number.+1-800-MY-APPLE
Websitestring?The website URL.https://www.apple.com
Sectorstring?The sector in which the entity operates.Technology
Industrystring?The industry the entity belongs to.Consumer Electronics
CntEmployeeslong?The number of employees.164000
Descriptionstring?A brief description.Apple designs and ...

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){varprofile=awaityahooService.GetProfileAsync("AAPL");Console.WriteLine($"Address: {profile.Adress}");Console.WriteLine($"Sector: {profile.Sector}");Console.WriteLine($"Industry: {profile.Industry}");Console.WriteLine($"Description: {profile.Description}");}
GetSummaryAsync

Description

Retrieves the summary of a specific asset based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Summary containing the following properties:

PropertyTypeDescriptionExample
Namestring?Name of the asset.Apple Inc.
MarketTimeNoticestring?Notice of market status.Market Closed
PreviousClosedecimal?Previous closing price.180.14
Opendecimal?Opening price of the stock.182.20
Biddecimal?Current bid price.180.00
Askdecimal?Current ask price.181.00
DaysRange_Mindecimal?Minimum price today.179.50
DaysRange_Maxdecimal?Maximum price today.183.00
WeekRange52_Mindecimal?Minimum price in 52 weeks.130.20
WeekRange52_Maxdecimal?Maximum price in 52 weeks.190.50
Volumedecimal?Total volume traded today.25,000,000
AvgVolumedecimal?Average daily volume.30,000,000
MarketCap_Intradaydecimal?Market cap in the current session.2.85T
Beta_5Y_Monthlydecimal?5-year beta (monthly data).1.20
PE_Ratio_TTMdecimal?Price-to-earnings ratio (TTM).28.90
EPS_TTMdecimal?Earnings per share (TTM).6.22
EarningsDateDateTime?Date of the next earnings report.2025-02-15
Forward_Dividenddecimal?Expected forward dividend.0.88
Forward_Yielddecimal?Forward dividend yield.0.49%
Ex_DividendDateDateTime?Ex-dividend date.2025-01-10
OneYearTargetEstdecimal?One-year target price estimate.200.00

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve the summary for Apple Inc.varsummary=awaityahooService.GetSummaryAsync("AAPL");Console.WriteLine($"Name: {summary.Name}");Console.WriteLine($"Previous Close: {summary.PreviousClose}");Console.WriteLine($"Open: {summary.Open}");Console.WriteLine($"Bid: {summary.Bid}");Console.WriteLine($"Ask: {summary.Ask}");Console.WriteLine($"Average Volume: {summary.AvgVolume}");Console.WriteLine($"EPS (TTM): {summary.EPS_TTM}");}
GetFinancialsAsync

Description

Retrieves the financial reports for a specified asset identified by its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Dictionary<string, FinancialReport> where the key is the label (e.g., "Annual Report 2024") and the value is a FinancialReport containing the following properties:

PropertyTypeDescriptionExample
TickerSymbolstring?The company's stock symbol.AAPL
TotalRevenuedecimal?Total revenue generated.394,328,000,000
CostOfRevenuedecimal?Direct costs of goods/services sold.213,459,000,000
GrossProfitdecimal?Gross profit (Revenue - Cost of Revenue).180,869,000,000
OperatingExpensedecimal?Operating expenses incurred.34,152,000,000
OperatingIncomedecimal?Operating income (Gross Profit - Operating Expenses).146,717,000,000
NetNonOperatingInterestIncomeExpensedecimal?Net non-operating interest income/expense.2,500,000,000
OtherIncomeExpensedecimal?Other non-core income/expenses.-1,200,000,000
PretaxIncomedecimal?Pretax income before taxes.148,017,000,000
TaxProvisiondecimal?Income taxes provisioned.25,000,000,000
NetIncomeCommonStockholdersdecimal?Net income for common stockholders.123,017,000,000
DilutedNIAvailableToComStockholdersdecimal?Diluted net income for common stockholders.120,517,000,000
BasicEPSdecimal?Basic earnings per share.6.25
DilutedEPSdecimal?Diluted earnings per share.6.15
BasicAverageSharesdecimal?Basic average shares for EPS.19,700,000,000
DilutedAverageSharesdecimal?Diluted average shares for EPS.19,600,000,000
TotalOperatingIncomeAsReporteddecimal?Reported total operating income.146,700,000,000
TotalExpensesdecimal?Total expenses incurred.247,611,000,000
NetIncomeFromContinuingAndDiscontinuedOperationdecimal?Net income from all operations.123,017,000,000
NormalizedIncomedecimal?Normalized income adjusted for irregularities.125,500,000,000
InterestIncomedecimal?Interest income earned.5,000,000,000
InterestExpensedecimal?Interest expense incurred.2,500,000,000
NetInterestIncomedecimal?Net interest income (Income - Expense).2,500,000,000
EBITdecimal?Earnings Before Interest and Taxes.148,217,000,000
EBITDAdecimal?Earnings Before Interest, Taxes, Depreciation, and Amortization.151,217,000,000
ReconciledCostOfRevenuedecimal?Adjusted cost of revenue.212,000,000,000
ReconciledDepreciationdecimal?Adjusted depreciation expense.3,000,000,000
NetIncomeFromContinuingOperationNetMinorityInterestdecimal?Net income from continuing operations.121,017,000,000
TotalUnusualItemsExcludingGoodwilldecimal?Total unusual items, excluding goodwill.-2,000,000,000
TotalUnusualItemsdecimal?Total unusual items, including goodwill.-2,000,000,000
NormalizedEBITDAdecimal?Adjusted EBITDA for unusual items.153,217,000,000
TaxRateForCalcsdecimal?Tax rate used in calculations.16.9%
TaxEffectOfUnusualItemsdecimal?Tax effect of unusual items.-500,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve financial reports for Apple Inc.varfinancialReports=awaityahooService.GetFinancialsAsync("AAPL");foreach(varlabelinfinancialReports.Keys){varreport=financialReports[label];Console.WriteLine($"Label: {label}");Console.WriteLine($"Ticker Symbol: {report.TickerSymbol}");Console.WriteLine($"Total Revenue: {report.TotalRevenue}");Console.WriteLine($"Cost of Revenue: {report.CostOfRevenue}");Console.WriteLine($"Gross Profit: {report.GrossProfit}");Console.WriteLine($"Operating Income: {report.OperatingIncome}");Console.WriteLine($"Net Income: {report.NetIncomeCommonStockholders}");Console.WriteLine();}}
GetRecordsAsync

Description

Retrieves historical stock market data records for a specified asset identified by its symbol. Users can specify an optional date range.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for retrieving historical records. Defaults to 7 days before the current date if not provided.
  • DateTime? endDate: (Optional) End date for retrieving historical records. Defaults to the current date if not provided.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Record>, where each Record represents a historical data point with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record.2025-01-01
Opendecimal?The opening price.150.25
Highdecimal?The highest price during the trading session.155.00
Lowdecimal?The lowest price during the trading session.148.50
Closedecimal?The closing price at the end of the trading session.152.75
AdjustedClosedecimal?The adjusted closing price, accounting for stock splits and dividends.153.00
Volumelong?The trading volume (number of shares traded).10,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve historical records for Apple Inc. for the last 30 daysvarstartDate=DateTime.UtcNow.AddDays(-30);varendDate=DateTime.UtcNow;varrecords=awaityahooService.GetRecordsAsync("AAPL",startDate,endDate);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date:yyyy-MM-dd}");Console.WriteLine($"Open: {record.Open:C}");Console.WriteLine($"Close: {record.Close:C}");Console.WriteLine();}}
GetQuoteAsync

Description

Retrieves detailed information about a specific financial quote, identified by its symbol. This API is useful for accessing comprehensive data about a stock, ETF, or other traded financial instruments.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A cancellation token that can be used to cancel the operation if needed.

Returns

A task that resolves to a Quote object. The Quote record contains detailed information about the requested financial instrument, as described in the table below.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskDisplayQuote(IYahooFinanceServiceyahooService){// Retrieve a quote for Apple Inc.varquote=awaityahooService.GetQuoteAsync("AAPL");Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.ShortName}");Console.WriteLine($"Market Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Currency: {quote.Currency}");}
GetQuotesAsync

Description

Retrieves quote data for multiple financial instruments identified by their symbols. The data includes detailed information about each instrument, such as pricing, market performance, and other financial metrics.

Parameters

  • List<string> symbols: A list of symbols for which to retrieve data (e.g., ["AAPL", "MSFT", "GOOGL"]).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Quote>, where each Quote provides comprehensive data about a specific instrument.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve quotes for Apple, Microsoft, and Googlevarsymbols=newList<string>{"AAPL","MSFT","GOOGL"};varquotes=awaityahooService.GetQuotesAsync(symbols);foreach(varquoteinquotes){Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.DisplayName}");Console.WriteLine($"Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Dividend Yield: {quote.DividendYield:P}");Console.WriteLine($"Earnings Date: {quote.EarningsDate:yyyy-MM-dd}");Console.WriteLine();}}

Alpha Vantage

Offers stock, forex, and cryptocurrency data including intraday and historical records.

Get an API key

To get started, obtain a free API key from Alpha Vantage.

Configure API key

After acquiring your API key, configure it in your service collection:

services.AddFinanceNet(newFinanceNetConfiguration{AlphaVantageApiKey="API_KEY"});

Methods

GetOverviewAsync

Description

Retrieves an instrument overview for a specified stock symbol.

Parameters

  • string symbol: The symbol of the asset (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A token to cancel the operation if needed.

Returns

A task that resolves to an InstrumentOverview?. The InstrumentOverview contains the following properties that provide key information about the company:

PropertyTypeDescriptionExample
Symbolstring?The stock symbol."AAPL"
AssetTypestring?The type of asset (e.g., stock, ETF)."Equity"
Namestring?The name of the ticker or company."Apple Inc."
Descriptionstring?A brief company description."Designs ... ."
CIKstring?The Central Index Key (CIK) of the company."0000320193"
Exchangestring?The exchange where the company is listed."NASDAQ"
Currencystring?The currency used for financials."USD"
Countrystring?The country where the company is located."United States"
Sectorstring?The company's sector (e.g., Technology)."Technology"
Industrystring?The industry the company operates in."Consumer Electronics"
Addressstring?The company's headquarters address."Cupertino, CA"
OfficialSitestring?The official website of the company."https://www.apple.com"
FiscalYearEndstring?The fiscal year end date."September 30"
LatestQuarterstring?The most recent available quarter."Q3 2024"
MarketCapitalizationlong?The market capitalization.2320000000000
EBITDAstring?EBITDA."11200000000"
PERatiostring?The Price-to-Earnings ratio."27.5"
PEGRatiostring?The Price/Earnings-to-Growth ratio."1.4"
BookValuestring?The company's book value."10.52"
DividendPerSharestring?The dividend per share."0.82"
DividendYieldstring?The dividend yield."1.5%"
EPSstring?Earnings per share."5.26"
RevenuePerShareTTMstring?Revenue per share for the trailing twelve months."30.5"
ProfitMarginstring?Profit margin."25%"
OperatingMarginTTMstring?Operating margin for the trailing twelve months."22%"
ReturnOnAssetsTTMstring?Return on assets for the trailing twelve months."14%"
ReturnOnEquityTTMstring?Return on equity for the trailing twelve months."40%"
RevenueTTMstring?Revenue for the trailing twelve months."386000000000"
GrossProfitTTMstring?Gross profit for the trailing twelve months."160000000000"
DilutedEPSTTMstring?Diluted earnings per share for the trailing twelve months."5.10"
QuarterlyEarningsGrowthYOYstring?Quarterly earnings growth year-over-year."15%"
QuarterlyRevenueGrowthYOYstring?Quarterly revenue growth year-over-year."10%"
AnalystTargetPricestring?Analyst target price for the stock."175.00"
AnalystRatingStrongBuystring?Percentage of analysts recommending a strong buy."60%"
AnalystRatingBuystring?Percentage of analysts recommending a buy."30%"
AnalystRatingHoldstring?Percentage of analysts recommending a hold."10%"
AnalystRatingSellstring?Percentage of analysts recommending a sell."0%"
AnalystRatingStrongSellstring?Percentage of analysts recommending a strong sell."0%"
TrailingPEstring?Trailing Price-to-Earnings ratio."28"
ForwardPEstring?Forward Price-to-Earnings ratio."25"
PriceToSalesRatioTTMstring?Price-to-Sales ratio for the trailing twelve months."6.5"
PriceToBookRatiostring?Price-to-Book ratio."4.3"
EVToRevenuestring?Enterprise value-to-revenue ratio."8.2"
EVToEBITDAstring?Enterprise value-to-EBITDA ratio."14.5"
Betastring?Beta value, measuring stock volatility."1.2"
FiftySecondWeekHighstring?52-week high stock price."179.50"
FiftySecondWeekLowstring?52-week low stock price."120.10"
FiftyDayMovingAveragestring?50-day moving average."153.25"
TwoHundredDayMovingAveragestring?200-day moving average."157.80"
SharesOutstandingstring?Number of shares outstanding."5000000000"
DividendDatestring?Next dividend payment date."2025-02-01"
ExDividendDatestring?Ex-dividend date."2025-01-10"

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve the overview for Apple Inc.varoverview=awaitalphaVantageService.GetOverviewAsync("AAPL");if(overview!=null){Console.WriteLine($"Symbol: {overview.Symbol}");Console.WriteLine($"Name: {overview.Name}");Console.WriteLine($"Sector: {overview.Sector}");Console.WriteLine($"Market Capitalization: {overview.MarketCapitalization}");Console.WriteLine($"Dividend Yield: {overview.DividendYield}");Console.WriteLine($"P/E Ratio: {overview.PERatio}");Console.WriteLine($"Revenue (TTM): {overview.RevenueTTM}");}}
GetRecordsAsync

Description

Retrieves historical daily stock records for a given symbol within an optional date range.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for the records. Defaults to 7 days ago.
  • DateTime? endDate: (Optional) End date for the records. Defaults to current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<Record>, with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record."2024-12-15"
Opendouble?The opening price of the asset.150.25
Lowdouble?The lowest price of the asset on that date.148.75
Highdouble?The highest price of the asset on that date.153.50
Closedouble?The closing price of the asset.151.00
AdjustedClosedouble?The adjusted closing price, considering stock splits and dividends.150.80
Volumelong?The trading volume of the asset on that date.1000000
SplitCoefficientdouble?The stock split coefficient, if any, for the given date.1.0

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical records for Apple Inc. (AAPL)varrecords=awaitalphaVantageService.GetRecordsAsync("AAPL",DateTime.Now.AddDays(-7),DateTime.Now);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date.ToShortDateString()}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"High: {record.High}");Console.WriteLine($"Low: {record.Low}");Console.WriteLine($"Close: {record.Close}");Console.WriteLine($"Adjusted Close: {record.AdjustedClose}");Console.WriteLine($"Volume: {record.Volume}");Console.WriteLine($"Split Coefficient: {record.SplitCoefficient}");Console.WriteLine();}}
GetForexRecordsAsync

Description

Retrieves historical daily forex (foreign exchange) records for a given currency pair within a specified date range.

Parameters

  • string currency1: The source currency (e.g., "USD").
  • string currency2: The target currency (e.g., "EUR").
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<ForexRecord>, with the following properties:

PropertyTypeDescriptionExample
DateDateTime?The date of the forex record."2024-12-15"
Opendouble?The opening price of the currency pair for that date.1.1215
Highdouble?The highest price of the currency pair for that date.1.1250
Lowdouble?The lowest price of the currency pair for that date.1.1180
Closedouble?The closing price of the currency pair for that date.1.1220

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical forex records for USD to EURvarforexRecords=awaitalphaVantageService.GetForexRecordsAsync("USD","EUR",DateTime.Now.AddDays(-7));foreach(varrecordinforexRecords){Console.WriteLine($"Date: {record.Date}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}
GetIntradayRecordsAsync

Description

Retrieves intraday stock records for a given symbol within a specified date range and time interval.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • EInterval interval: The time interval between data points. Default is 15 minutes. Possible values:
    • Interval_1Min
    • Interval_5Min
    • Interval_15Min
    • Interval_30Min
    • Interval_60Min
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<IntradayRecord>, with the following properties:

PropertyTypeDescriptionExample
DateTimeDateTimeThe date and time of the record."2024-12-15 09:30"
OpendoubleThe opening price of the stock for that interval.145.32
HighdoubleThe highest price of the stock for that interval.147.10
LowdoubleThe lowest price of the stock for that interval.144.98
ClosedoubleThe closing price of the stock for that interval.146.30
VolumelongThe trading volume during that interval.1234567

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve intraday stock records for AAPL with a 15-minute intervalvarintradayRecords=awaitalphaVantageService.GetIntradayRecordsAsync("AAPL",DateTime.Now.AddDays(-1),DateTime.Now,EInterval.Interval_15Min);foreach(varrecordinintradayRecords){Console.WriteLine($"DateTime: {record.DateTime}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}

DataHub

Accesses datasets like Nasdaq and S&P 500 companies.

Methods

GetNasdaqInstrumentsAsync

Description

Retrieves a collection of more than 4,000 Nasdaq instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<NasdaqInstrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.TSLA
Namestring?The company name associated with the instrument.Tesla, Inc.

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetNasdaqInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}");}}
GetSp500InstrumentsAsync

Description

Retrieves a collection of S&P 500 instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Sp500Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the instrument.TSLA
Namestring?Name of the instrument/company.Tesla, Inc.
Sectorstring?Sector of the instrument.Automobile Manufacturers
Pricedouble?Current price of the instrument.345.16
PriceEarningsdouble?Price-to-earnings ratio.94.31
DividendYielddouble?Dividend yield.0.89
EarningsSharedouble?Earnings per share.3.66
FiftyTwoWeekLowdouble?52-week low price.338.8
FiftyTwoWeekHighdouble?52-week high price.361.93
MarketCaplong?Market capitalization.1107284384000
EBITDAlong?EBITDA value.13244000256
PriceSalesdouble?Price-to-sales ratio.11.41
PriceBookdouble?Price-to-book ratio.15.82

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetSp500InstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}, Sector: {item.Sector}");}}

Xetra

A major European trading platform offering data on Xetra-listed instruments.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of more than 3,000 Xetra instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the financial instrument.TL0.DE
InstrumentStatusstring?Current status of the instrument.Active
InstrumentNamestring?Full name of the financial instrument.TESLA INC. DL -,001
ISINstring?International Securities Identification Number.US88160R1014
WKNstring?German securities identification number.000A1CX3T
Mnemonicstring?Shorthand or mnemonic code for the instrument.TL0
InstrumentTypestring?Type of financial instrument (e.g., CS, ETF, ETN).CS
Currencystring?Currency in which the instrument is traded.EUR

Example

publicasyncTaskRun(IXetraServicexetraService){varinstruments=awaitxetraService.GetInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.InstrumentName}");}}

🤝 How to Contribute

We welcome contributions to Finance.NET! If you’d like to improve the project, please:

  1. Check out our contributing guidelines.
  2. Ideally, open an issue before starting work.
  3. Submit a pull request with your changes.

Thank you for helping make Finance.NET better!


ℹ️ Disclaimer

Finance.NET is an open-source project using publicly accessible APIs and scraping techniques. It is intended for educational and research purposes.

For legal usage, refer to the terms of each data provider:

For additional licensing and attribution details, see NOTICE.md.


🐞 Report a Bug

If you encounter any issues or bugs, please report them here.

About

A .NET library for retrieving real-time and historical financial data from Yahoo Finance and other popular sources.

Topics

Resources

Code of conduct

Contributing

Stars

22 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Banner

CICoverageQuality GateNuGetDownloads.NET StandardStars

An easy-to-use .NET library for accessing and aggregating financial data from multiple sources.

This library enables developers to retrieve financial data via APIs and HTML scraping from a variety of providers. It's ideal for building analytical tools, dashboards, or financial applications that require access to market data.


⭐ Features

  • Retrieve Instruments: Get tradable ticker symbols and associated details.
  • Fundamentals: Access key financial metrics and company fundamentals.
  • Historical Records: Fetch historical data for analysis or charting.
  • Real-Time Quotes: Receive live updates on stock prices and market data.

🚀 Getting started

This section guides you through installing Finance.NET, configuring services, and basic data retrieval.

Installation

Install via NuGet:

dotnet add package Finance.NET

Register in Service Collection

Add Finance.NET to your service collection for dependency injection:

services.AddFinanceNet();

Optional: Configure with custom settings.

services.AddFinanceNet(newFinanceNetConfiguration{HttpTimeout=5,// seconds (default: 20)HttpRetryCount=3,// default: 10HttpRetrySleepTime=5,// seconds, base for exponential back-off; capped at 30s per attempt, plus jitter (default: 5)AlphaVantageApiKey="ALPHA_VANTAGE__API_KEY"});

Basic Usage

Example: Retrieve historical and real-time data for Tesla (TSLA):

publicasyncTaskRun(IYahooFinanceServiceyahooService){varsymbol="TSLA";varstartDate=newDateTime(2020,1,1);varrecords=awaityahooService.GetRecordsAsync(symbol,startDate);foreach(varrecordinrecords){Console.WriteLine($"Date={record.Date}: {record.Open} / {record.Close}");}varquote=awaityahooService.GetQuoteAsync(symbol);Console.WriteLine($"Bid={quote.Bid}, Ask={quote.Ask}");}

🔌Finance.NET Service Interfaces

Finance.NET exposes modular service interfaces for accessing diverse financial data through a consistent API. Each interface corresponds to a specific provider and supports its unique features.

Yahoo! Finance

Provides market data, company fundamentals, historical records, and real-time quotes.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of financial instruments.

Parameters

  • EInstrumentType? filterByType: An optional filter to specify the type of asset. If not provided, all asset types will be included. Possible values:
    • Stock: Most active stocks.
    • ETF: Most active exchange-traded funds (ETFs)
    • Forex: Available currencies (foreign exchange).
    • Crypto: Available cryptocurrencies.
    • Index: Available world indices.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.AAPL
InstrumentTypeEInstrumentType?The type of the financial instrument.Stock

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve all instrumentsvarinstruments=awaityahooService.GetInstrumentsAsync();// Retrieve only stock instrumentsvarstockInstruments=awaityahooService.GetInstrumentsAsync(EInstrumentType.Stock);foreach(varinstrumentinstockInstruments){Console.WriteLine($"Symbol: {instrument.Symbol}, Type: {instrument.InstrumentType}");}}
GetProfileAsync

Description

Retrieves the profile of a specific entity based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Profile containing the following properties:

PropertyTypeDescriptionExample
Adressstring?The address.One Apple Park Way, Cupertino, CA 95014
Phonestring?The phone number.+1-800-MY-APPLE
Websitestring?The website URL.https://www.apple.com
Sectorstring?The sector in which the entity operates.Technology
Industrystring?The industry the entity belongs to.Consumer Electronics
CntEmployeeslong?The number of employees.164000
Descriptionstring?A brief description.Apple designs and ...

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){varprofile=awaityahooService.GetProfileAsync("AAPL");Console.WriteLine($"Address: {profile.Adress}");Console.WriteLine($"Sector: {profile.Sector}");Console.WriteLine($"Industry: {profile.Industry}");Console.WriteLine($"Description: {profile.Description}");}
GetSummaryAsync

Description

Retrieves the summary of a specific asset based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Summary containing the following properties:

PropertyTypeDescriptionExample
Namestring?Name of the asset.Apple Inc.
MarketTimeNoticestring?Notice of market status.Market Closed
PreviousClosedecimal?Previous closing price.180.14
Opendecimal?Opening price of the stock.182.20
Biddecimal?Current bid price.180.00
Askdecimal?Current ask price.181.00
DaysRange_Mindecimal?Minimum price today.179.50
DaysRange_Maxdecimal?Maximum price today.183.00
WeekRange52_Mindecimal?Minimum price in 52 weeks.130.20
WeekRange52_Maxdecimal?Maximum price in 52 weeks.190.50
Volumedecimal?Total volume traded today.25,000,000
AvgVolumedecimal?Average daily volume.30,000,000
MarketCap_Intradaydecimal?Market cap in the current session.2.85T
Beta_5Y_Monthlydecimal?5-year beta (monthly data).1.20
PE_Ratio_TTMdecimal?Price-to-earnings ratio (TTM).28.90
EPS_TTMdecimal?Earnings per share (TTM).6.22
EarningsDateDateTime?Date of the next earnings report.2025-02-15
Forward_Dividenddecimal?Expected forward dividend.0.88
Forward_Yielddecimal?Forward dividend yield.0.49%
Ex_DividendDateDateTime?Ex-dividend date.2025-01-10
OneYearTargetEstdecimal?One-year target price estimate.200.00

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve the summary for Apple Inc.varsummary=awaityahooService.GetSummaryAsync("AAPL");Console.WriteLine($"Name: {summary.Name}");Console.WriteLine($"Previous Close: {summary.PreviousClose}");Console.WriteLine($"Open: {summary.Open}");Console.WriteLine($"Bid: {summary.Bid}");Console.WriteLine($"Ask: {summary.Ask}");Console.WriteLine($"Average Volume: {summary.AvgVolume}");Console.WriteLine($"EPS (TTM): {summary.EPS_TTM}");}
GetFinancialsAsync

Description

Retrieves the financial reports for a specified asset identified by its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Dictionary<string, FinancialReport> where the key is the label (e.g., "Annual Report 2024") and the value is a FinancialReport containing the following properties:

PropertyTypeDescriptionExample
TickerSymbolstring?The company's stock symbol.AAPL
TotalRevenuedecimal?Total revenue generated.394,328,000,000
CostOfRevenuedecimal?Direct costs of goods/services sold.213,459,000,000
GrossProfitdecimal?Gross profit (Revenue - Cost of Revenue).180,869,000,000
OperatingExpensedecimal?Operating expenses incurred.34,152,000,000
OperatingIncomedecimal?Operating income (Gross Profit - Operating Expenses).146,717,000,000
NetNonOperatingInterestIncomeExpensedecimal?Net non-operating interest income/expense.2,500,000,000
OtherIncomeExpensedecimal?Other non-core income/expenses.-1,200,000,000
PretaxIncomedecimal?Pretax income before taxes.148,017,000,000
TaxProvisiondecimal?Income taxes provisioned.25,000,000,000
NetIncomeCommonStockholdersdecimal?Net income for common stockholders.123,017,000,000
DilutedNIAvailableToComStockholdersdecimal?Diluted net income for common stockholders.120,517,000,000
BasicEPSdecimal?Basic earnings per share.6.25
DilutedEPSdecimal?Diluted earnings per share.6.15
BasicAverageSharesdecimal?Basic average shares for EPS.19,700,000,000
DilutedAverageSharesdecimal?Diluted average shares for EPS.19,600,000,000
TotalOperatingIncomeAsReporteddecimal?Reported total operating income.146,700,000,000
TotalExpensesdecimal?Total expenses incurred.247,611,000,000
NetIncomeFromContinuingAndDiscontinuedOperationdecimal?Net income from all operations.123,017,000,000
NormalizedIncomedecimal?Normalized income adjusted for irregularities.125,500,000,000
InterestIncomedecimal?Interest income earned.5,000,000,000
InterestExpensedecimal?Interest expense incurred.2,500,000,000
NetInterestIncomedecimal?Net interest income (Income - Expense).2,500,000,000
EBITdecimal?Earnings Before Interest and Taxes.148,217,000,000
EBITDAdecimal?Earnings Before Interest, Taxes, Depreciation, and Amortization.151,217,000,000
ReconciledCostOfRevenuedecimal?Adjusted cost of revenue.212,000,000,000
ReconciledDepreciationdecimal?Adjusted depreciation expense.3,000,000,000
NetIncomeFromContinuingOperationNetMinorityInterestdecimal?Net income from continuing operations.121,017,000,000
TotalUnusualItemsExcludingGoodwilldecimal?Total unusual items, excluding goodwill.-2,000,000,000
TotalUnusualItemsdecimal?Total unusual items, including goodwill.-2,000,000,000
NormalizedEBITDAdecimal?Adjusted EBITDA for unusual items.153,217,000,000
TaxRateForCalcsdecimal?Tax rate used in calculations.16.9%
TaxEffectOfUnusualItemsdecimal?Tax effect of unusual items.-500,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve financial reports for Apple Inc.varfinancialReports=awaityahooService.GetFinancialsAsync("AAPL");foreach(varlabelinfinancialReports.Keys){varreport=financialReports[label];Console.WriteLine($"Label: {label}");Console.WriteLine($"Ticker Symbol: {report.TickerSymbol}");Console.WriteLine($"Total Revenue: {report.TotalRevenue}");Console.WriteLine($"Cost of Revenue: {report.CostOfRevenue}");Console.WriteLine($"Gross Profit: {report.GrossProfit}");Console.WriteLine($"Operating Income: {report.OperatingIncome}");Console.WriteLine($"Net Income: {report.NetIncomeCommonStockholders}");Console.WriteLine();}}
GetRecordsAsync

Description

Retrieves historical stock market data records for a specified asset identified by its symbol. Users can specify an optional date range.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for retrieving historical records. Defaults to 7 days before the current date if not provided.
  • DateTime? endDate: (Optional) End date for retrieving historical records. Defaults to the current date if not provided.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Record>, where each Record represents a historical data point with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record.2025-01-01
Opendecimal?The opening price.150.25
Highdecimal?The highest price during the trading session.155.00
Lowdecimal?The lowest price during the trading session.148.50
Closedecimal?The closing price at the end of the trading session.152.75
AdjustedClosedecimal?The adjusted closing price, accounting for stock splits and dividends.153.00
Volumelong?The trading volume (number of shares traded).10,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve historical records for Apple Inc. for the last 30 daysvarstartDate=DateTime.UtcNow.AddDays(-30);varendDate=DateTime.UtcNow;varrecords=awaityahooService.GetRecordsAsync("AAPL",startDate,endDate);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date:yyyy-MM-dd}");Console.WriteLine($"Open: {record.Open:C}");Console.WriteLine($"Close: {record.Close:C}");Console.WriteLine();}}
GetQuoteAsync

Description

Retrieves detailed information about a specific financial quote, identified by its symbol. This API is useful for accessing comprehensive data about a stock, ETF, or other traded financial instruments.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A cancellation token that can be used to cancel the operation if needed.

Returns

A task that resolves to a Quote object. The Quote record contains detailed information about the requested financial instrument, as described in the table below.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskDisplayQuote(IYahooFinanceServiceyahooService){// Retrieve a quote for Apple Inc.varquote=awaityahooService.GetQuoteAsync("AAPL");Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.ShortName}");Console.WriteLine($"Market Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Currency: {quote.Currency}");}
GetQuotesAsync

Description

Retrieves quote data for multiple financial instruments identified by their symbols. The data includes detailed information about each instrument, such as pricing, market performance, and other financial metrics.

Parameters

  • List<string> symbols: A list of symbols for which to retrieve data (e.g., ["AAPL", "MSFT", "GOOGL"]).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Quote>, where each Quote provides comprehensive data about a specific instrument.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve quotes for Apple, Microsoft, and Googlevarsymbols=newList<string>{"AAPL","MSFT","GOOGL"};varquotes=awaityahooService.GetQuotesAsync(symbols);foreach(varquoteinquotes){Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.DisplayName}");Console.WriteLine($"Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Dividend Yield: {quote.DividendYield:P}");Console.WriteLine($"Earnings Date: {quote.EarningsDate:yyyy-MM-dd}");Console.WriteLine();}}

Alpha Vantage

Offers stock, forex, and cryptocurrency data including intraday and historical records.

Get an API key

To get started, obtain a free API key from Alpha Vantage.

Configure API key

After acquiring your API key, configure it in your service collection:

services.AddFinanceNet(newFinanceNetConfiguration{AlphaVantageApiKey="API_KEY"});

Methods

GetOverviewAsync

Description

Retrieves an instrument overview for a specified stock symbol.

Parameters

  • string symbol: The symbol of the asset (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A token to cancel the operation if needed.

Returns

A task that resolves to an InstrumentOverview?. The InstrumentOverview contains the following properties that provide key information about the company:

PropertyTypeDescriptionExample
Symbolstring?The stock symbol."AAPL"
AssetTypestring?The type of asset (e.g., stock, ETF)."Equity"
Namestring?The name of the ticker or company."Apple Inc."
Descriptionstring?A brief company description."Designs ... ."
CIKstring?The Central Index Key (CIK) of the company."0000320193"
Exchangestring?The exchange where the company is listed."NASDAQ"
Currencystring?The currency used for financials."USD"
Countrystring?The country where the company is located."United States"
Sectorstring?The company's sector (e.g., Technology)."Technology"
Industrystring?The industry the company operates in."Consumer Electronics"
Addressstring?The company's headquarters address."Cupertino, CA"
OfficialSitestring?The official website of the company."https://www.apple.com"
FiscalYearEndstring?The fiscal year end date."September 30"
LatestQuarterstring?The most recent available quarter."Q3 2024"
MarketCapitalizationlong?The market capitalization.2320000000000
EBITDAstring?EBITDA."11200000000"
PERatiostring?The Price-to-Earnings ratio."27.5"
PEGRatiostring?The Price/Earnings-to-Growth ratio."1.4"
BookValuestring?The company's book value."10.52"
DividendPerSharestring?The dividend per share."0.82"
DividendYieldstring?The dividend yield."1.5%"
EPSstring?Earnings per share."5.26"
RevenuePerShareTTMstring?Revenue per share for the trailing twelve months."30.5"
ProfitMarginstring?Profit margin."25%"
OperatingMarginTTMstring?Operating margin for the trailing twelve months."22%"
ReturnOnAssetsTTMstring?Return on assets for the trailing twelve months."14%"
ReturnOnEquityTTMstring?Return on equity for the trailing twelve months."40%"
RevenueTTMstring?Revenue for the trailing twelve months."386000000000"
GrossProfitTTMstring?Gross profit for the trailing twelve months."160000000000"
DilutedEPSTTMstring?Diluted earnings per share for the trailing twelve months."5.10"
QuarterlyEarningsGrowthYOYstring?Quarterly earnings growth year-over-year."15%"
QuarterlyRevenueGrowthYOYstring?Quarterly revenue growth year-over-year."10%"
AnalystTargetPricestring?Analyst target price for the stock."175.00"
AnalystRatingStrongBuystring?Percentage of analysts recommending a strong buy."60%"
AnalystRatingBuystring?Percentage of analysts recommending a buy."30%"
AnalystRatingHoldstring?Percentage of analysts recommending a hold."10%"
AnalystRatingSellstring?Percentage of analysts recommending a sell."0%"
AnalystRatingStrongSellstring?Percentage of analysts recommending a strong sell."0%"
TrailingPEstring?Trailing Price-to-Earnings ratio."28"
ForwardPEstring?Forward Price-to-Earnings ratio."25"
PriceToSalesRatioTTMstring?Price-to-Sales ratio for the trailing twelve months."6.5"
PriceToBookRatiostring?Price-to-Book ratio."4.3"
EVToRevenuestring?Enterprise value-to-revenue ratio."8.2"
EVToEBITDAstring?Enterprise value-to-EBITDA ratio."14.5"
Betastring?Beta value, measuring stock volatility."1.2"
FiftySecondWeekHighstring?52-week high stock price."179.50"
FiftySecondWeekLowstring?52-week low stock price."120.10"
FiftyDayMovingAveragestring?50-day moving average."153.25"
TwoHundredDayMovingAveragestring?200-day moving average."157.80"
SharesOutstandingstring?Number of shares outstanding."5000000000"
DividendDatestring?Next dividend payment date."2025-02-01"
ExDividendDatestring?Ex-dividend date."2025-01-10"

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve the overview for Apple Inc.varoverview=awaitalphaVantageService.GetOverviewAsync("AAPL");if(overview!=null){Console.WriteLine($"Symbol: {overview.Symbol}");Console.WriteLine($"Name: {overview.Name}");Console.WriteLine($"Sector: {overview.Sector}");Console.WriteLine($"Market Capitalization: {overview.MarketCapitalization}");Console.WriteLine($"Dividend Yield: {overview.DividendYield}");Console.WriteLine($"P/E Ratio: {overview.PERatio}");Console.WriteLine($"Revenue (TTM): {overview.RevenueTTM}");}}
GetRecordsAsync

Description

Retrieves historical daily stock records for a given symbol within an optional date range.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for the records. Defaults to 7 days ago.
  • DateTime? endDate: (Optional) End date for the records. Defaults to current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<Record>, with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record."2024-12-15"
Opendouble?The opening price of the asset.150.25
Lowdouble?The lowest price of the asset on that date.148.75
Highdouble?The highest price of the asset on that date.153.50
Closedouble?The closing price of the asset.151.00
AdjustedClosedouble?The adjusted closing price, considering stock splits and dividends.150.80
Volumelong?The trading volume of the asset on that date.1000000
SplitCoefficientdouble?The stock split coefficient, if any, for the given date.1.0

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical records for Apple Inc. (AAPL)varrecords=awaitalphaVantageService.GetRecordsAsync("AAPL",DateTime.Now.AddDays(-7),DateTime.Now);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date.ToShortDateString()}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"High: {record.High}");Console.WriteLine($"Low: {record.Low}");Console.WriteLine($"Close: {record.Close}");Console.WriteLine($"Adjusted Close: {record.AdjustedClose}");Console.WriteLine($"Volume: {record.Volume}");Console.WriteLine($"Split Coefficient: {record.SplitCoefficient}");Console.WriteLine();}}
GetForexRecordsAsync

Description

Retrieves historical daily forex (foreign exchange) records for a given currency pair within a specified date range.

Parameters

  • string currency1: The source currency (e.g., "USD").
  • string currency2: The target currency (e.g., "EUR").
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<ForexRecord>, with the following properties:

PropertyTypeDescriptionExample
DateDateTime?The date of the forex record."2024-12-15"
Opendouble?The opening price of the currency pair for that date.1.1215
Highdouble?The highest price of the currency pair for that date.1.1250
Lowdouble?The lowest price of the currency pair for that date.1.1180
Closedouble?The closing price of the currency pair for that date.1.1220

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical forex records for USD to EURvarforexRecords=awaitalphaVantageService.GetForexRecordsAsync("USD","EUR",DateTime.Now.AddDays(-7));foreach(varrecordinforexRecords){Console.WriteLine($"Date: {record.Date}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}
GetIntradayRecordsAsync

Description

Retrieves intraday stock records for a given symbol within a specified date range and time interval.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • EInterval interval: The time interval between data points. Default is 15 minutes. Possible values:
    • Interval_1Min
    • Interval_5Min
    • Interval_15Min
    • Interval_30Min
    • Interval_60Min
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<IntradayRecord>, with the following properties:

PropertyTypeDescriptionExample
DateTimeDateTimeThe date and time of the record."2024-12-15 09:30"
OpendoubleThe opening price of the stock for that interval.145.32
HighdoubleThe highest price of the stock for that interval.147.10
LowdoubleThe lowest price of the stock for that interval.144.98
ClosedoubleThe closing price of the stock for that interval.146.30
VolumelongThe trading volume during that interval.1234567

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve intraday stock records for AAPL with a 15-minute intervalvarintradayRecords=awaitalphaVantageService.GetIntradayRecordsAsync("AAPL",DateTime.Now.AddDays(-1),DateTime.Now,EInterval.Interval_15Min);foreach(varrecordinintradayRecords){Console.WriteLine($"DateTime: {record.DateTime}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}

DataHub

Accesses datasets like Nasdaq and S&P 500 companies.

Methods

GetNasdaqInstrumentsAsync

Description

Retrieves a collection of more than 4,000 Nasdaq instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<NasdaqInstrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.TSLA
Namestring?The company name associated with the instrument.Tesla, Inc.

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetNasdaqInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}");}}
GetSp500InstrumentsAsync

Description

Retrieves a collection of S&P 500 instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Sp500Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the instrument.TSLA
Namestring?Name of the instrument/company.Tesla, Inc.
Sectorstring?Sector of the instrument.Automobile Manufacturers
Pricedouble?Current price of the instrument.345.16
PriceEarningsdouble?Price-to-earnings ratio.94.31
DividendYielddouble?Dividend yield.0.89
EarningsSharedouble?Earnings per share.3.66
FiftyTwoWeekLowdouble?52-week low price.338.8
FiftyTwoWeekHighdouble?52-week high price.361.93
MarketCaplong?Market capitalization.1107284384000
EBITDAlong?EBITDA value.13244000256
PriceSalesdouble?Price-to-sales ratio.11.41
PriceBookdouble?Price-to-book ratio.15.82

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetSp500InstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}, Sector: {item.Sector}");}}

Xetra

A major European trading platform offering data on Xetra-listed instruments.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of more than 3,000 Xetra instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the financial instrument.TL0.DE
InstrumentStatusstring?Current status of the instrument.Active
InstrumentNamestring?Full name of the financial instrument.TESLA INC. DL -,001
ISINstring?International Securities Identification Number.US88160R1014
WKNstring?German securities identification number.000A1CX3T
Mnemonicstring?Shorthand or mnemonic code for the instrument.TL0
InstrumentTypestring?Type of financial instrument (e.g., CS, ETF, ETN).CS
Currencystring?Currency in which the instrument is traded.EUR

Example

publicasyncTaskRun(IXetraServicexetraService){varinstruments=awaitxetraService.GetInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.InstrumentName}");}}

🤝 How to Contribute

We welcome contributions to Finance.NET! If you’d like to improve the project, please:

  1. Check out our contributing guidelines.
  2. Ideally, open an issue before starting work.
  3. Submit a pull request with your changes.

Thank you for helping make Finance.NET better!


ℹ️ Disclaimer

Finance.NET is an open-source project using publicly accessible APIs and scraping techniques. It is intended for educational and research purposes.

For legal usage, refer to the terms of each data provider:

For additional licensing and attribution details, see NOTICE.md.


🐞 Report a Bug

If you encounter any issues or bugs, please report them here.

About

A .NET library for retrieving real-time and historical financial data from Yahoo Finance and other popular sources.

Topics

Resources

Code of conduct

Contributing

Stars

22 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

Banner

CICoverageQuality GateNuGetDownloads.NET StandardStars

An easy-to-use .NET library for accessing and aggregating financial data from multiple sources.

This library enables developers to retrieve financial data via APIs and HTML scraping from a variety of providers. It's ideal for building analytical tools, dashboards, or financial applications that require access to market data.


⭐ Features

  • Retrieve Instruments: Get tradable ticker symbols and associated details.
  • Fundamentals: Access key financial metrics and company fundamentals.
  • Historical Records: Fetch historical data for analysis or charting.
  • Real-Time Quotes: Receive live updates on stock prices and market data.

🚀 Getting started

This section guides you through installing Finance.NET, configuring services, and basic data retrieval.

Installation

Install via NuGet:

dotnet add package Finance.NET

Register in Service Collection

Add Finance.NET to your service collection for dependency injection:

services.AddFinanceNet();

Optional: Configure with custom settings.

services.AddFinanceNet(newFinanceNetConfiguration{HttpTimeout=5,// seconds (default: 20)HttpRetryCount=3,// default: 10HttpRetrySleepTime=5,// seconds, base for exponential back-off; capped at 30s per attempt, plus jitter (default: 5)AlphaVantageApiKey="ALPHA_VANTAGE__API_KEY"});

Basic Usage

Example: Retrieve historical and real-time data for Tesla (TSLA):

publicasyncTaskRun(IYahooFinanceServiceyahooService){varsymbol="TSLA";varstartDate=newDateTime(2020,1,1);varrecords=awaityahooService.GetRecordsAsync(symbol,startDate);foreach(varrecordinrecords){Console.WriteLine($"Date={record.Date}: {record.Open} / {record.Close}");}varquote=awaityahooService.GetQuoteAsync(symbol);Console.WriteLine($"Bid={quote.Bid}, Ask={quote.Ask}");}

🔌Finance.NET Service Interfaces

Finance.NET exposes modular service interfaces for accessing diverse financial data through a consistent API. Each interface corresponds to a specific provider and supports its unique features.

Yahoo! Finance

Provides market data, company fundamentals, historical records, and real-time quotes.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of financial instruments.

Parameters

  • EInstrumentType? filterByType: An optional filter to specify the type of asset. If not provided, all asset types will be included. Possible values:
    • Stock: Most active stocks.
    • ETF: Most active exchange-traded funds (ETFs)
    • Forex: Available currencies (foreign exchange).
    • Crypto: Available cryptocurrencies.
    • Index: Available world indices.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.AAPL
InstrumentTypeEInstrumentType?The type of the financial instrument.Stock

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve all instrumentsvarinstruments=awaityahooService.GetInstrumentsAsync();// Retrieve only stock instrumentsvarstockInstruments=awaityahooService.GetInstrumentsAsync(EInstrumentType.Stock);foreach(varinstrumentinstockInstruments){Console.WriteLine($"Symbol: {instrument.Symbol}, Type: {instrument.InstrumentType}");}}
GetProfileAsync

Description

Retrieves the profile of a specific entity based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Profile containing the following properties:

PropertyTypeDescriptionExample
Adressstring?The address.One Apple Park Way, Cupertino, CA 95014
Phonestring?The phone number.+1-800-MY-APPLE
Websitestring?The website URL.https://www.apple.com
Sectorstring?The sector in which the entity operates.Technology
Industrystring?The industry the entity belongs to.Consumer Electronics
CntEmployeeslong?The number of employees.164000
Descriptionstring?A brief description.Apple designs and ...

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){varprofile=awaityahooService.GetProfileAsync("AAPL");Console.WriteLine($"Address: {profile.Adress}");Console.WriteLine($"Sector: {profile.Sector}");Console.WriteLine($"Industry: {profile.Industry}");Console.WriteLine($"Description: {profile.Description}");}
GetSummaryAsync

Description

Retrieves the summary of a specific asset based on its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Summary containing the following properties:

PropertyTypeDescriptionExample
Namestring?Name of the asset.Apple Inc.
MarketTimeNoticestring?Notice of market status.Market Closed
PreviousClosedecimal?Previous closing price.180.14
Opendecimal?Opening price of the stock.182.20
Biddecimal?Current bid price.180.00
Askdecimal?Current ask price.181.00
DaysRange_Mindecimal?Minimum price today.179.50
DaysRange_Maxdecimal?Maximum price today.183.00
WeekRange52_Mindecimal?Minimum price in 52 weeks.130.20
WeekRange52_Maxdecimal?Maximum price in 52 weeks.190.50
Volumedecimal?Total volume traded today.25,000,000
AvgVolumedecimal?Average daily volume.30,000,000
MarketCap_Intradaydecimal?Market cap in the current session.2.85T
Beta_5Y_Monthlydecimal?5-year beta (monthly data).1.20
PE_Ratio_TTMdecimal?Price-to-earnings ratio (TTM).28.90
EPS_TTMdecimal?Earnings per share (TTM).6.22
EarningsDateDateTime?Date of the next earnings report.2025-02-15
Forward_Dividenddecimal?Expected forward dividend.0.88
Forward_Yielddecimal?Forward dividend yield.0.49%
Ex_DividendDateDateTime?Ex-dividend date.2025-01-10
OneYearTargetEstdecimal?One-year target price estimate.200.00

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve the summary for Apple Inc.varsummary=awaityahooService.GetSummaryAsync("AAPL");Console.WriteLine($"Name: {summary.Name}");Console.WriteLine($"Previous Close: {summary.PreviousClose}");Console.WriteLine($"Open: {summary.Open}");Console.WriteLine($"Bid: {summary.Bid}");Console.WriteLine($"Ask: {summary.Ask}");Console.WriteLine($"Average Volume: {summary.AvgVolume}");Console.WriteLine($"EPS (TTM): {summary.EPS_TTM}");}
GetFinancialsAsync

Description

Retrieves the financial reports for a specified asset identified by its symbol.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to a Dictionary<string, FinancialReport> where the key is the label (e.g., "Annual Report 2024") and the value is a FinancialReport containing the following properties:

PropertyTypeDescriptionExample
TickerSymbolstring?The company's stock symbol.AAPL
TotalRevenuedecimal?Total revenue generated.394,328,000,000
CostOfRevenuedecimal?Direct costs of goods/services sold.213,459,000,000
GrossProfitdecimal?Gross profit (Revenue - Cost of Revenue).180,869,000,000
OperatingExpensedecimal?Operating expenses incurred.34,152,000,000
OperatingIncomedecimal?Operating income (Gross Profit - Operating Expenses).146,717,000,000
NetNonOperatingInterestIncomeExpensedecimal?Net non-operating interest income/expense.2,500,000,000
OtherIncomeExpensedecimal?Other non-core income/expenses.-1,200,000,000
PretaxIncomedecimal?Pretax income before taxes.148,017,000,000
TaxProvisiondecimal?Income taxes provisioned.25,000,000,000
NetIncomeCommonStockholdersdecimal?Net income for common stockholders.123,017,000,000
DilutedNIAvailableToComStockholdersdecimal?Diluted net income for common stockholders.120,517,000,000
BasicEPSdecimal?Basic earnings per share.6.25
DilutedEPSdecimal?Diluted earnings per share.6.15
BasicAverageSharesdecimal?Basic average shares for EPS.19,700,000,000
DilutedAverageSharesdecimal?Diluted average shares for EPS.19,600,000,000
TotalOperatingIncomeAsReporteddecimal?Reported total operating income.146,700,000,000
TotalExpensesdecimal?Total expenses incurred.247,611,000,000
NetIncomeFromContinuingAndDiscontinuedOperationdecimal?Net income from all operations.123,017,000,000
NormalizedIncomedecimal?Normalized income adjusted for irregularities.125,500,000,000
InterestIncomedecimal?Interest income earned.5,000,000,000
InterestExpensedecimal?Interest expense incurred.2,500,000,000
NetInterestIncomedecimal?Net interest income (Income - Expense).2,500,000,000
EBITdecimal?Earnings Before Interest and Taxes.148,217,000,000
EBITDAdecimal?Earnings Before Interest, Taxes, Depreciation, and Amortization.151,217,000,000
ReconciledCostOfRevenuedecimal?Adjusted cost of revenue.212,000,000,000
ReconciledDepreciationdecimal?Adjusted depreciation expense.3,000,000,000
NetIncomeFromContinuingOperationNetMinorityInterestdecimal?Net income from continuing operations.121,017,000,000
TotalUnusualItemsExcludingGoodwilldecimal?Total unusual items, excluding goodwill.-2,000,000,000
TotalUnusualItemsdecimal?Total unusual items, including goodwill.-2,000,000,000
NormalizedEBITDAdecimal?Adjusted EBITDA for unusual items.153,217,000,000
TaxRateForCalcsdecimal?Tax rate used in calculations.16.9%
TaxEffectOfUnusualItemsdecimal?Tax effect of unusual items.-500,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve financial reports for Apple Inc.varfinancialReports=awaityahooService.GetFinancialsAsync("AAPL");foreach(varlabelinfinancialReports.Keys){varreport=financialReports[label];Console.WriteLine($"Label: {label}");Console.WriteLine($"Ticker Symbol: {report.TickerSymbol}");Console.WriteLine($"Total Revenue: {report.TotalRevenue}");Console.WriteLine($"Cost of Revenue: {report.CostOfRevenue}");Console.WriteLine($"Gross Profit: {report.GrossProfit}");Console.WriteLine($"Operating Income: {report.OperatingIncome}");Console.WriteLine($"Net Income: {report.NetIncomeCommonStockholders}");Console.WriteLine();}}
GetRecordsAsync

Description

Retrieves historical stock market data records for a specified asset identified by its symbol. Users can specify an optional date range.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for retrieving historical records. Defaults to 7 days before the current date if not provided.
  • DateTime? endDate: (Optional) End date for retrieving historical records. Defaults to the current date if not provided.
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Record>, where each Record represents a historical data point with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record.2025-01-01
Opendecimal?The opening price.150.25
Highdecimal?The highest price during the trading session.155.00
Lowdecimal?The lowest price during the trading session.148.50
Closedecimal?The closing price at the end of the trading session.152.75
AdjustedClosedecimal?The adjusted closing price, accounting for stock splits and dividends.153.00
Volumelong?The trading volume (number of shares traded).10,000,000

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve historical records for Apple Inc. for the last 30 daysvarstartDate=DateTime.UtcNow.AddDays(-30);varendDate=DateTime.UtcNow;varrecords=awaityahooService.GetRecordsAsync("AAPL",startDate,endDate);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date:yyyy-MM-dd}");Console.WriteLine($"Open: {record.Open:C}");Console.WriteLine($"Close: {record.Close:C}");Console.WriteLine();}}
GetQuoteAsync

Description

Retrieves detailed information about a specific financial quote, identified by its symbol. This API is useful for accessing comprehensive data about a stock, ETF, or other traded financial instruments.

Parameters

  • string symbol: The symbol of the quote (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A cancellation token that can be used to cancel the operation if needed.

Returns

A task that resolves to a Quote object. The Quote record contains detailed information about the requested financial instrument, as described in the table below.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskDisplayQuote(IYahooFinanceServiceyahooService){// Retrieve a quote for Apple Inc.varquote=awaityahooService.GetQuoteAsync("AAPL");Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.ShortName}");Console.WriteLine($"Market Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Currency: {quote.Currency}");}
GetQuotesAsync

Description

Retrieves quote data for multiple financial instruments identified by their symbols. The data includes detailed information about each instrument, such as pricing, market performance, and other financial metrics.

Parameters

  • List<string> symbols: A list of symbols for which to retrieve data (e.g., ["AAPL", "MSFT", "GOOGL"]).
  • CancellationToken token: (Optional) Cancellation token to cancel the operation if needed.

Returns

A task that resolves to an IEnumerable<Quote>, where each Quote provides comprehensive data about a specific instrument.

PropertyTypeDescriptionExample
Languagestring?The language of the quote."en"
Regionstring?The region of the quote."US"
QuoteTypestring?The type of the quote."equity"
TypeDispstring?The display type of the quote."STOCK"
QuoteSourceNamestring?The source of the quote."Yahoo Finance"
CustomPriceAlertConfidencestring?The confidence level of a custom price alert."HIGH"
Currencystring?The currency in which the stock is traded."USD"
Exchangestring?The exchange on which the stock is listed."NASDAQ"
ShortNamestring?The short name of the symbol."AAPL"
LongNamestring?The full name of the symbol."Apple Inc."
ExchangeTimezoneNamestring?The time zone of the exchange."America/New_York"
ExchangeTimezoneShortNamestring?The abbreviated time zone of the exchange."EST"
GmtOffSetMillisecondslong?The GMT offset in milliseconds.-18000000
Marketstring?The market the instrument is listed on."Equity"
EsgPopulatedbool?Indicates if ESG (Environmental, Social, Governance) data is populated.true
RegularMarketChangePercentdouble?The percentage change in the regular market price.2.35
RegularMarketPricedouble?The regular market price of the stock.145.67
MarketStatestring?The market state (e.g., open or closed)."OPEN"
FullExchangeNamestring?The full name of the exchange."NASDAQ Stock Market"
FinancialCurrencystring?The financial currency used for the quote."USD"
RegularMarketOpendouble?The opening price of the regular market.143.50
AverageDailyVolume3Monthlong?The average volume over the last 3 months.1500000
AverageDailyVolume10Daylong?The average volume over the last 10 days.2000000
FiftyTwoWeekLowChangedouble?The change in the 52-week low price.10.00
FiftyTwoWeekLowChangePercentdouble?The percentage change in the 52-week low price.7.5
FiftyTwoWeekRangestring?The 52-week price range."120.00 - 160.00"
FiftyTwoWeekHighChangedouble?The change in the 52-week high price.-5.00
FiftyTwoWeekHighChangePercentdouble?The percentage change in the 52-week high price.-3.12
FiftyTwoWeekLowdouble?The price at its 52-week low.120.00
FiftyTwoWeekHighdouble?The price at its 52-week high.160.00
FiftyTwoWeekChangePercentdouble?The percentage change in the 52-week price.5.0
EarningsDateDateTime?The earnings date.2025-02-01
DividendRatedouble?The current dividend rate.0.22
DividendDateDateTime?The date of the next dividend payment.2025-04-15
TrailingAnnualDividendYielddouble?The trailing annual dividend yield.1.5
MarketCaplong?The market capitalization of the company.2450000000000
ForwardPedouble?The forward PE ratio.28.9
PriceToBookdouble?The price-to-book ratio.12.5
AverageAnalystRatingstring?The average analyst rating."Buy"
Tradeablebool?Indicates whether the instrument is tradeable.true
HasPrePostMarketDatabool?Has the quote pre/post-market data.true
FirstTradeDateDateTime?The date of the first trade.1980-12-12
DisplayNamestring?The display name of the stock."Apple Inc."
Symbolstring?The symbol (ticker) of the stock."AAPL"

Example

publicasyncTaskRun(IYahooFinanceServiceyahooService){// Retrieve quotes for Apple, Microsoft, and Googlevarsymbols=newList<string>{"AAPL","MSFT","GOOGL"};varquotes=awaityahooService.GetQuotesAsync(symbols);foreach(varquoteinquotes){Console.WriteLine($"Symbol: {quote.Symbol}");Console.WriteLine($"Name: {quote.DisplayName}");Console.WriteLine($"Price: {quote.RegularMarketPrice:C}");Console.WriteLine($"52-Week High: {quote.FiftyTwoWeekHigh:C}");Console.WriteLine($"52-Week Low: {quote.FiftyTwoWeekLow:C}");Console.WriteLine($"Market Cap: {quote.MarketCap:N0}");Console.WriteLine($"Dividend Yield: {quote.DividendYield:P}");Console.WriteLine($"Earnings Date: {quote.EarningsDate:yyyy-MM-dd}");Console.WriteLine();}}

Alpha Vantage

Offers stock, forex, and cryptocurrency data including intraday and historical records.

Get an API key

To get started, obtain a free API key from Alpha Vantage.

Configure API key

After acquiring your API key, configure it in your service collection:

services.AddFinanceNet(newFinanceNetConfiguration{AlphaVantageApiKey="API_KEY"});

Methods

GetOverviewAsync

Description

Retrieves an instrument overview for a specified stock symbol.

Parameters

  • string symbol: The symbol of the asset (e.g., "AAPL" for Apple).
  • CancellationToken token: (Optional) A token to cancel the operation if needed.

Returns

A task that resolves to an InstrumentOverview?. The InstrumentOverview contains the following properties that provide key information about the company:

PropertyTypeDescriptionExample
Symbolstring?The stock symbol."AAPL"
AssetTypestring?The type of asset (e.g., stock, ETF)."Equity"
Namestring?The name of the ticker or company."Apple Inc."
Descriptionstring?A brief company description."Designs ... ."
CIKstring?The Central Index Key (CIK) of the company."0000320193"
Exchangestring?The exchange where the company is listed."NASDAQ"
Currencystring?The currency used for financials."USD"
Countrystring?The country where the company is located."United States"
Sectorstring?The company's sector (e.g., Technology)."Technology"
Industrystring?The industry the company operates in."Consumer Electronics"
Addressstring?The company's headquarters address."Cupertino, CA"
OfficialSitestring?The official website of the company."https://www.apple.com"
FiscalYearEndstring?The fiscal year end date."September 30"
LatestQuarterstring?The most recent available quarter."Q3 2024"
MarketCapitalizationlong?The market capitalization.2320000000000
EBITDAstring?EBITDA."11200000000"
PERatiostring?The Price-to-Earnings ratio."27.5"
PEGRatiostring?The Price/Earnings-to-Growth ratio."1.4"
BookValuestring?The company's book value."10.52"
DividendPerSharestring?The dividend per share."0.82"
DividendYieldstring?The dividend yield."1.5%"
EPSstring?Earnings per share."5.26"
RevenuePerShareTTMstring?Revenue per share for the trailing twelve months."30.5"
ProfitMarginstring?Profit margin."25%"
OperatingMarginTTMstring?Operating margin for the trailing twelve months."22%"
ReturnOnAssetsTTMstring?Return on assets for the trailing twelve months."14%"
ReturnOnEquityTTMstring?Return on equity for the trailing twelve months."40%"
RevenueTTMstring?Revenue for the trailing twelve months."386000000000"
GrossProfitTTMstring?Gross profit for the trailing twelve months."160000000000"
DilutedEPSTTMstring?Diluted earnings per share for the trailing twelve months."5.10"
QuarterlyEarningsGrowthYOYstring?Quarterly earnings growth year-over-year."15%"
QuarterlyRevenueGrowthYOYstring?Quarterly revenue growth year-over-year."10%"
AnalystTargetPricestring?Analyst target price for the stock."175.00"
AnalystRatingStrongBuystring?Percentage of analysts recommending a strong buy."60%"
AnalystRatingBuystring?Percentage of analysts recommending a buy."30%"
AnalystRatingHoldstring?Percentage of analysts recommending a hold."10%"
AnalystRatingSellstring?Percentage of analysts recommending a sell."0%"
AnalystRatingStrongSellstring?Percentage of analysts recommending a strong sell."0%"
TrailingPEstring?Trailing Price-to-Earnings ratio."28"
ForwardPEstring?Forward Price-to-Earnings ratio."25"
PriceToSalesRatioTTMstring?Price-to-Sales ratio for the trailing twelve months."6.5"
PriceToBookRatiostring?Price-to-Book ratio."4.3"
EVToRevenuestring?Enterprise value-to-revenue ratio."8.2"
EVToEBITDAstring?Enterprise value-to-EBITDA ratio."14.5"
Betastring?Beta value, measuring stock volatility."1.2"
FiftySecondWeekHighstring?52-week high stock price."179.50"
FiftySecondWeekLowstring?52-week low stock price."120.10"
FiftyDayMovingAveragestring?50-day moving average."153.25"
TwoHundredDayMovingAveragestring?200-day moving average."157.80"
SharesOutstandingstring?Number of shares outstanding."5000000000"
DividendDatestring?Next dividend payment date."2025-02-01"
ExDividendDatestring?Ex-dividend date."2025-01-10"

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve the overview for Apple Inc.varoverview=awaitalphaVantageService.GetOverviewAsync("AAPL");if(overview!=null){Console.WriteLine($"Symbol: {overview.Symbol}");Console.WriteLine($"Name: {overview.Name}");Console.WriteLine($"Sector: {overview.Sector}");Console.WriteLine($"Market Capitalization: {overview.MarketCapitalization}");Console.WriteLine($"Dividend Yield: {overview.DividendYield}");Console.WriteLine($"P/E Ratio: {overview.PERatio}");Console.WriteLine($"Revenue (TTM): {overview.RevenueTTM}");}}
GetRecordsAsync

Description

Retrieves historical daily stock records for a given symbol within an optional date range.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime? startDate: (Optional) Start date for the records. Defaults to 7 days ago.
  • DateTime? endDate: (Optional) End date for the records. Defaults to current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<Record>, with the following properties:

PropertyTypeDescriptionExample
DateDateTimeThe date of the record."2024-12-15"
Opendouble?The opening price of the asset.150.25
Lowdouble?The lowest price of the asset on that date.148.75
Highdouble?The highest price of the asset on that date.153.50
Closedouble?The closing price of the asset.151.00
AdjustedClosedouble?The adjusted closing price, considering stock splits and dividends.150.80
Volumelong?The trading volume of the asset on that date.1000000
SplitCoefficientdouble?The stock split coefficient, if any, for the given date.1.0

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical records for Apple Inc. (AAPL)varrecords=awaitalphaVantageService.GetRecordsAsync("AAPL",DateTime.Now.AddDays(-7),DateTime.Now);foreach(varrecordinrecords){Console.WriteLine($"Date: {record.Date.ToShortDateString()}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"High: {record.High}");Console.WriteLine($"Low: {record.Low}");Console.WriteLine($"Close: {record.Close}");Console.WriteLine($"Adjusted Close: {record.AdjustedClose}");Console.WriteLine($"Volume: {record.Volume}");Console.WriteLine($"Split Coefficient: {record.SplitCoefficient}");Console.WriteLine();}}
GetForexRecordsAsync

Description

Retrieves historical daily forex (foreign exchange) records for a given currency pair within a specified date range.

Parameters

  • string currency1: The source currency (e.g., "USD").
  • string currency2: The target currency (e.g., "EUR").
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<ForexRecord>, with the following properties:

PropertyTypeDescriptionExample
DateDateTime?The date of the forex record."2024-12-15"
Opendouble?The opening price of the currency pair for that date.1.1215
Highdouble?The highest price of the currency pair for that date.1.1250
Lowdouble?The lowest price of the currency pair for that date.1.1180
Closedouble?The closing price of the currency pair for that date.1.1220

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve historical forex records for USD to EURvarforexRecords=awaitalphaVantageService.GetForexRecordsAsync("USD","EUR",DateTime.Now.AddDays(-7));foreach(varrecordinforexRecords){Console.WriteLine($"Date: {record.Date}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}
GetIntradayRecordsAsync

Description

Retrieves intraday stock records for a given symbol within a specified date range and time interval.

Parameters

  • string symbol: The stock symbol (e.g., "AAPL" for Apple).
  • DateTime startDate: The start date for the records.
  • DateTime? endDate: (Optional) The end date for the records. Defaults to the current date.
  • EInterval interval: The time interval between data points. Default is 15 minutes. Possible values:
    • Interval_1Min
    • Interval_5Min
    • Interval_15Min
    • Interval_30Min
    • Interval_60Min
  • CancellationToken token: (Optional) A token to cancel the operation.

Returns

A task that resolves to an IEnumerable<IntradayRecord>, with the following properties:

PropertyTypeDescriptionExample
DateTimeDateTimeThe date and time of the record."2024-12-15 09:30"
OpendoubleThe opening price of the stock for that interval.145.32
HighdoubleThe highest price of the stock for that interval.147.10
LowdoubleThe lowest price of the stock for that interval.144.98
ClosedoubleThe closing price of the stock for that interval.146.30
VolumelongThe trading volume during that interval.1234567

Example

publicasyncTaskRun(IAlphaVantageServicealphaVantageService){// Retrieve intraday stock records for AAPL with a 15-minute intervalvarintradayRecords=awaitalphaVantageService.GetIntradayRecordsAsync("AAPL",DateTime.Now.AddDays(-1),DateTime.Now,EInterval.Interval_15Min);foreach(varrecordinintradayRecords){Console.WriteLine($"DateTime: {record.DateTime}");Console.WriteLine($"Open: {record.Open}");Console.WriteLine($"Close: {record.Close}");}}

DataHub

Accesses datasets like Nasdaq and S&P 500 companies.

Methods

GetNasdaqInstrumentsAsync

Description

Retrieves a collection of more than 4,000 Nasdaq instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<NasdaqInstrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?The ticker symbol of the instrument.TSLA
Namestring?The company name associated with the instrument.Tesla, Inc.

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetNasdaqInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}");}}
GetSp500InstrumentsAsync

Description

Retrieves a collection of S&P 500 instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Sp500Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the instrument.TSLA
Namestring?Name of the instrument/company.Tesla, Inc.
Sectorstring?Sector of the instrument.Automobile Manufacturers
Pricedouble?Current price of the instrument.345.16
PriceEarningsdouble?Price-to-earnings ratio.94.31
DividendYielddouble?Dividend yield.0.89
EarningsSharedouble?Earnings per share.3.66
FiftyTwoWeekLowdouble?52-week low price.338.8
FiftyTwoWeekHighdouble?52-week high price.361.93
MarketCaplong?Market capitalization.1107284384000
EBITDAlong?EBITDA value.13244000256
PriceSalesdouble?Price-to-sales ratio.11.41
PriceBookdouble?Price-to-book ratio.15.82

Example

publicasyncTaskRun(IDataHubServicedatahubService){varinstruments=awaitdatahubService.GetSp500InstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.Name}, Sector: {item.Sector}");}}

Xetra

A major European trading platform offering data on Xetra-listed instruments.

Methods

GetInstrumentsAsync

Description

Retrieves a collection of more than 3,000 Xetra instruments.

Parameters

  • CancellationToken token: (Optional) Cancellation token.

Returns

A task that resolves to an IEnumerable<Instrument> containing the following properties for each item:

PropertyTypeDescriptionExample
Symbolstring?Ticker symbol of the financial instrument.TL0.DE
InstrumentStatusstring?Current status of the instrument.Active
InstrumentNamestring?Full name of the financial instrument.TESLA INC. DL -,001
ISINstring?International Securities Identification Number.US88160R1014
WKNstring?German securities identification number.000A1CX3T
Mnemonicstring?Shorthand or mnemonic code for the instrument.TL0
InstrumentTypestring?Type of financial instrument (e.g., CS, ETF, ETN).CS
Currencystring?Currency in which the instrument is traded.EUR

Example

publicasyncTaskRun(IXetraServicexetraService){varinstruments=awaitxetraService.GetInstrumentsAsync();foreach(varitemininstruments){Console.WriteLine($"Symbol: {item.Symbol}, Name: {item.InstrumentName}");}}

🤝 How to Contribute

We welcome contributions to Finance.NET! If you’d like to improve the project, please:

  1. Check out our contributing guidelines.
  2. Ideally, open an issue before starting work.
  3. Submit a pull request with your changes.

Thank you for helping make Finance.NET better!


ℹ️ Disclaimer

Finance.NET is an open-source project using publicly accessible APIs and scraping techniques. It is intended for educational and research purposes.

For legal usage, refer to the terms of each data provider:

For additional licensing and attribution details, see NOTICE.md.


🐞 Report a Bug

If you encounter any issues or bugs, please report them here.

About

A .NET library for retrieving real-time and historical financial data from Yahoo Finance and other popular sources.

Topics

Resources

Code of conduct

Contributing

Stars

22 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages