Skip to main content

Yahoo! Finance market data downloader

=====================================

Ever since Yahoo! finance <https://finance.yahoo.com>_ decommissioned their historical data API, many programs that relied on it to stop working.

yfinance_ez aimes to solve this problem by offering a reliable and Pythonic way to download historical market data from Yahoo! finance.

Note from Ezra:

This library was originally created by Ran Aroussi and named yfinance. I encountered some bugs using it and wasn't able to reach him about updating his package, so I've renamed it for now to yfinance-ez so I can work on it. I've done some significant restructuring and added improved documentation, but the credit for much of the html parsing code is not mine. I've also pared down the package to focus just on the Ticker class and its functionality which I've gotten working.

Quick Start

The Ticker module

The Ticker module, which allows you to access ticker data in amore Pythonic way:

    import yfinance_ez as yf

    msft = yf.Ticker("MSFT")

    # get stock info
    msft.info

    # get historical market data for the last quarter
    # This method also accepts start and end dates and/or time intervals
    # so you can customize what you're looking for.
    hist = msft.get_history(period=yf.TimePeriods.Quarter)

    # show actions (dividends, splits) for the last retrieved historical period
    msft.actions

    # show dividends for the last retrieved historical period
    msft.dividends

    # show splits for the last retrieved historical period
    msft.splits

    # show financials
    msft.financials
    msft.quarterly_financials

    # show major holders
    msft.major_holders

    # show institutional holders
    msft.institutional_holders

    # show balance heet
    msft.balance_sheet
    msft.quarterly_balance_sheet

    # show cashflow
    msft.cashflow
    msft.quarterly_cashflow

    # show earnings
    msft.earnings
    msft.quarterly_earnings

    # show sustainability
    msft.sustainability

    # show analysts recommendations
    msft.recommendations

    # show next event (earnings, etc)
    msft.calendar

    # get option chain for specific expiration
    opt = msft.option_chain('YYYY-MM-DD')
    # data available via: opt.calls, opt.puts

If you want to use a proxy server for downloading data, use:

    import yfinance_ez as yf

    msft = yf.Ticker("MSFT", proxy="PROXY_SERVER")

If you want to get history data for multiple tickers using async, use:

    import yfinance_ez as yf

    async def get_history_multiple_tickers(ticker_symbols: List[str],
                                           **kwargs) -> List[yf.Ticker]:

    tickers = [yf.Ticker(ticker_symbol) for ticker_symbol in ticker_symbols]

    await asyncio.gather(
        *[ticker.get_history_async(**kwargs) for ticker in tickers])

    return tickers

Installation

Install yfinance_ez using pip:

    $ pip install yfinance_ez

Requirements

  • Python <https://www.python.org>_ >= 3.5+
  • Pandas <https://github.com/pydata/pandas>_ (tested to work with >=0.23.1)
  • Numpy <http://www.numpy.org>_ >= 1.11.1
  • requests <http://docs.python-requests.org/en/master/>_ >= 2.14.2

Legal Stuff

yfinance_ez is distributed under the Apache Software License. See the LICENSE.txt <./LICENSE.txt>_ file in the release for details.

P.S.

Please drop me an note with any feedback you have.

Ezra Schiff

Release files for yfinance-ez 0.5.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yfinance-ez 0.5.6
File Size Uploaded
yfinance_ez-0.5.6.tar.gz 26.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for yfinance-ez 0.5.6
File Interpreter ABI Platform
yfinance_ez-0.5.6-py3-none-any.whl Python 3 none any Details

Total release size: 53.2 kB

Release files / yfinance_ez-0.5.6.tar.gz

Download URL yfinance_ez-0.5.6.tar.gz
Size 26.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d393dc7e04291c4d642c0f7fce0b3d8f90e14c324df33c3ba99da50ff64b22ea
BLAKE2b-256 checksum
How to use checksums
dc1438f623b94509ebd32a911d5da8dcdfcd2d4e6cfd968c27988f2539722bc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.0 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.0

Release files / yfinance_ez-0.5.6-py3-none-any.whl

Download URL yfinance_ez-0.5.6-py3-none-any.whl
Size 26.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f05e7281fc9765e48c6843bba714af977e343b60cfe7c86ed9257bcc2837e89
BLAKE2b-256 checksum
How to use checksums
e5670b7f3633afc220e2d7f618fa98adb5ee5ce7d014ffb9af413efa9e4f6a52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.0 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.0

Release history Release notifications | RSS feed

This release

0.5.6 This release

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

3 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page