YahooFinanceAPI
YahooFinanceAPI is a small wrapper that is meant solely to retrieve historical data from Yahoo Finance.
Installation
pip install YahooFinanceAPI
Functions
The function declarations for the limited functionality are listed below with comments.
# reset the data frequency (daily, weekly, or monthly) the Interval
# class allows access to class variables that define these intervals, i.e.
# Interval.WEEKLY, Interval.MONTHLY, and Interval.DAILY
set_interval(interval)
# Retrieve data for one ticker from start_date to end_date.
# ticker is a string and start_date and end_date are python datetimes.
# This function returns a Pandas dataframe.
get_ticker_data(ticker, start_date, end_date)
# Retrieve data for a list of tickers.
# tickers -> list of strings, start_date and end_date -> datatimes
# Returns a dictionary taking the ticker symbol to a Pandas dataframe
get_data_for_tickers(tickers, start_date, end_date)
Usage
Acceptable intervals are 1d (default), 1wk, and 1mo. The API only offers the ability to retrieve data for a ticker or a list of tickers. The results are returned as a Pandas dataframe and include the following columns:
Date
Open
High
Low
Close
Adj Close
Volume
Example usage, as seen in example.py:
from yfapi import YahooFinanceAPI, Interval
# instantiate the API and set the interval to weekly data
dh = YahooFinanceAPI(Interval.WEEKLY)
now = datetime.datetime(2020, 6, 28)
then = datetime.datetime(2020, 1, 1)
# returns dataframe holding the historical data
df = dh.get_ticker_data("msft", then, now)
# reset the data interval to monthly
dh.set_interval(Interval.MONTHLY)
# returns results as a dictionary: ticker -> dataframe
data_dict = dh.get_data_for_tickers(['msft', 'aapl', 'amzn'], then, now)
Metadata
Release files for YahooFinanceAPI 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| YahooFinanceAPI-1.0.0.tar.gz | 2.9 kB | Without provenance | Details for YahooFinanceAPI-1.0.0.tar.gz |
Release files / YahooFinanceAPI-1.0.0.tar.gz
| Download URL | YahooFinanceAPI-1.0.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
40491fc9dafb881a37da1c38f15d9dd764fcd7aa6b6544884a87d86e640436bb
|
|
BLAKE2b-256 checksum How to use checksums |
5822295eb88100a28f11f694aea80f3930bd48cc3f46ba7d9fcb78cf618e8c14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
|
Security for YahooFinanceAPI 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.