Companies

Companies
Author

Benedict Thekkel

import pandas as pd
import httpx

url = "https://www.sec.gov/files/company_tickers.json"
headers = {"User-Agent": "Ben Thekkel (your_email@example.com)", "Accept": "application/json"}

async with httpx.AsyncClient(http2=True, headers=headers, timeout=30.0) as client:
    r = await client.get(url)
    r.raise_for_status()
    data = r.json()

df = pd.DataFrame.from_dict(data, orient="index")
df
cik_str ticker title
0 1045810 NVDA NVIDIA CORP
1 789019 MSFT MICROSOFT CORP
2 320193 AAPL Apple Inc.
3 1652044 GOOGL Alphabet Inc.
4 1018724 AMZN AMAZON COM INC
... ... ... ...
10085 2053411 PCPPF PC Partner Group Ltd/ADR
10086 2073638 FINGF Finning International Inc./ADR
10087 2020414 EDVGF Endeavour Group Limited/ADR
10088 2008315 ARHUF AAK AB/ADR
10089 1788707 ADYYF Adyen N.V./ADR

10090 rows × 3 columns

yfinance

import yfinance as yf


ticker = "AAPL"
info = yf.Ticker(ticker).info  # dict with company fundamentals
info
{'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': [{'maxAge': 1,
   'name': 'Mr. Timothy D. Cook',
   'age': 63,
   'title': 'CEO & Director',
   'yearBorn': 1961,
   'fiscalYear': 2024,
   'totalPay': 16520856,
   'exercisedValue': 0,
   'unexercisedValue': 0},
  {'maxAge': 1,
   'name': 'Ms. Katherine L. Adams',
   'age': 60,
   'title': 'Senior VP, General Counsel & Secretary',
   'yearBorn': 1964,
   'fiscalYear': 2024,
   'totalPay': 5022182,
   'exercisedValue': 0,
   'unexercisedValue': 0},
  {'maxAge': 1,
   'name': "Ms. Deirdre  O'Brien",
   'age': 57,
   'title': 'Chief People Officer & Senior VP of Retail',
   'yearBorn': 1967,
   'fiscalYear': 2024,
   'totalPay': 5022182,
   'exercisedValue': 0,
   'unexercisedValue': 0},
  {'maxAge': 1,
   'name': 'Mr. Jeffrey E. Williams',
   'age': 60,
   'title': 'Senior Vice President of Design, Watch, & Health',
   'yearBorn': 1964,
   'fiscalYear': 2024,
   'totalPay': 5020737,
   'exercisedValue': 0,
   'unexercisedValue': 0},
  {'maxAge': 1,
   'name': 'Mr. Kevan  Parekh',
   'age': 52,
   'title': 'Senior VP & CFO',
   'yearBorn': 1972,
   'fiscalYear': 2024,
   'exercisedValue': 0,
   'unexercisedValue': 0},
  {'maxAge': 1,
   'name': 'Mr. Sabih  Khan',
   'title': 'Chief Operating Officer',
   'fiscalYear': 2024,
   'exercisedValue': 0,
   'unexercisedValue': 0},
  {'maxAge': 1,
   'name': 'Mr. Chris  Kondo',
   'title': 'Senior Director of Corporate Accounting',
   'fiscalYear': 2024,
   'exercisedValue': 0,
   'unexercisedValue': 0},
  {'maxAge': 1,
   'name': 'Suhasini  Chandramouli',
   'title': 'Director of Investor Relations',
   'fiscalYear': 2024,
   'exercisedValue': 0,
   'unexercisedValue': 0},
  {'maxAge': 1,
   'name': 'Ms. Kristin Huguet Quayle',
   'title': 'Vice President of Worldwide Communications',
   'fiscalYear': 2024,
   'exercisedValue': 0,
   'unexercisedValue': 0},
  {'maxAge': 1,
   'name': 'Mr. Greg  Joswiak',
   'title': 'Senior Vice President of Worldwide Marketing',
   'fiscalYear': 2024,
   'exercisedValue': 0,
   'unexercisedValue': 0}],
 'auditRisk': 7,
 'boardRisk': 1,
 'compensationRisk': 3,
 'shareHolderRightsRisk': 1,
 'overallRisk': 1,
 'governanceEpochDate': 1756684800,
 'compensationAsOfEpochDate': 1735603200,
 'irWebsite': 'http://investor.apple.com/',
 'executiveTeam': [],
 'maxAge': 86400,
 'priceHint': 2,
 'previousClose': 232.14,
 'open': 229.7,
 'dayLow': 227.69,
 'dayHigh': 230.78,
 'regularMarketPreviousClose': 232.14,
 'regularMarketOpen': 229.7,
 'regularMarketDayLow': 227.69,
 'regularMarketDayHigh': 230.78,
 'dividendRate': 1.04,
 'dividendYield': 0.45,
 'exDividendDate': 1754870400,
 'payoutRatio': 0.1533,
 'fiveYearAvgDividendYield': 0.54,
 'beta': 1.165,
 'trailingPE': 34.937786,
 'forwardPE': 27.706377,
 'volume': 10237665,
 'regularMarketVolume': 10237665,
 'averageVolume': 54241479,
 'averageVolume10days': 38652350,
 'averageDailyVolume10Day': 38652350,
 'bid': 229.02,
 'ask': 231.97,
 'bidSize': 3,
 'askSize': 4,
 'marketCap': 3416853839872,
 'fiftyTwoWeekLow': 169.21,
 'fiftyTwoWeekHigh': 260.1,
 'priceToSalesTrailing12Months': 8.361833,
 'fiftyDayAverage': 215.5476,
 'twoHundredDayAverage': 221.1669,
 'trailingAnnualDividendRate': 1.01,
 'trailingAnnualDividendYield': 0.004350823,
 'currency': 'USD',
 'tradeable': False,
 'enterpriseValue': 3491374039040,
 'profitMargins': 0.24295999,
 'floatShares': 14814419318,
 'sharesOutstanding': 14840399872,
 'sharesShort': 127079143,
 'sharesShortPriorMonth': 93946599,
 'sharesShortPreviousMonthDate': 1752537600,
 'dateShortInterest': 1755216000,
 'sharesPercentSharesOut': 0.0086,
 'heldPercentInsiders': 0.0197,
 'heldPercentInstitutions': 0.63659,
 'shortRatio': 2.08,
 'shortPercentOfFloat': 0.0086,
 'impliedSharesOutstanding': 15318899712,
 'bookValue': 4.431,
 'priceToBook': 51.96118,
 'lastFiscalYearEnd': 1727481600,
 'nextFiscalYearEnd': 1759017600,
 'mostRecentQuarter': 1751068800,
 'earningsQuarterlyGrowth': 0.093,
 'netIncomeToCommon': 99280003072,
 'trailingEps': 6.59,
 'forwardEps': 8.31,
 'lastSplitFactor': '4:1',
 'lastSplitDate': 1598832000,
 'enterpriseToRevenue': 8.544,
 'enterpriseToEbitda': 24.64,
 '52WeekChange': 0.04206133,
 'SandP52WeekChange': 0.16844666,
 'lastDividendValue': 0.26,
 'lastDividendDate': 1754870400,
 'quoteType': 'EQUITY',
 'currentPrice': 230.24,
 'targetHighPrice': 300.0,
 'targetLowPrice': 175.0,
 'targetMeanPrice': 234.99919,
 'targetMedianPrice': 239.0,
 'recommendationMean': 1.95455,
 'recommendationKey': 'buy',
 'numberOfAnalystOpinions': 37,
 'totalCash': 55372001280,
 'totalCashPerShare': 3.731,
 'ebitda': 141696008192,
 'totalDebt': 101698002944,
 'quickRatio': 0.724,
 'currentRatio': 0.868,
 'totalRevenue': 408624988160,
 'debtToEquity': 154.486,
 'revenuePerShare': 27.173,
 'returnOnAssets': 0.24545999,
 'returnOnEquity': 1.49814,
 'grossProfits': 190739005440,
 'freeCashflow': 94873747456,
 'operatingCashflow': 108564996096,
 'earningsGrowth': 0.121,
 'revenueGrowth': 0.096,
 'grossMargins': 0.46678,
 'ebitdaMargins': 0.34675997,
 'operatingMargins': 0.29990998,
 'financialCurrency': 'USD',
 'symbol': 'AAPL',
 'language': 'en-US',
 'region': 'US',
 'typeDisp': 'Equity',
 'quoteSourceName': 'Nasdaq Real Time Price',
 'triggerable': True,
 'customPriceAlertConfidence': 'HIGH',
 'exchange': 'NMS',
 'messageBoardId': 'finmb_24937',
 'exchangeTimezoneName': 'America/New_York',
 'exchangeTimezoneShortName': 'EDT',
 'gmtOffSetMilliseconds': -14400000,
 'market': 'us_market',
 'esgPopulated': False,
 'regularMarketChangePercent': -0.818469,
 'regularMarketPrice': 230.24,
 'marketState': 'REGULAR',
 'fiftyTwoWeekChangePercent': 4.206133,
 'dividendDate': 1755129600,
 'earningsTimestamp': 1753992000,
 'earningsTimestampStart': 1761854400,
 'earningsTimestampEnd': 1761854400,
 'earningsCallTimestampStart': 1753995600,
 'earningsCallTimestampEnd': 1753995600,
 'isEarningsDateEstimate': True,
 'epsTrailingTwelveMonths': 6.59,
 'epsForward': 8.31,
 'epsCurrentYear': 7.38566,
 'priceEpsCurrentYear': 31.173923,
 'fiftyDayAverageChange': 14.692398,
 'fiftyDayAverageChangePercent': 0.06816312,
 'twoHundredDayAverageChange': 9.073105,
 'twoHundredDayAverageChangePercent': 0.04102379,
 'sourceInterval': 15,
 'exchangeDataDelayedBy': 0,
 'averageAnalystRating': '2.0 - Buy',
 'cryptoTradeable': False,
 'corporateActions': [],
 'regularMarketTime': 1756823912,
 'shortName': 'Apple Inc.',
 'longName': 'Apple Inc.',
 'hasPrePostMarketData': True,
 'firstTradeDateMilliseconds': 345479400000,
 'regularMarketChange': -1.8999939,
 'regularMarketDayRange': '227.69 - 230.78',
 'fullExchangeName': 'NasdaqGS',
 'averageDailyVolume3Month': 54241479,
 'fiftyTwoWeekLowChange': 61.03,
 'fiftyTwoWeekLowChangePercent': 0.36067605,
 'fiftyTwoWeekRange': '169.21 - 260.1',
 'fiftyTwoWeekHighChange': -29.86,
 'fiftyTwoWeekHighChangePercent': -0.114801995,
 'displayName': 'Apple',
 'trailingPegRatio': 2.0954}
# Take first 10 tickers for demo
sample = df.head(10).copy()

def get_yf_info(ticker):
    try:
        t = yf.Ticker(ticker)
        info = t.info
        return {
            "longName": info.get("longName"),
            "sector": info.get("sector"),
            "industry": info.get("industry"),
            "marketCap": info.get("marketCap"),
            "exchange": info.get("exchange"),
        }
    except Exception as e:
        return {"longName": None, "sector": None, "industry": None, "marketCap": None, "exchange": None}

# Apply and expand into columns
sample_info = sample["ticker"].apply(get_yf_info).apply(pd.Series)

# Combine with SEC dataset
enriched = pd.concat([sample, sample_info], axis=1)
enriched
cik_str ticker title longName sector industry marketCap exchange
0 1045810 NVDA NVIDIA CORP NVIDIA Corporation Technology Semiconductors 4134729416704 NMS
1 789019 MSFT MICROSOFT CORP Microsoft Corporation Technology Software - Infrastructure 3749030658048 NMS
2 320193 AAPL Apple Inc. Apple Inc. Technology Consumer Electronics 3411214336000 NMS
3 1652044 GOOGL Alphabet Inc. Alphabet Inc. Communication Services Internet Content & Information 2527557582848 NMS
4 1018724 AMZN AMAZON COM INC Amazon.com, Inc. Consumer Cyclical Internet Retail 2394643234816 NMS
5 1326801 META Meta Platforms, Inc. Meta Platforms, Inc. Communication Services Internet Content & Information 1841147543552 NMS
6 1730168 AVGO Broadcom Inc. Broadcom Inc. Technology Semiconductors 1388135186432 NMS
7 1318605 TSLA Tesla, Inc. Tesla, Inc. Consumer Cyclical Auto Manufacturers 1070559133696 NMS
8 1067983 BRK-B BERKSHIRE HATHAWAY INC Berkshire Hathaway Inc. Financial Services Insurance - Diversified 1084189114368 NYQ
9 19617 JPM JPMORGAN CHASE & CO JPMorgan Chase & Co. Financial Services Banks - Diversified 819500875776 NYQ
Back to top