Skip to main content

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 worldwide. The company offers television (TV) series, documentaries, feature films, games, and live programming 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. Netflix, Inc. was incorporated in 1997 and is headquartered in Los Gatos, California.',
  'fullTimeEmployees': 16000,
  '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 48.319000 48.465000 46.186001 50494000 46.849998
2024-01-03 46.731998 47.505001 46.577000 34437000 47.026001
2024-01-04 47.298000 48.074001 46.653000 36365000 47.466999
2024-01-05 47.650002 47.955002 47.180000 26313000 47.405998
2024-01-08 47.389000 48.523998 47.365002 36758000 48.502998

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, a technology company, develops and supports a portfolio of technology solutions for individuals and businesses worldwide. Its products include operating systems, server applications, business solution applications, software development tools, desktop and server management tools, and video games; and devices, such as PCs, tablets, gaming and entertainment consoles, other intelligent devices, and related accessories. The company's Productivity and Business Processes segment offers Microsoft 365 Commercial, Enterprise Mobility + Security, Power BI, Exchange, SharePoint, Microsoft Teams, Microsoft 365 Security and Compliance, Microsoft 365 Copilot, and Windows Commercial on-premises and Office licensed on-premises. This segment also provides Microsoft 365 Consumer products and cloud services; LinkedIn, including talent solutions, marketing solutions, subscriptions, and sales solutions; Dynamics 365, a set of cloud-based applications; and on-premises ERP and CRM applications. Its Intelligent Cloud segment offers server products and cloud services; cloud and AI consumption-based services, GitHub cloud services, health and life sciences cloud services, as well as virtual desktop offerings, and other cloud services; SQL Server, Windows Server, Visual Studio, System Center, and related client access licenses; and enterprise support services, industry solutions, Microsoft partner network, and learning experience. The company's More Personal Computing segment provides Windows OEM licensing and devices comprising Surface and PC accessories; XBOX hardware, and XBOX first- and third-party content and services; XBOX Game Pass and other subscriptions; XBOX Cloud Gaming, advertising, and other cloud services; and search advertising consisting of Bing, Copilot, Microsoft News, Microsoft Edge, and third-party affiliates. It sells its products through partners and retail networks. The company was founded in 1975 and is headquartered in Redmond, Washington.",
  'fullTimeEmployees': 223000,
  'companyOfficers': [],
  'irWebsite': 'http://www.microsoft.com/investor/default.aspx',
  'executiveTeam': [],
  'maxAge': 86400},
 'AAPL': {'address1': 'One Apple Park Way',
  'address2': 'MS 927-4GC',
  '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. 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, including Apple Watch, AirPods, Beats products, Apple Vision Pro, Apple TV 4K, HomePod, and Apple HomeView, as well as Apple branded and third-party accessories. It also provides advertising services comprising third-party licensing arrangements and own advertising platforms; AppleCare and cloud services; and payment services, including Apple Card and Apple Pay. In addition, the company operates App Store that allow customers to discover and download applications and digital content, such as books, music, video, games, and podcasts. Further, it provides digital content through subscription-based services, including Apple Arcade, a game service; Apple Fitness+, a personalized fitness service; Apple Music, which offers users a curated listening experience; Apple News+, a news and magazine service; and Apple TV, which offers original content and live sports. The company sells its products and resells third-party products through its retail and online stores, and direct sales force; its services through its various service platforms; and third-party cellular network carriers and other resellers. It serves consumer, small and mid-sized business, education, enterprise, and government markets. The company operates in North and South America, European countries, India, the Middle East, Africa, China mainland, Hong Kong, Taiwan, Japan, Australia, New Zealand, and rest of Asia. The company was formerly known as Apple Computer, Inc. and changed its name to Apple Inc. in January 2007. Apple Inc. was founded in 1976 and is headquartered in Cupertino, California.',
  'fullTimeEmployees': 167000,
  '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 Google Play and YouTube; and devices, as well as the provision of YouTube consumer subscription services, such as YouTube TV, YouTube Music and Premium, NFL Sunday Ticket, and Google One. The Google Cloud segment offers consumption-based fees and subscriptions for AI solutions, including AI infrastructure, Vertex AI platform, and Gemini enterprise. It also provides cybersecurity, and data and analytics services; Google Workspace that include cloud-based communication and collaboration tools for enterprises, such as Calendar, Gmail, Docs, Drive, and Meet; and other enterprise services. The Other Bets segment sells transportation and internet services. Alphabet Inc. was incorporated in 1998 and is headquartered in Mountain View, California.',
  'fullTimeEmployees': 204757,
  'companyOfficers': [],
  'executiveTeam': [],
  'maxAge': 86400}}

Historical prices:

df = tickers.history()
df.head()
open high low close volume adjclose dividends
symbol date
MSFT 2026-01-02 484.390015 484.660004 470.160004 472.940002 25571600 469.052429 0.0
2026-01-05 474.059998 476.070007 469.500000 472.850006 25250300 468.963135 0.0
2026-01-06 473.799988 478.739990 469.750000 478.510010 23037700 474.576630 0.0
2026-01-07 479.760010 489.700012 477.950012 483.470001 25564200 479.495819 0.0
2026-01-08 481.239990 482.660004 475.859985 478.109985 18162600 474.179901 0.0
df.tail()
open high low close volume adjclose dividends
symbol date
GOOGL 2026-11-16 293.809998 294.140015 282.959991 283.720001 34747200 283.720001 0.0
2026-11-17 283.399994 284.089996 278.459991 280.200012 32175900 280.200012 0.0
2026-11-18 282.750000 284.970001 279.690002 282.440002 27401800 282.440002 0.0
2026-11-19 294.299988 295.429993 272.359985 272.660004 49718500 272.660004 0.0
2026-11-20 274.500000 283.149994 264.220001 265.290009 57302800 265.290009 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 2026-01-02 MSFT 469.052429
1 2026-01-05 MSFT 468.963135
2 2026-01-06 MSFT 474.576630
3 2026-01-07 MSFT 479.495819
4 2026-01-08 MSFT 474.179901

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 2026-01-02 MSFT 469.052429
1 2026-01-05 MSFT 468.963135
2 2026-01-06 MSFT 474.576630
3 2026-01-07 MSFT 479.495819
4 2026-01-08 MSFT 474.179901

Pivoting the data:

prices_pivot = df.pivot(columns="symbol", values="adjclose", index="date")
prices_pivot.head()
symbol AAPL GOOGL MSFT
date
2026-01-02 270.069153 314.538147 469.052429
2026-01-05 266.332184 315.925476 468.963135
2026-01-06 261.449158 313.729706 474.576630
2026-01-07 259.426208 321.354889 479.495819
2026-01-08 258.140686 324.808167 474.179901