yfinance


Nameyfinance JSON
Version 0.2.48 PyPI version JSON
download
home_pagehttps://github.com/ranaroussi/yfinance
SummaryDownload market data from Yahoo! Finance API
upload_time2024-10-25 18:03:15
maintainerNone
docs_urlNone
authorRan Aroussi
requires_pythonNone
licenseApache
keywords pandas yahoo finance pandas datareader
VCS
bugtrack_url
requirements pandas numpy requests multitasking lxml platformdirs pytz frozendict beautifulsoup4 html5lib peewee
Travis-CI
coveralls test coverage No coveralls.
            # Download market data from Yahoo! Finance's API

<table border=1 cellpadding=10><tr><td>

#### \*\*\* IMPORTANT LEGAL DISCLAIMER \*\*\*

---

**Yahoo!, Y!Finance, and Yahoo! finance are registered trademarks of
Yahoo, Inc.**

yfinance is **not** affiliated, endorsed, or vetted by Yahoo, Inc. It's
an open-source tool that uses Yahoo's publicly available APIs, and is
intended for research and educational purposes.

**You should refer to Yahoo!'s terms of use**
([here](https://policies.yahoo.com/us/en/yahoo/terms/product-atos/apiforydn/index.htm),
[here](https://legal.yahoo.com/us/en/yahoo/terms/otos/index.html), and
[here](https://policies.yahoo.com/us/en/yahoo/terms/index.htm)) **for
details on your rights to use the actual data downloaded. Remember - the
Yahoo! finance API is intended for personal use only.**

</td></tr></table>

---

<a target="new" href="https://pypi.python.org/pypi/yfinance"><img border=0 src="https://img.shields.io/badge/python-2.7,%203.6+-blue.svg?style=flat" alt="Python version"></a>
<a target="new" href="https://pypi.python.org/pypi/yfinance"><img border=0 src="https://img.shields.io/pypi/v/yfinance.svg?maxAge=60%" alt="PyPi version"></a>
<a target="new" href="https://pypi.python.org/pypi/yfinance"><img border=0 src="https://img.shields.io/pypi/status/yfinance.svg?maxAge=60" alt="PyPi status"></a>
<a target="new" href="https://pypi.python.org/pypi/yfinance"><img border=0 src="https://img.shields.io/pypi/dm/yfinance.svg?maxAge=2592000&label=installs&color=%2327B1FF" alt="PyPi downloads"></a>
<a target="new" href="https://www.codefactor.io/repository/github/ranaroussi/yfinance"><img border=0 src="https://www.codefactor.io/repository/github/ranaroussi/yfinance/badge" alt="CodeFactor"></a>
<a target="new" href="https://github.com/ranaroussi/yfinance"><img border=0 src="https://img.shields.io/github/stars/ranaroussi/yfinance.svg?style=social&label=Star&maxAge=60" alt="Star this repo"></a>
<a target="new" href="https://twitter.com/aroussi"><img border=0 src="https://img.shields.io/twitter/follow/aroussi.svg?style=social&label=Follow&maxAge=60" alt="Follow me on twitter"></a>


**yfinance** offers a threaded and Pythonic way to download market data from [Yahoo!Ⓡ finance](https://finance.yahoo.com).

→ Check out this [Blog post](https://aroussi.com/#post/python-yahoo-finance) for a detailed tutorial with code examples.

[Changelog »](https://github.com/ranaroussi/yfinance/blob/main/CHANGELOG.rst)

---

- [Installation](#installation)
- [Quick start](#quick-start)
- [Advanced](#logging)
- [Wiki](https://github.com/ranaroussi/yfinance/wiki)
- [Contribute](#developers-want-to-contribute)

---

## Installation

Install `yfinance` using `pip`:

``` {.sourceCode .bash}
$ pip install yfinance --upgrade --no-cache-dir
```

[With Conda](https://anaconda.org/ranaroussi/yfinance).

To install with optional dependencies, replace `optional` with: `nospam` for [caching-requests](#smarter-scraping), `repair` for [price repair](https://github.com/ranaroussi/yfinance/wiki/Price-repair), or `nospam,repair` for both:

``` {.sourceCode .bash}
$ pip install "yfinance[optional]"
```

[Required dependencies](./requirements.txt) , [all dependencies](./setup.py#L62).

---

## Quick Start

### The Ticker module

The `Ticker` module, which allows you to access ticker data in a more Pythonic way:

```python
import yfinance as yf

msft = yf.Ticker("MSFT")

# get all stock info
msft.info

# get historical market data
hist = msft.history(period="1mo")

# show meta information about the history (requires history() to be called first)
msft.history_metadata

# show actions (dividends, splits, capital gains)
msft.actions
msft.dividends
msft.splits
msft.capital_gains  # only for mutual funds & etfs

# show share count
msft.get_shares_full(start="2022-01-01", end=None)

# show financials:
msft.calendar
msft.sec_filings
# - income statement
msft.income_stmt
msft.quarterly_income_stmt
# - balance sheet
msft.balance_sheet
msft.quarterly_balance_sheet
# - cash flow statement
msft.cashflow
msft.quarterly_cashflow
# see `Ticker.get_income_stmt()` for more options

# show holders
msft.major_holders
msft.institutional_holders
msft.mutualfund_holders
msft.insider_transactions
msft.insider_purchases
msft.insider_roster_holders

msft.sustainability

# show recommendations
msft.recommendations
msft.recommendations_summary
msft.upgrades_downgrades

# show analysts data
msft.analyst_price_targets
msft.earnings_estimate
msft.revenue_estimate
msft.earnings_history
msft.eps_trend
msft.eps_revisions
msft.growth_estimates

# Show future and historic earnings dates, returns at most next 4 quarters and last 8 quarters by default.
# Note: If more are needed use msft.get_earnings_dates(limit=XX) with increased limit argument.
msft.earnings_dates

# show ISIN code - *experimental*
# ISIN = International Securities Identification Number
msft.isin

# show options expirations
msft.options

# show news
msft.news

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

For tickers that are ETFs/Mutual Funds, `Ticker.funds_data` provides access to fund related data. 

Funds' Top Holdings and other data with category average is returned as `pd.DataFrame`.

```python
import yfinance as yf
spy = yf.Ticker('SPY')
data = spy.funds_data

# show fund description
data.description

# show operational information
data.fund_overview
data.fund_operations

# show holdings related information
data.asset_classes
data.top_holdings
data.equity_holdings
data.bond_holdings
data.bond_ratings
data.sector_weightings
```

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

```python
import yfinance as yf

msft = yf.Ticker("MSFT")

msft.history(..., proxy="PROXY_SERVER")
msft.get_actions(proxy="PROXY_SERVER")
msft.get_dividends(proxy="PROXY_SERVER")
msft.get_splits(proxy="PROXY_SERVER")
msft.get_capital_gains(proxy="PROXY_SERVER")
msft.get_balance_sheet(proxy="PROXY_SERVER")
msft.get_cashflow(proxy="PROXY_SERVER")
msft.option_chain(..., proxy="PROXY_SERVER")
...
```

### Multiple tickers

To initialize multiple `Ticker` objects, use

```python
import yfinance as yf

tickers = yf.Tickers('msft aapl goog')

# access each ticker using (example)
tickers.tickers['MSFT'].info
tickers.tickers['AAPL'].history(period="1mo")
tickers.tickers['GOOG'].actions
```

To download price history into one table:

```python
import yfinance as yf
data = yf.download("SPY AAPL", period="1mo")
```

#### `yf.download()` and `Ticker.history()` have many options for configuring fetching and processing. [Review the Wiki](https://github.com/ranaroussi/yfinance/wiki) for more options and detail.

### Sector and Industry

The `Sector` and `Industry` modules allow you to access the US market information.

To initialize, use the relevant sector or industry key as below. (Complete mapping of the keys is available in `const.py`.)

```python
import yfinance as yf

tech = yf.Sector('technology')
software = yf.Industry('software-infrastructure')

# Common information
tech.key
tech.name
tech.symbol
tech.ticker
tech.overview
tech.top_companies
tech.research_reports

# Sector information
tech.top_etfs
tech.top_mutual_funds
tech.industries

# Industry information
software.sector_key
software.sector_name
software.top_performing_companies
software.top_growth_companies
```

The modules can be chained with Ticker as below.
```python
import yfinance as yf

# Ticker to Sector and Industry
msft = yf.Ticker('MSFT')
tech = yf.Sector(msft.info.get('sectorKey'))
software = yf.Industry(msft.info.get('industryKey'))

# Sector and Industry to Ticker
tech_ticker = tech.ticker
tech_ticker.info
software_ticker = software.ticker
software_ticker.history()
```

### Market Screener
The `Screener` module allows you to screen the market based on specified queries.

#### Query Construction
To create a query, you can use the `EquityQuery` class to construct your filters step by step. The queries support operators: `GT` (greater than), `LT` (less than), `BTWN` (between), `EQ` (equals), and logical operators `AND` and `OR` for combining multiple conditions.

#### Screener
The `Screener` class is used to execute the queries and return the filtered results. You can set a custom body for the screener or use predefined configurations.

<!-- TODO: link to Github Pages for more including list of predefined bodies, supported fields, operands, and sample code -->

### Logging

`yfinance` now uses the `logging` module to handle messages, default behaviour is only print errors. If debugging, use `yf.enable_debug_mode()` to switch logging to debug with custom formatting.

### Smarter scraping

Install the `nospam` packages for smarter scraping using `pip` (see [Installation](#installation)). These packages help cache calls such that Yahoo is not spammed with requests.

To use a custom `requests` session, pass a `session=` argument to
the Ticker constructor. This allows for caching calls to the API as well as a custom way to modify requests via  the `User-agent` header.

```python
import requests_cache
session = requests_cache.CachedSession('yfinance.cache')
session.headers['User-agent'] = 'my-program/1.0'
ticker = yf.Ticker('msft', session=session)
# The scraped response will be stored in the cache
ticker.actions
```

Combine `requests_cache` with rate-limiting to avoid triggering Yahoo's rate-limiter/blocker that can corrupt data.
```python
from requests import Session
from requests_cache import CacheMixin, SQLiteCache
from requests_ratelimiter import LimiterMixin, MemoryQueueBucket
from pyrate_limiter import Duration, RequestRate, Limiter
class CachedLimiterSession(CacheMixin, LimiterMixin, Session):
    pass

session = CachedLimiterSession(
    limiter=Limiter(RequestRate(2, Duration.SECOND*5)),  # max 2 requests per 5 seconds
    bucket_class=MemoryQueueBucket,
    backend=SQLiteCache("yfinance.cache"),
)
```

### Managing Multi-Level Columns

The following answer on Stack Overflow is for [How to deal with
multi-level column names downloaded with
yfinance?](https://stackoverflow.com/questions/63107801)

-   `yfinance` returns a `pandas.DataFrame` with multi-level column
    names, with a level for the ticker and a level for the stock price
    data
    -   The answer discusses:
        -   How to correctly read the the multi-level columns after
            saving the dataframe to a csv with `pandas.DataFrame.to_csv`
        -   How to download single or multiple tickers into a single
            dataframe with single level column names and a ticker column

### Persistent cache store

To reduce Yahoo, yfinance store some data locally: timezones to localize dates, and cookie. Cache location is:

- Windows = C:/Users/\<USER\>/AppData/Local/py-yfinance
- Linux = /home/\<USER\>/.cache/py-yfinance
- MacOS = /Users/\<USER\>/Library/Caches/py-yfinance

You can direct cache to use a different location with `set_tz_cache_location()`:

```python
import yfinance as yf
yf.set_tz_cache_location("custom/cache/location")
...
```

---

## Developers: want to contribute?

`yfinance` relies on community to investigate bugs and contribute code. Developer guide: https://github.com/ranaroussi/yfinance/discussions/1084

---

### Legal Stuff

**yfinance** is distributed under the **Apache Software License**. See
the [LICENSE.txt](./LICENSE.txt) file in the release for details.


AGAIN - yfinance is **not** affiliated, endorsed, or vetted by Yahoo, Inc. It's
an open-source tool that uses Yahoo's publicly available APIs, and is
intended for research and educational purposes. You should refer to Yahoo!'s terms of use
([here](https://policies.yahoo.com/us/en/yahoo/terms/product-atos/apiforydn/index.htm),
[here](https://legal.yahoo.com/us/en/yahoo/terms/otos/index.html), and
[here](https://policies.yahoo.com/us/en/yahoo/terms/index.htm)) for
details on your rights to use the actual data downloaded.

---

### P.S.

Please drop me a note with any feedback you have.

**Ran Aroussi**

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ranaroussi/yfinance",
    "name": "yfinance",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "pandas, yahoo finance, pandas datareader",
    "author": "Ran Aroussi",
    "author_email": "ran@aroussi.com",
    "download_url": "https://files.pythonhosted.org/packages/2b/d3/164c641a2087b5cc1a065e3380fc7912d16d9423f7eba4398519d83f0acb/yfinance-0.2.48.tar.gz",
    "platform": "any",
    "description": "# Download market data from Yahoo! Finance's API\n\n<table border=1 cellpadding=10><tr><td>\n\n#### \\*\\*\\* IMPORTANT LEGAL DISCLAIMER \\*\\*\\*\n\n---\n\n**Yahoo!, Y!Finance, and Yahoo! finance are registered trademarks of\nYahoo, Inc.**\n\nyfinance is **not** affiliated, endorsed, or vetted by Yahoo, Inc. It's\nan open-source tool that uses Yahoo's publicly available APIs, and is\nintended for research and educational purposes.\n\n**You should refer to Yahoo!'s terms of use**\n([here](https://policies.yahoo.com/us/en/yahoo/terms/product-atos/apiforydn/index.htm),\n[here](https://legal.yahoo.com/us/en/yahoo/terms/otos/index.html), and\n[here](https://policies.yahoo.com/us/en/yahoo/terms/index.htm)) **for\ndetails on your rights to use the actual data downloaded. Remember - the\nYahoo! finance API is intended for personal use only.**\n\n</td></tr></table>\n\n---\n\n<a target=\"new\" href=\"https://pypi.python.org/pypi/yfinance\"><img border=0 src=\"https://img.shields.io/badge/python-2.7,%203.6+-blue.svg?style=flat\" alt=\"Python version\"></a>\n<a target=\"new\" href=\"https://pypi.python.org/pypi/yfinance\"><img border=0 src=\"https://img.shields.io/pypi/v/yfinance.svg?maxAge=60%\" alt=\"PyPi version\"></a>\n<a target=\"new\" href=\"https://pypi.python.org/pypi/yfinance\"><img border=0 src=\"https://img.shields.io/pypi/status/yfinance.svg?maxAge=60\" alt=\"PyPi status\"></a>\n<a target=\"new\" href=\"https://pypi.python.org/pypi/yfinance\"><img border=0 src=\"https://img.shields.io/pypi/dm/yfinance.svg?maxAge=2592000&label=installs&color=%2327B1FF\" alt=\"PyPi downloads\"></a>\n<a target=\"new\" href=\"https://www.codefactor.io/repository/github/ranaroussi/yfinance\"><img border=0 src=\"https://www.codefactor.io/repository/github/ranaroussi/yfinance/badge\" alt=\"CodeFactor\"></a>\n<a target=\"new\" href=\"https://github.com/ranaroussi/yfinance\"><img border=0 src=\"https://img.shields.io/github/stars/ranaroussi/yfinance.svg?style=social&label=Star&maxAge=60\" alt=\"Star this repo\"></a>\n<a target=\"new\" href=\"https://twitter.com/aroussi\"><img border=0 src=\"https://img.shields.io/twitter/follow/aroussi.svg?style=social&label=Follow&maxAge=60\" alt=\"Follow me on twitter\"></a>\n\n\n**yfinance** offers a threaded and Pythonic way to download market data from [Yahoo!\u24c7 finance](https://finance.yahoo.com).\n\n\u2192 Check out this [Blog post](https://aroussi.com/#post/python-yahoo-finance) for a detailed tutorial with code examples.\n\n[Changelog \u00bb](https://github.com/ranaroussi/yfinance/blob/main/CHANGELOG.rst)\n\n---\n\n- [Installation](#installation)\n- [Quick start](#quick-start)\n- [Advanced](#logging)\n- [Wiki](https://github.com/ranaroussi/yfinance/wiki)\n- [Contribute](#developers-want-to-contribute)\n\n---\n\n## Installation\n\nInstall `yfinance` using `pip`:\n\n``` {.sourceCode .bash}\n$ pip install yfinance --upgrade --no-cache-dir\n```\n\n[With Conda](https://anaconda.org/ranaroussi/yfinance).\n\nTo install with optional dependencies, replace `optional` with: `nospam` for [caching-requests](#smarter-scraping), `repair` for [price repair](https://github.com/ranaroussi/yfinance/wiki/Price-repair), or `nospam,repair` for both:\n\n``` {.sourceCode .bash}\n$ pip install \"yfinance[optional]\"\n```\n\n[Required dependencies](./requirements.txt) , [all dependencies](./setup.py#L62).\n\n---\n\n## Quick Start\n\n### The Ticker module\n\nThe `Ticker` module, which allows you to access ticker data in a more Pythonic way:\n\n```python\nimport yfinance as yf\n\nmsft = yf.Ticker(\"MSFT\")\n\n# get all stock info\nmsft.info\n\n# get historical market data\nhist = msft.history(period=\"1mo\")\n\n# show meta information about the history (requires history() to be called first)\nmsft.history_metadata\n\n# show actions (dividends, splits, capital gains)\nmsft.actions\nmsft.dividends\nmsft.splits\nmsft.capital_gains  # only for mutual funds & etfs\n\n# show share count\nmsft.get_shares_full(start=\"2022-01-01\", end=None)\n\n# show financials:\nmsft.calendar\nmsft.sec_filings\n# - income statement\nmsft.income_stmt\nmsft.quarterly_income_stmt\n# - balance sheet\nmsft.balance_sheet\nmsft.quarterly_balance_sheet\n# - cash flow statement\nmsft.cashflow\nmsft.quarterly_cashflow\n# see `Ticker.get_income_stmt()` for more options\n\n# show holders\nmsft.major_holders\nmsft.institutional_holders\nmsft.mutualfund_holders\nmsft.insider_transactions\nmsft.insider_purchases\nmsft.insider_roster_holders\n\nmsft.sustainability\n\n# show recommendations\nmsft.recommendations\nmsft.recommendations_summary\nmsft.upgrades_downgrades\n\n# show analysts data\nmsft.analyst_price_targets\nmsft.earnings_estimate\nmsft.revenue_estimate\nmsft.earnings_history\nmsft.eps_trend\nmsft.eps_revisions\nmsft.growth_estimates\n\n# Show future and historic earnings dates, returns at most next 4 quarters and last 8 quarters by default.\n# Note: If more are needed use msft.get_earnings_dates(limit=XX) with increased limit argument.\nmsft.earnings_dates\n\n# show ISIN code - *experimental*\n# ISIN = International Securities Identification Number\nmsft.isin\n\n# show options expirations\nmsft.options\n\n# show news\nmsft.news\n\n# get option chain for specific expiration\nopt = msft.option_chain('YYYY-MM-DD')\n# data available via: opt.calls, opt.puts\n```\n\nFor tickers that are ETFs/Mutual Funds, `Ticker.funds_data` provides access to fund related data. \n\nFunds' Top Holdings and other data with category average is returned as `pd.DataFrame`.\n\n```python\nimport yfinance as yf\nspy = yf.Ticker('SPY')\ndata = spy.funds_data\n\n# show fund description\ndata.description\n\n# show operational information\ndata.fund_overview\ndata.fund_operations\n\n# show holdings related information\ndata.asset_classes\ndata.top_holdings\ndata.equity_holdings\ndata.bond_holdings\ndata.bond_ratings\ndata.sector_weightings\n```\n\nIf you want to use a proxy server for downloading data, use:\n\n```python\nimport yfinance as yf\n\nmsft = yf.Ticker(\"MSFT\")\n\nmsft.history(..., proxy=\"PROXY_SERVER\")\nmsft.get_actions(proxy=\"PROXY_SERVER\")\nmsft.get_dividends(proxy=\"PROXY_SERVER\")\nmsft.get_splits(proxy=\"PROXY_SERVER\")\nmsft.get_capital_gains(proxy=\"PROXY_SERVER\")\nmsft.get_balance_sheet(proxy=\"PROXY_SERVER\")\nmsft.get_cashflow(proxy=\"PROXY_SERVER\")\nmsft.option_chain(..., proxy=\"PROXY_SERVER\")\n...\n```\n\n### Multiple tickers\n\nTo initialize multiple `Ticker` objects, use\n\n```python\nimport yfinance as yf\n\ntickers = yf.Tickers('msft aapl goog')\n\n# access each ticker using (example)\ntickers.tickers['MSFT'].info\ntickers.tickers['AAPL'].history(period=\"1mo\")\ntickers.tickers['GOOG'].actions\n```\n\nTo download price history into one table:\n\n```python\nimport yfinance as yf\ndata = yf.download(\"SPY AAPL\", period=\"1mo\")\n```\n\n#### `yf.download()` and `Ticker.history()` have many options for configuring fetching and processing. [Review the Wiki](https://github.com/ranaroussi/yfinance/wiki) for more options and detail.\n\n### Sector and Industry\n\nThe `Sector` and `Industry` modules allow you to access the US market information.\n\nTo initialize, use the relevant sector or industry key as below. (Complete mapping of the keys is available in `const.py`.)\n\n```python\nimport yfinance as yf\n\ntech = yf.Sector('technology')\nsoftware = yf.Industry('software-infrastructure')\n\n# Common information\ntech.key\ntech.name\ntech.symbol\ntech.ticker\ntech.overview\ntech.top_companies\ntech.research_reports\n\n# Sector information\ntech.top_etfs\ntech.top_mutual_funds\ntech.industries\n\n# Industry information\nsoftware.sector_key\nsoftware.sector_name\nsoftware.top_performing_companies\nsoftware.top_growth_companies\n```\n\nThe modules can be chained with Ticker as below.\n```python\nimport yfinance as yf\n\n# Ticker to Sector and Industry\nmsft = yf.Ticker('MSFT')\ntech = yf.Sector(msft.info.get('sectorKey'))\nsoftware = yf.Industry(msft.info.get('industryKey'))\n\n# Sector and Industry to Ticker\ntech_ticker = tech.ticker\ntech_ticker.info\nsoftware_ticker = software.ticker\nsoftware_ticker.history()\n```\n\n### Market Screener\nThe `Screener` module allows you to screen the market based on specified queries.\n\n#### Query Construction\nTo create a query, you can use the `EquityQuery` class to construct your filters step by step. The queries support operators: `GT` (greater than), `LT` (less than), `BTWN` (between), `EQ` (equals), and logical operators `AND` and `OR` for combining multiple conditions.\n\n#### Screener\nThe `Screener` class is used to execute the queries and return the filtered results. You can set a custom body for the screener or use predefined configurations.\n\n<!-- TODO: link to Github Pages for more including list of predefined bodies, supported fields, operands, and sample code -->\n\n### Logging\n\n`yfinance` now uses the `logging` module to handle messages, default behaviour is only print errors. If debugging, use `yf.enable_debug_mode()` to switch logging to debug with custom formatting.\n\n### Smarter scraping\n\nInstall the `nospam` packages for smarter scraping using `pip` (see [Installation](#installation)). These packages help cache calls such that Yahoo is not spammed with requests.\n\nTo use a custom `requests` session, pass a `session=` argument to\nthe Ticker constructor. This allows for caching calls to the API as well as a custom way to modify requests via  the `User-agent` header.\n\n```python\nimport requests_cache\nsession = requests_cache.CachedSession('yfinance.cache')\nsession.headers['User-agent'] = 'my-program/1.0'\nticker = yf.Ticker('msft', session=session)\n# The scraped response will be stored in the cache\nticker.actions\n```\n\nCombine `requests_cache` with rate-limiting to avoid triggering Yahoo's rate-limiter/blocker that can corrupt data.\n```python\nfrom requests import Session\nfrom requests_cache import CacheMixin, SQLiteCache\nfrom requests_ratelimiter import LimiterMixin, MemoryQueueBucket\nfrom pyrate_limiter import Duration, RequestRate, Limiter\nclass CachedLimiterSession(CacheMixin, LimiterMixin, Session):\n    pass\n\nsession = CachedLimiterSession(\n    limiter=Limiter(RequestRate(2, Duration.SECOND*5)),  # max 2 requests per 5 seconds\n    bucket_class=MemoryQueueBucket,\n    backend=SQLiteCache(\"yfinance.cache\"),\n)\n```\n\n### Managing Multi-Level Columns\n\nThe following answer on Stack Overflow is for [How to deal with\nmulti-level column names downloaded with\nyfinance?](https://stackoverflow.com/questions/63107801)\n\n-   `yfinance` returns a `pandas.DataFrame` with multi-level column\n    names, with a level for the ticker and a level for the stock price\n    data\n    -   The answer discusses:\n        -   How to correctly read the the multi-level columns after\n            saving the dataframe to a csv with `pandas.DataFrame.to_csv`\n        -   How to download single or multiple tickers into a single\n            dataframe with single level column names and a ticker column\n\n### Persistent cache store\n\nTo reduce Yahoo, yfinance store some data locally: timezones to localize dates, and cookie. Cache location is:\n\n- Windows = C:/Users/\\<USER\\>/AppData/Local/py-yfinance\n- Linux = /home/\\<USER\\>/.cache/py-yfinance\n- MacOS = /Users/\\<USER\\>/Library/Caches/py-yfinance\n\nYou can direct cache to use a different location with `set_tz_cache_location()`:\n\n```python\nimport yfinance as yf\nyf.set_tz_cache_location(\"custom/cache/location\")\n...\n```\n\n---\n\n## Developers: want to contribute?\n\n`yfinance` relies on community to investigate bugs and contribute code. Developer guide: https://github.com/ranaroussi/yfinance/discussions/1084\n\n---\n\n### Legal Stuff\n\n**yfinance** is distributed under the **Apache Software License**. See\nthe [LICENSE.txt](./LICENSE.txt) file in the release for details.\n\n\nAGAIN - yfinance is **not** affiliated, endorsed, or vetted by Yahoo, Inc. It's\nan open-source tool that uses Yahoo's publicly available APIs, and is\nintended for research and educational purposes. You should refer to Yahoo!'s terms of use\n([here](https://policies.yahoo.com/us/en/yahoo/terms/product-atos/apiforydn/index.htm),\n[here](https://legal.yahoo.com/us/en/yahoo/terms/otos/index.html), and\n[here](https://policies.yahoo.com/us/en/yahoo/terms/index.htm)) for\ndetails on your rights to use the actual data downloaded.\n\n---\n\n### P.S.\n\nPlease drop me a note with any feedback you have.\n\n**Ran Aroussi**\n",
    "bugtrack_url": null,
    "license": "Apache",
    "summary": "Download market data from Yahoo! Finance API",
    "version": "0.2.48",
    "project_urls": {
        "Homepage": "https://github.com/ranaroussi/yfinance"
    },
    "split_keywords": [
        "pandas",
        " yahoo finance",
        " pandas datareader"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bc5bb8d04f920d4be17e938a8ebad48941fbb0b97b1672897178c0d470734fd2",
                "md5": "297288e4b678a08ec6758bcf11ad0f1f",
                "sha256": "eda797145faa4536595eb629f869d3616e58ed7e71de36856b19f1abaef71a5b"
            },
            "downloads": -1,
            "filename": "yfinance-0.2.48-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "297288e4b678a08ec6758bcf11ad0f1f",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 101053,
            "upload_time": "2024-10-25T18:03:13",
            "upload_time_iso_8601": "2024-10-25T18:03:13.975906Z",
            "url": "https://files.pythonhosted.org/packages/bc/5b/b8d04f920d4be17e938a8ebad48941fbb0b97b1672897178c0d470734fd2/yfinance-0.2.48-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2bd3164c641a2087b5cc1a065e3380fc7912d16d9423f7eba4398519d83f0acb",
                "md5": "67720a1c769d893ee76bc9f26e9e1529",
                "sha256": "1434cd8bf22f345fa27ef1ed82bfdd291c1bb5b6fe3067118a94e256aa90c4eb"
            },
            "downloads": -1,
            "filename": "yfinance-0.2.48.tar.gz",
            "has_sig": false,
            "md5_digest": "67720a1c769d893ee76bc9f26e9e1529",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 113886,
            "upload_time": "2024-10-25T18:03:15",
            "upload_time_iso_8601": "2024-10-25T18:03:15.513752Z",
            "url": "https://files.pythonhosted.org/packages/2b/d3/164c641a2087b5cc1a065e3380fc7912d16d9423f7eba4398519d83f0acb/yfinance-0.2.48.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-25 18:03:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ranaroussi",
    "github_project": "yfinance",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pandas",
            "specs": [
                [
                    ">=",
                    "1.3.0"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.16.5"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.31"
                ]
            ]
        },
        {
            "name": "multitasking",
            "specs": [
                [
                    ">=",
                    "0.0.7"
                ]
            ]
        },
        {
            "name": "lxml",
            "specs": [
                [
                    ">=",
                    "4.9.1"
                ]
            ]
        },
        {
            "name": "platformdirs",
            "specs": [
                [
                    ">=",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "pytz",
            "specs": [
                [
                    ">=",
                    "2022.5"
                ]
            ]
        },
        {
            "name": "frozendict",
            "specs": [
                [
                    ">=",
                    "2.3.4"
                ]
            ]
        },
        {
            "name": "beautifulsoup4",
            "specs": [
                [
                    ">=",
                    "4.11.1"
                ]
            ]
        },
        {
            "name": "html5lib",
            "specs": [
                [
                    ">=",
                    "1.1"
                ]
            ]
        },
        {
            "name": "peewee",
            "specs": [
                [
                    ">=",
                    "3.16.2"
                ]
            ]
        }
    ],
    "lcname": "yfinance"
}
        
Elapsed time: 0.52979s