Appendix B — The yahooquery Package

B.1 Single Company

from yahooquery import Ticker

ticker = Ticker("NFLX")

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:

df = ticker.history(start="2024-01-01", end="2024-01-31", adj_ohlc=True)
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 2612500 474.059998
2024-01-08 473.890015 485.239990 473.649994 3675800 485.029999

B.2 Multiple Companies

from yahooquery import Ticker

tickers = Ticker( ["MSFT", "AAPL", "GOOGL"])

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 Productivity and Business Processes segment offers office, exchange, SharePoint, Microsoft Teams, office 365 Security and Compliance, Microsoft viva, and Microsoft 365 copilot; and office consumer services, such as Microsoft 365 consumer subscriptions, Office licensed on-premises, and other office services. This segment also provides LinkedIn; and dynamics business solutions, including Dynamics 365, a set of intelligent, cloud-based applications across ERP, CRM, power apps, and power automate; and on-premises ERP and CRM applications. The Intelligent Cloud segment offers server products and cloud services, such as azure and other cloud services; SQL and windows server, visual studio, system center, and related client access licenses, as well as nuance and GitHub; and enterprise services including enterprise support services, industry solutions, and nuance professional services. The More Personal Computing segment offers Windows, including windows OEM licensing and other non-volume licensing of the Windows operating system; Windows commercial comprising volume licensing of the Windows operating system, windows cloud services, and other Windows commercial offerings; patent licensing; and windows Internet of Things; and devices, such as surface, HoloLens, and PC accessories. Additionally, this segment provides gaming, which includes Xbox hardware and content, and first- and third-party content; Xbox game pass and other subscriptions, cloud gaming, advertising, third-party disc royalties, and other cloud services; and search and news advertising, which includes Bing, Microsoft News and Edge, and third-party affiliates. The company sells its products through OEMs, distributors, and resellers; and directly through digital marketplaces, 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': 164000,
  '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': 185719,
  'companyOfficers': [],
  'executiveTeam': [],
  'maxAge': 86400}}

Historical prices:

df = tickers.history()
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.976868 0.0
2025-01-03 421.079987 424.029999 419.540009 423.350006 16662900 421.728607 0.0
2025-01-06 428.000000 434.320007 425.480011 427.850006 20573600 426.211365 0.0
2025-01-07 429.000000 430.649994 420.799988 422.369995 18139100 420.752350 0.0
2025-01-08 423.459991 426.970001 421.540009 424.559998 15054600 422.933960 0.0
df.tail()
open high low close volume adjclose dividends
symbol date
GOOGL 2025-06-17 175.699997 177.360001 174.580002 175.949997 24973000 175.949997 0.0
2025-06-18 176.009995 176.559998 173.199997 173.320007 28707500 173.320007 0.0
2025-06-20 173.949997 174.339996 165.460007 166.639999 75659900 166.639999 0.0
2025-06-23 166.270004 167.339996 162.000000 165.190002 57671000 165.190002 0.0
2025-06-24 16:00:02-04:00 167.039993 168.220001 166.130005 166.770004 40123669 166.770004 0.0

Simplifying the multi-index:

df["symbol"] = df.index.get_level_values(0)
df["date"] = df.index.get_level_values(1)

df.reset_index(drop=True, inplace=True)

df[["date", "symbol", "adjclose"]].head()
date symbol adjclose
0 2025-01-02 MSFT 416.976868
1 2025-01-03 MSFT 421.728607
2 2025-01-06 MSFT 426.211365
3 2025-01-07 MSFT 420.752350
4 2025-01-08 MSFT 422.933960

Optionally converting dates to be datetime-aware:

from pandas import to_datetime

# fix date values (see: https://github.com/dpguthrie/yahooquery/issues/210)
df["date"] = df["date"].astype("str")
df["date"] = df["date"].str.split(" ").str[0]
# convert to datetime-aware values:
df["date"] = to_datetime(df["date"]).dt.date

df[["date", "symbol", "adjclose"]].head()
date symbol adjclose
0 2025-01-02 MSFT 416.976868
1 2025-01-03 MSFT 421.728607
2 2025-01-06 MSFT 426.211365
3 2025-01-07 MSFT 420.752350
4 2025-01-08 MSFT 422.933960

Pivoting the data:

prices_pivot = df.pivot(columns="symbol", values="adjclose", index="date")
prices_pivot.head()
symbol AAPL GOOGL MSFT
date
2025-01-02 243.263199 188.983292 416.976868
2025-01-03 242.774368 191.337723 421.728607
2025-01-06 244.410416 196.405762 426.211365
2025-01-07 241.627136 195.029022 420.752350
2025-01-08 242.115952 193.492645 422.933960