from yahooquery import Ticker
= Ticker("NFLX") ticker
Appendix B — The yahooquery
Package
B.1 Single Company
Company information:
ticker.summary_profile
{'NFLX': {'address1': '121 Albright Way',
'city': 'Los Gatos',
'state': 'CA',
'zip': '95032',
'country': 'United States',
'phone': '(408) 540-3700',
'website': 'https://www.netflix.com',
'industry': 'Entertainment',
'industryKey': 'entertainment',
'industryDisp': 'Entertainment',
'sector': 'Communication Services',
'sectorKey': 'communication-services',
'sectorDisp': 'Communication Services',
'longBusinessSummary': 'Netflix, Inc. provides entertainment services. The company offers television (TV) series, documentaries, feature films, and games across various genres and languages. It also provides members the ability to receive streaming content through a host of internet-connected devices, including TVs, digital video players, TV set-top boxes, and mobile devices. The company operates approximately in 190 countries. Netflix, Inc. was incorporated in 1997 and is headquartered in Los Gatos, California.',
'fullTimeEmployees': 14000,
'companyOfficers': [],
'executiveTeam': [],
'maxAge': 86400}}
Historical prices:
= ticker.history(start="2024-01-01", end="2024-01-31", adj_ohlc=True)
df df.head()
open | high | low | volume | close | ||
---|---|---|---|---|---|---|
symbol | date | |||||
NFLX | 2024-01-02 | 483.190002 | 484.649994 | 461.859985 | 5049400 | 468.500000 |
2024-01-03 | 467.320007 | 475.049988 | 465.769989 | 3443700 | 470.260010 | |
2024-01-04 | 472.980011 | 480.739990 | 466.529999 | 3636500 | 474.670013 | |
2024-01-05 | 476.500000 | 479.549988 | 471.799988 | 2631300 | 474.059998 | |
2024-01-08 | 473.890015 | 485.239990 | 473.649994 | 3675800 | 485.029999 |
B.2 Multiple Companies
from yahooquery import Ticker
= Ticker( ["MSFT", "AAPL", "GOOGL"]) tickers
Company information:
tickers.summary_profile
{'MSFT': {'address1': 'One Microsoft Way',
'city': 'Redmond',
'state': 'WA',
'zip': '98052-6399',
'country': 'United States',
'phone': '425 882 8080',
'website': 'https://www.microsoft.com',
'industry': 'Software - Infrastructure',
'industryKey': 'software-infrastructure',
'industryDisp': 'Software - Infrastructure',
'sector': 'Technology',
'sectorKey': 'technology',
'sectorDisp': 'Technology',
'longBusinessSummary': "Microsoft Corporation develops and supports software, services, devices, and solutions worldwide. The company's Productivity and Business Processes segment offers Microsoft 365 Commercial, Enterprise Mobility + Security, Windows Commercial, Power BI, Exchange, SharePoint, Microsoft Teams, Security and Compliance, and Copilot; Microsoft 365 Commercial products, such as Windows Commercial on-premises and Office licensed services; Microsoft 365 Consumer products and cloud services, such as Microsoft 365 Consumer subscriptions, Office licensed on-premises, and other consumer services; LinkedIn; Dynamics products and cloud services, such as Dynamics 365, cloud-based applications, and on-premises ERP and CRM applications. Its Intelligent Cloud segment provides Server products and cloud services, such as Azure and other cloud services, GitHub, Nuance Healthcare, virtual desktop offerings, and other cloud services; Server products, including SQL and Windows Server, Visual Studio and System Center related Client Access Licenses, and other on-premises offerings; Enterprise and partner services, including Enterprise Support and Nuance professional Services, Industry Solutions, Microsoft Partner Network, and Learning Experience. The company's Personal Computing segment provides Windows and Devices, such as Windows OEM licensing and Devices and Surface and PC accessories; Gaming services and solutions, such as Xbox hardware, content, and services, first- and third-party content Xbox Game Pass, subscriptions, and Cloud Gaming, advertising, and other cloud services; search and news advertising services, such as Bing and Copilot, Microsoft News and Edge, and third-party affiliates. It sells its products through OEMs, distributors, and resellers; and online and retail stores. The company was founded in 1975 and is headquartered in Redmond, Washington.",
'fullTimeEmployees': 228000,
'companyOfficers': [],
'irWebsite': 'http://www.microsoft.com/investor/default.aspx',
'executiveTeam': [],
'maxAge': 86400},
'AAPL': {'address1': 'One Apple Park Way',
'city': 'Cupertino',
'state': 'CA',
'zip': '95014',
'country': 'United States',
'phone': '(408) 996-1010',
'website': 'https://www.apple.com',
'industry': 'Consumer Electronics',
'industryKey': 'consumer-electronics',
'industryDisp': 'Consumer Electronics',
'sector': 'Technology',
'sectorKey': 'technology',
'sectorDisp': 'Technology',
'longBusinessSummary': 'Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables, and accessories worldwide. The company offers iPhone, a line of smartphones; Mac, a line of personal computers; iPad, a line of multi-purpose tablets; and wearables, home, and accessories comprising AirPods, Apple TV, Apple Watch, Beats products, and HomePod. It also provides AppleCare support and cloud services; and operates various platforms, including the App Store that allow customers to discover and download applications and digital content, such as books, music, video, games, and podcasts, as well as advertising services include third-party licensing arrangements and its own advertising platforms. In addition, the company offers various subscription-based services, such as Apple Arcade, a game subscription service; Apple Fitness+, a personalized fitness service; Apple Music, which offers users a curated listening experience with on-demand radio stations; Apple News+, a subscription news and magazine service; Apple TV+, which offers exclusive original content; Apple Card, a co-branded credit card; and Apple Pay, a cashless payment service, as well as licenses its intellectual property. The company serves consumers, and small and mid-sized businesses; and the education, enterprise, and government markets. It distributes third-party applications for its products through the App Store. The company also sells its products through its retail and online stores, and direct sales force; and third-party cellular network carriers, wholesalers, retailers, and resellers. Apple Inc. was founded in 1976 and is headquartered in Cupertino, California.',
'fullTimeEmployees': 150000,
'companyOfficers': [],
'irWebsite': 'http://investor.apple.com/',
'executiveTeam': [],
'maxAge': 86400},
'GOOGL': {'address1': '1600 Amphitheatre Parkway',
'city': 'Mountain View',
'state': 'CA',
'zip': '94043',
'country': 'United States',
'phone': '650-253-0000',
'website': 'https://abc.xyz',
'industry': 'Internet Content & Information',
'industryKey': 'internet-content-information',
'industryDisp': 'Internet Content & Information',
'sector': 'Communication Services',
'sectorKey': 'communication-services',
'sectorDisp': 'Communication Services',
'longBusinessSummary': 'Alphabet Inc. offers various products and platforms in the United States, Europe, the Middle East, Africa, the Asia-Pacific, Canada, and Latin America. It operates through Google Services, Google Cloud, and Other Bets segments. The Google Services segment provides products and services, including ads, Android, Chrome, devices, Gmail, Google Drive, Google Maps, Google Photos, Google Play, Search, and YouTube. It is also involved in the sale of apps and in-app purchases and digital content in the Google Play and YouTube; and devices, as well as in the provision of YouTube consumer subscription services. The Google Cloud segment offers AI infrastructure, Vertex AI platform, cybersecurity, data and analytics, and other services; Google Workspace that include cloud-based communication and collaboration tools for enterprises, such as Calendar, Gmail, Docs, Drive, and Meet; and other services for enterprise customers. The Other Bets segment sells healthcare-related and internet services. The company was incorporated in 1998 and is headquartered in Mountain View, California.',
'fullTimeEmployees': 187103,
'companyOfficers': [],
'executiveTeam': [],
'maxAge': 86400}}
Historical prices:
= tickers.history()
df df.head()
open | high | low | close | volume | adjclose | dividends | ||
---|---|---|---|---|---|---|---|---|
symbol | date | |||||||
MSFT | 2025-01-02 | 425.529999 | 426.070007 | 414.850006 | 418.579987 | 16896500 | 416.292511 | 0.0 |
2025-01-03 | 421.079987 | 424.029999 | 419.540009 | 423.350006 | 16662900 | 421.036469 | 0.0 | |
2025-01-06 | 428.000000 | 434.320007 | 425.480011 | 427.850006 | 20573600 | 425.511871 | 0.0 | |
2025-01-07 | 429.000000 | 430.649994 | 420.799988 | 422.369995 | 18139100 | 420.061798 | 0.0 | |
2025-01-08 | 423.459991 | 426.970001 | 421.540009 | 424.559998 | 15054600 | 422.239838 | 0.0 |
df.tail()
open | high | low | close | volume | adjclose | dividends | ||
---|---|---|---|---|---|---|---|---|
symbol | date | |||||||
GOOGL | 2025-10-02 | 245.149994 | 246.809998 | 242.300003 | 245.690002 | 25483300 | 245.690002 | 0.0 |
2025-10-03 | 244.490005 | 246.300003 | 241.660004 | 245.350006 | 30249600 | 245.350006 | 0.0 | |
2025-10-06 | 244.779999 | 251.320007 | 244.580002 | 250.429993 | 28894700 | 250.429993 | 0.0 | |
2025-10-07 | 248.270004 | 250.440002 | 245.520004 | 245.759995 | 23181300 | 245.759995 | 0.0 | |
2025-10-08 16:00:01-04:00 | 244.949997 | 246.005005 | 243.820007 | 244.619995 | 21111139 | 244.619995 | 0.0 |
Simplifying the multi-index:
"symbol"] = df.index.get_level_values(0)
df["date"] = df.index.get_level_values(1)
df[
=True, inplace=True)
df.reset_index(drop
"date", "symbol", "adjclose"]].head() df[[
date | symbol | adjclose | |
---|---|---|---|
0 | 2025-01-02 | MSFT | 416.292511 |
1 | 2025-01-03 | MSFT | 421.036469 |
2 | 2025-01-06 | MSFT | 425.511871 |
3 | 2025-01-07 | MSFT | 420.061798 |
4 | 2025-01-08 | MSFT | 422.239838 |
Optionally converting dates to be datetime-aware:
from pandas import to_datetime
# fix date values (see: https://github.com/dpguthrie/yahooquery/issues/210)
"date"] = df["date"].astype("str")
df["date"] = df["date"].str.split(" ").str[0]
df[# convert to datetime-aware values:
"date"] = to_datetime(df["date"]).dt.date
df[
"date", "symbol", "adjclose"]].head() df[[
date | symbol | adjclose | |
---|---|---|---|
0 | 2025-01-02 | MSFT | 416.292511 |
1 | 2025-01-03 | MSFT | 421.036469 |
2 | 2025-01-06 | MSFT | 425.511871 |
3 | 2025-01-07 | MSFT | 420.061798 |
4 | 2025-01-08 | MSFT | 422.239838 |
Pivoting the data:
= df.pivot(columns="symbol", values="adjclose", index="date")
prices_pivot prices_pivot.head()
symbol | AAPL | GOOGL | MSFT |
---|---|---|---|
date | |||
2025-01-02 | 242.987427 | 188.814438 | 416.292511 |
2025-01-03 | 242.499146 | 191.166748 | 421.036469 |
2025-01-06 | 244.133347 | 196.230240 | 425.511871 |
2025-01-07 | 241.353226 | 194.854752 | 420.061798 |
2025-01-08 | 241.841476 | 193.319733 | 422.239838 |