API Documentation — yahoofinance documentation (2024)

Please note that the API is currently under development and things maychange rapidly!

Core Interface

class yahoofinance.interfaces.IYahooData(locale)[source]

This is the base interface.

Each class in this library inherits implements this interface.

This class is NOT instantiable.

Parameters:locale – a yahoofinance.Locale constant to determine which domain to query from.
to_csv()[source]

Generates a CSV file.

to_dfs()[source]

Generates a dictionary containing pandas.DataFrame.

Historical Data

class yahoofinance.HistoricalPrices(instrument, start_date, end_date, date_format_string='%Y-%m-%d', event='history', frequency='1d', locale='')[source]

Retrieves historical data from Yahoo Finance.

Parameters:
  • instrument – The a stock instrument code to query.
  • start_date – The start date for the query (inclusive).
  • end_date – The end date for the query (inclusive).
  • date_format_string – If start_date or end_date is not a DateTime object,the object passed in (string) will be parsed to the format string. Default: %Y-%m-%d.
  • event – A DataEvent constant to determine what event to query for. Default: DataEvent.HISTORICAL_PRICES.
  • frequency – A DataFrequency constant to determine the interval between records. Default: DataFrequency.DAILY.
  • locale – A Locale constant to determine which domain to query from. Default: Locale.US.
Returns:

HistoricalPrices object

Return type:

HistoricalPrices

E.g. https://finance.yahoo.com/quote/AAPL/history

Usage:

>>> from yahoofinance import HistoricalPrices>>> req = HistoricalPrices('AAPL')Object<HistoricalPrices>
to_csv(path=None, sep=', ', data_format='raw', csv_dialect='excel')[source]

Generates a CSV file.

Parameters:
  • path – The path to a file location. If it is None, this method returns theCSV as a string.
  • sep – The separator between elements in the new line. NOT USED
  • data_format – A DataFormat constant to determine how the data isexported. NOT USED
  • csv_dialect – The dialect to write the CSV file. See Python in-built csv.
Returns:

None or string

Return type:

None or string

to_dfs(data_format='raw')[source]

Generates a dictionary containing pandas.DataFrame.

Parameters:data_format – A DataFormat constant to determine how the data is exported.NOT USED
Returns:pandas.DataFrame
Return type:pandas.DataFrame

Dictionary keys

Historical Prices

Note: All of the below classes below are experimental and results mayvary significantly as they data is scraped from the website.Use at your own risk!

Balance Sheet

class yahoofinance.BalanceSheet(stock, locale='')[source]

Retrieves annual balance sheet information from Yahoo Finance.

EXPERIMENTAL

Parameters:
  • stock – The a stock code to query.
  • locale – A Locale constant to determine which domain to query from. Default: Locale.US.
Returns:

BalanceSheet object

Return type:

BalanceSheet

E.g. https://finance.yahoo.com/quote/AAPL/balance-sheet

Usage:

>>> from yahoofinance import BalanceSheet>>> req = BalanceSheet('AAPL')Object<BalanceSheet>
to_csv(path=None, sep=', ', data_format='raw', csv_dialect='excel')[source]

Generates a CSV file.

Parameters:
  • path – The path to a file location. If it is None, this method returns theCSV as a string.
  • sep – The separator between elements in the new line.
  • data_format – A DataFormat constant to determine how the data isexported.
  • csv_dialect – The dialect to write the CSV file. See Python in-built csv.
Returns:

None or string

Return type:

None or string

to_dfs(data_format='raw')[source]

Generates a dictionary containing pandas.DataFrame.

Parameters:data_format – A DataFormat constant to determine how the data is exported.
Returns:pandas.DataFrame
Return type:pandas.DataFrame

Dictionary keys

Cash FlowOverallOperating activitiesInvestment activitiesFinancing activitiesChanges in Cash
class yahoofinance.BalanceSheetQuarterly(stock, locale='')[source]

Retrieves quarterly balance sheet information from Yahoo Finance.

EXPERIMENTAL

Parameters:
  • stock – The a stock code to query.
  • locale – A Locale constant to determine which domain to query from. Default: Locale.US.
Returns:

BalanceSheetQuarterly object

Return type:

BalanceSheetQuarterly

E.g. https://finance.yahoo.com/quote/AAPL/balance-sheet

Usage:

>>> from yahoofinance import BalanceSheetQuarterly>>> req = BalanceSheetQuarterly('AAPL')Object<BalanceSheetQuarterly>

Cash Flow

class yahoofinance.CashFlow(stock, locale='')[source]

Retrieves annual cash flow information from Yahoo Finance.

EXPERIMENTAL

Parameters:
  • stock – The a stock code to query.
  • locale – A Locale constant to determine which domain to query from. Default: Locale.US.
Returns:

CashFlow object

Return type:

CashFlow

E.g. https://finance.yahoo.com/quote/AAPL/cash-flow

Usage:

>>> from yahoofinance import CashFlow>>> req = CashFlow('AAPL')Object<CashFlow>
to_csv(path=None, sep=', ', data_format='raw', csv_dialect='excel')[source]

Generates a CSV file.

Parameters:
  • path – The path to a file location. If it is None, this method returns theCSV as a string.
  • sep – The separator between elements in the new line.
  • data_format – A DataFormat constant to determine how the data isexported.
  • csv_dialect – The dialect to write the CSV file. See Python in-built csv.
Returns:

None or string

Return type:

None or string

to_dfs(data_format='raw')[source]

Generates a dictionary containing pandas.DataFrame.

Parameters:data_format – A DataFormat constant to determine how the data is exported.
Returns:pandas.DataFrame
Return type:pandas.DataFrame

Dictionary keys

Cash FlowOverallOperating activitiesInvestment activitiesFinancing activitiesChanges in Cash
class yahoofinance.CashFlowQuarterly(stock, locale='')[source]

Retrieves quarterly cash flow information from Yahoo Finance.

EXPERIMENTAL

Parameters:
  • stock – The a stock code to query.
  • locale – A Locale constant to determine which domain to query from. Default: Locale.US.
Returns:

CashFlowQuarterly object

Return type:

CashFlowQuarterly

E.g. https://finance.yahoo.com/quote/AAPL/cash-flow

Usage:

>>> from yahoofinance import CashFlowQuarterly>>> req = CashFlowQuarterly('AAPL')Object<CashFlowQuarterly>

Income Statement

class yahoofinance.IncomeStatement(stock, locale='')[source]

Retrieves annual balance sheet information from Yahoo Finance.

EXPERIMENTAL

Parameters:
  • stock – The a stock code to query.
  • locale – A Locale constant to determine which domain to query from. Default: Locale.US.
Returns:

IncomeStatement object

Return type:

IncomeStatement

E.g. https://finance.yahoo.com/quote/AAPL/financials

Usage:

>>> from yahoofinance import IncomeStatement>>> req = IncomeStatement('AAPL')Object<IncomeStatement>
to_csv(path=None, sep=', ', data_format='raw', csv_dialect='excel')[source]

Generates a CSV file.

Parameters:
  • path – The path to a file location. If it is None, this method returns theCSV as a string.
  • sep – The separator between elements in the new line.
  • data_format – A DataFormat constant to determine how the data isexported.
  • csv_dialect – The dialect to write the CSV file. See Python in-built csv.
Returns:

None or string

Return type:

None or string

to_dfs(data_format='raw')[source]

Generates a dictionary containing pandas.DataFrame.

Parameters:data_format – A DataFormat constant to determine how the data is exported.
Returns:pandas.DataFrame
Return type:pandas.DataFrame

Dictionary keys

Cash FlowOverallOperating activitiesInvestment activitiesFinancing activitiesChanges in Cash
class yahoofinance.IncomeStatementQuarterly(stock, locale='')[source]

Retrieves quarterly balance sheet information from Yahoo Finance.

EXPERIMENTAL

Parameters:
  • stock – The a stock code to query.
  • locale – A Locale constant to determine which domain to query from. Default: Locale.US.
Returns:

IncomeStatementQuarterly object

Return type:

IncomeStatementQuarterly

E.g. https://finance.yahoo.com/quote/AAPL/financials

Usage:

>>> from yahoofinance import IncomeStatementQuarterly>>> req = IncomeStatementQuarterly('AAPL')Object<IncomeStatementQuarterly>

Asset Profile

class yahoofinance.AssetProfile(stock, locale='')[source]

Retrieves the asset profile from Yahoo Finance.

EXPERIMENTAL

Parameters:
  • stock – The stock ticker
  • locale – A Local constant to determine which domain to query from. Default: Locale.US.
Returns:

AssetProfile object

Return type:

AssetProfile

E.g. https://finance.yahoo.com/quote/AAPL/profile

Usage:

>>> from yahoofinance import AssetProfile>>> req = AssetProfile('AAPL')Object<AssetProfile>
to_csv(path, sep=', ', data_format='raw', csv_dialect='excel')[source]

Generates a CSV file.

Parameters:
  • path – The path to a file location. If it is None, this method returns theCSV as a string.
  • sep – The separator between elements in the new line. NOT USED
  • data_format – A DataFormat constant to determine how the data isexported. NOT USED
  • csv_dialect – The dialect to write the CSV file. See Python in-built csv.
Returns:

None or string

Return type:

None or string

to_dfs(data_format='raw')[source]

Generates a dictionary containing pandas.DataFrame.

Additional Config

class yahoofinance.Locale[source]

Provides locale information to any IYahooData implementations.

By using your local domain, it may speed up queries by a miniscule amount or bypass
certain country domain filters and restrictions.
AU = 'au'

Uses the Australian domain. E.g. https://au.finance.yahoo.com/quote/AAPL/

CA = 'ca'

Uses the Canadian domain. E.g. https://ca.finance.yahoo.com/quote/AAPL/

US = ''

Uses the United States domain. E.g. https://finance.yahoo.com/quote/AAPL/

static locale_url(locale)[source]

This is an auxilary method to determine the domain url for a locale.

Parameters:locale – A Locale string constant. A hard coded string can also be usedif the 2 letter domain is known.
Returns:string object
Return type:string
class yahoofinance.DataEvent[source]

Provides data event information for HistoricalData.

Yahoo provides 3 different types of historical data sets.

class yahoofinance.DataFrequency[source]

Provides data frequency information for HistoricalData.

Yahoo provides data at 3 different time granuarities.

DAILY = '1d'

Retrieve data at daily intervals.

MONTHLY = '1mo'

Retrieve data at montly intervals.

WEEKLY = '1wk'

Retrieve data at weekly intervals.

class yahoofinance.DataFormat[source]

Selects the way data is formatted for IYahooData implementations.

LONG = 'longFmt'

Provides a longer formatted value. E.g. 1,000,000.0

RAW = 'raw'

Provides a raw numerical value. E.g. 1000000.0

SHORT = 'fmt'

Provides a shorter formatted value. E.g. 1.0M

API Documentation — yahoofinance  documentation (2024)

References

Top Articles
J. G. Ballard - Literature
Chicken Broccoli Ring Recipe
Santa Clara College Confidential
Lexington Herald-Leader from Lexington, Kentucky
Beautiful Scrap Wood Paper Towel Holder
Legacy First National Bank
Slay The Spire Red Mask
You can put a price tag on the value of a personal finance education: $100,000
Hello Alice Business Credit Card Limit Hard Pull
Tamilblasters 2023
Select Truck Greensboro
fltimes.com | Finger Lakes Times
Aces Fmc Charting
OpenXR support for IL-2 and DCS for Windows Mixed Reality VR headsets
Craigslist Pets Longview Tx
2015 Honda Fit EX-L for sale - Seattle, WA - craigslist
Michael Shaara Books In Order - Books In Order
Straight Talk Phones With 7 Inch Screen
Boston Gang Map
Bridge.trihealth
Blue Rain Lubbock
Adt Residential Sales Representative Salary
Sea To Dallas Google Flights
Imouto Wa Gal Kawaii - Episode 2
Craigslist Dubuque Iowa Pets
Snohomish Hairmasters
Paris Immobilier - craigslist
Maisons près d'une ville - Štanga - Location de vacances à proximité d'une ville - Štanga | Résultats 201
Primerica Shareholder Account
Issue Monday, September 23, 2024
Dubois County Barter Page
Devargasfuneral
R3Vlimited Forum
Supermarkt Amsterdam - Openingstijden, Folder met alle Aanbiedingen
The Best Carry-On Suitcases 2024, Tested and Reviewed by Travel Editors | SmarterTravel
Skip The Games Ventura
Ticketmaster Lion King Chicago
The Vélodrome d'Hiver (Vél d'Hiv) Roundup
Oriellys Tooele
Nsav Investorshub
M Life Insider
Wal-Mart 140 Supercenter Products
Florida Lottery Claim Appointment
Citroen | Skąd pobrać program do lexia diagbox?
Shell Gas Stations Prices
Silicone Spray Advance Auto
Beds From Rent-A-Center
Dying Light Mother's Day Roof
Missed Connections Dayton Ohio
Craigslist Anc Ak
Minute Clinic Mooresville Nc
Códigos SWIFT/BIC para bancos de USA
Latest Posts
Article information

Author: Patricia Veum II

Last Updated:

Views: 6150

Rating: 4.3 / 5 (44 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Patricia Veum II

Birthday: 1994-12-16

Address: 2064 Little Summit, Goldieton, MS 97651-0862

Phone: +6873952696715

Job: Principal Officer

Hobby: Rafting, Cabaret, Candle making, Jigsaw puzzles, Inline skating, Magic, Graffiti

Introduction: My name is Patricia Veum II, I am a vast, combative, smiling, famous, inexpensive, zealous, sparkling person who loves writing and wants to share my knowledge and understanding with you.