cointoss.sources.yahoofinance¶
yahoofinance
¶
YfPeriod = Literal['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']
module-attribute
¶
SECTORS = ('basic-materials', 'communication-services', 'consumer-cyclical', 'consumer-defensive', 'energy', 'financial-services', 'healthcare', 'industrials', 'real-estate', 'technology', 'utilities')
module-attribute
¶
NoSuchTicker
¶
Bases: LookupError
Yahoo has no history for ticker.
Source code in src/cointoss/sources/yahoofinance.py
IndustryList
¶
Bases: StrEnum
Which of an industry's two published lists named a company.
Source code in src/cointoss/sources/yahoofinance.py
IndustryListing
¶
Bases: BaseModel
One company named by one of an industry's lists, under Yahoo's sector and industry keys.
Source code in src/cointoss/sources/yahoofinance.py
Industry
¶
Bases: BaseModel
One of Yahoo's industries, under the key of the sector it belongs to.
Source code in src/cointoss/sources/yahoofinance.py
get_info(ticker)
¶
get_prices(ticker, period='max')
¶
Source code in src/cointoss/sources/yahoofinance.py
get_prices_batch(tickers, *, period=None, start=None)
¶
Each ticker's daily history from one yf.download, from start or over period.
Each frame is shaped as get_prices shapes one: a date column, then Yahoo's columns,
auto_adjust=False with the action columns, and only the sessions the ticker has a close
for, since the batch's index is the union of every ticker's sessions. A ticker with no
close at all is NoSuchTicker: yfinance logs a failed download and leaves its columns
empty, so an unknown ticker and a failed fetch look alike. Not cached: a daily window must
be fetched fresh. Fetches the tickers one after another, so a caller pacing batches paces
the requests.
Source code in src/cointoss/sources/yahoofinance.py
search_pairs(symbol)
¶
Yahoo's USD tickers for the coin symbol, in search order.
Yahoo lists many coins under {SYMBOL}{n}-USD, a numeric suffix telling apart coins that
share a symbol, so the candidates are the crypto quotes for {symbol} USD of that shape.
Source code in src/cointoss/sources/yahoofinance.py
lookup(query)
¶
Source code in src/cointoss/sources/yahoofinance.py
sector_industries(sector)
¶
The keys of the industries Yahoo lists under sector, in Yahoo's order.
Source code in src/cointoss/sources/yahoofinance.py
industry_companies(industry)
¶
The companies industry's top (up to 50) and fastest-growing (5) lists name.
A company on both lists is named once by each.
Source code in src/cointoss/sources/yahoofinance.py
industries()
¶
Every industry of every sector, in Yahoo's order: 145 in 11 sectors.
Source code in src/cointoss/sources/yahoofinance.py
industry_listings(walked=None)
¶
Every company named by the lists of the walked industries, every industry if None.
About 2,600 US tickers over 145 industries in 11 sectors; each sector and industry query is cached on its own, so a walk interrupted part-way resumes from the cache.