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)
Top Articles
Stephanie Ruhle Divorce: The Untold Story - This Week in Libraries
MSNBC's Stephanie Ruhle Was Diagnosed with Dyslexia Only 10 Years Ago After Childhood Comprehension Struggles
Funny Roblox Id Codes 2023
Golden Abyss - Chapter 5 - Lunar_Angel
Www.paystubportal.com/7-11 Login
Joi Databas
DPhil Research - List of thesis titles
Shs Games 1V1 Lol
Evil Dead Rise Showtimes Near Massena Movieplex
Steamy Afternoon With Handsome Fernando
Which aspects are important in sales |#1 Prospection
Detroit Lions 50 50
18443168434
Zürich Stadion Letzigrund detailed interactive seating plan with seat & row numbers | Sitzplan Saalplan with Sitzplatz & Reihen Nummerierung
Grace Caroline Deepfake
978-0137606801
Nwi Arrests Lake County
Justified Official Series Trailer
London Ups Store
Committees Of Correspondence | Encyclopedia.com
Pizza Hut In Dinuba
Jinx Chapter 24: Release Date, Spoilers & Where To Read - OtakuKart
How Much You Should Be Tipping For Beauty Services - American Beauty Institute
Free Online Games on CrazyGames | Play Now!
Sizewise Stat Login
Amih Stocktwits
Fort Mccoy Fire Map
Uta Kinesiology Advising
Kcwi Tv Schedule
What Time Does Walmart Auto Center Open
Nesb Routing Number
Olivia Maeday
Random Bibleizer
10 Best Places to Go and Things to Know for a Trip to the Hickory M...
Black Lion Backpack And Glider Voucher
Gopher Carts Pensacola Beach
Duke University Transcript Request
Lincoln Financial Field, section 110, row 4, home of Philadelphia Eagles, Temple Owls, page 1
Jambus - Definition, Beispiele, Merkmale, Wirkung
Netherforged Lavaproof Boots
Ark Unlock All Skins Command
Craigslist Red Wing Mn
D3 Boards
Jail View Sumter
Nancy Pazelt Obituary
Birmingham City Schools Clever Login
Thotsbook Com
Funkin' on the Heights
Vci Classified Paducah
Www Pig11 Net
Ty Glass Sentenced
Latest Posts
Article information

Author: Moshe Kshlerin

Last Updated:

Views: 6349

Rating: 4.7 / 5 (57 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Moshe Kshlerin

Birthday: 1994-01-25

Address: Suite 609 315 Lupita Unions, Ronnieburgh, MI 62697

Phone: +2424755286529

Job: District Education Designer

Hobby: Yoga, Gunsmithing, Singing, 3D printing, Nordic skating, Soapmaking, Juggling

Introduction: My name is Moshe Kshlerin, I am a gleaming, attractive, outstanding, pleasant, delightful, outstanding, famous person who loves writing and wants to share my knowledge and understanding with you.