Smart caching wrapper for 'yfinance' module
Project description
yfinance-cache
Caching wrapper for yfinance module. Intelligent caching, not dumb caching of web requests:
- If requested data not in cache,
yfinanceis called - If all requested data is in cache, return that
- If some in cache but some missing, ask
yfinancefor the missing data
Additional logic decides if cached data needs refresh.
Interface
Interaction is almost identical to yfinance. Differences are highlighted underneath code:
import yfinance_cache as yf
msft = yf.Ticker("MSFT")
# get stock info
msft.info
# get historical market data
hist = msft.history(period="max")
...
# etc. See yfinance documentation for full API
Refreshing cache
msft = yf.Ticker(interval="1d", max_age=datetime.timedelta(hours=1), ...)
max_age controls when to refresh cached data to avoid spam. If market is still open and max_age time has passed since last fetch, then today's cached price data will be refreshed.
Defaults to half of interval. Refresh also triggered if market closed since last fetch.
Adjusting price
Price can be adjusted for stock splits, dividends, or both. yfinance only allows control of dividends adjustment via auto_adjust. How Yahoo adjusts for dividends is slightly mysterious so djusted prices are slightly different to Yahoo (tiny relative error ~1e-7)
msft = yf.Ticker(..., adjust_splits=True, adjust_divs=True)
Installation
Available on PIP: pip install yfinance_cache
Known issues / pending tasks
- Considering adding a 'verify' function, checking all cached data against Yahoo.
- Add refresh check to financials data, then to earnings dates.
Limitations
Code is being actively developed so some features missing:
- only price data is checked if refresh needed
Tickersclass anddownload()not available - useTicker.history()- pre/post price data not available
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yfinance-cache-0.3.2.tar.gz.
File metadata
- Download URL: yfinance-cache-0.3.2.tar.gz
- Upload date:
- Size: 82.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
258678d9e1a10559dd6f73613cc8d997bafc0496e8f0e17d86577a7b61d4f703
|
|
| MD5 |
7b8089be3b79f0da0eb7a2ede6d86f12
|
|
| BLAKE2b-256 |
2526f8f07ec7403a1927d792485472730d72ec570ab4194acbaaaa57e2ff6960
|
File details
Details for the file yfinance_cache-0.3.2-py3-none-any.whl.
File metadata
- Download URL: yfinance_cache-0.3.2-py3-none-any.whl
- Upload date:
- Size: 102.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a24bf23d9c1cbcc5bcfbfee705685e7c68ce82a85bbf017ccf449efec0029a7
|
|
| MD5 |
bce0f9124893e22f019bb5f9c38feac8
|
|
| BLAKE2b-256 |
e72fc97ce7dd916089c132db2648c93f9e09fc8504260b5e31ac16588a9c3ac5
|