A package to get stock data from Yahoo Finance
Project description
Stockdex
Stockdex is a Python package that provides a simple interface to access financial data from Yahoo Finance. Data is returned as a pandas DataFrame.
Installation
Install the package using pip:
pip install stockdex
Usage
Create Ticker
object by passing the ticker symbol. Ticker objects are the main interface to retrieve stock data.
from stockdex import Ticker
# Pick arbitrary ticker
ticker = Ticker('AAPL')
Fundamental data from Yahoo Finance
API (fast queries through Yahoo Finance API):
# Price data (use range and dataGranularity to make range and granularity more specific)
price = ticker.price(range='1y', dataGranularity='1d')
# Current trading period of the stock (pre-market, regular, post-market trading periods)
current_trading_period = ticker.current_trading_period
# Fundamental data (use frequency, format, period1 and period2 to fine-tune the returned data)
income_statement = ticker.income_statement(frequency='quarterly')
cash_flow = ticker.cash_flow(format='raw')
balance_sheet = ticker.balance_sheet(period1=datetime(2020, 1, 1))
financials = ticker.financials(period1=datetime(2022, 1, 1), period2=datetime.today())
Fundamental data with criteria from Yahoo Finance
website (web scraping):
# Summary including general financial information
summary = ticker.summary
# Financial data as it is seen in the yahoo finance website
income_stmt = ticker.income_stmt
balance_sheet = ticker.balance_sheet_web
cash_flow = ticker.cashflow_web
# Analysts and estimates
analysis = ticker.analysis
# Data about options
calls = ticker.calls
puts = ticker.puts
# Profile data
key_executives = ticker.key_executives
description = ticker.description
corporate_governance = ticker.corporate_governance
# Data about shareholders
major_holders = ticker.major_holders
top_institutional_holders = ticker.top_institutional_holders
top_mutual_fund_holders = ticker.top_mutual_fund_holders
# Main statistics
statistics = ticker.statistics
NASDAQ data from NASDAQ
(web scraping):
# Data about quarterly and yearly earnings, updated on the same day as the earnings release (yahoo finance data is updated after a few days)
quarterly_earnings_surprise = ticker.quarterly_earnings_surprise
yearly_earnings_forecast = ticker.yearly_earnings_forecast
quarterly_earnings_forecast = ticker.quarterly_earnings_forecast
EU ETF data from justETF (web scraping):
For EU ETFS, the isin
and security_type
should be passed to the Ticker
object. The isin
is the International Securities Identification Number of the ETF and the security_type
should be set to etf
.
etf = Ticker(isin='IE00B4L5Y983', security_type='etf')
etf_general_info = etf.etf_general_info
etf_wkn = etf.etf_wkn
etf_description = etf.etf_description
# Basic data about the ETF
etf_basics = etf.etf_basics
# Holdings of the ETF by company, country and sector
etf_holdings_companies = etf.etf_holdings_companies
etf_holdings_countries = etf.etf_holdings_countries
etf_holdings_sectors = etf.etf_holdings_sectors
Historical dividends data
All dividends paid by the company returned as a pandas DataFrame.
dividend = ticker.dividend
Check out sphinx documentation here for more information about the package.
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
Hashes for stockdex-0.3.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fa5086ce38c21b2afe89cc2b10a730efca43efdfd18f5dee79770f7a117d801 |
|
MD5 | 0fddd8697a3645c550e97ee0fb87010e |
|
BLAKE2b-256 | 327e640f6e23924ce742d224a9a20837359ce44d3b6f23cffba0e166ae0ba6b2 |