Skip to main content

Fetch company financial records from SEC EDGAR

Project description

secfin

Fetch company financial records from SEC EDGAR.

Installation

pip install secfin

Or install from source:

pip install -e .

Quick Start

from secfin import SECClient, Company

# Initialize client (SEC requires User-Agent with contact info)
client = SECClient(user_agent="MyApp contact@email.com")

# Get company financials
company = Company("AAPL", client)

# Income Statement
income = company.get_income_statement()
print(f"Revenue: {income.revenue.latest()}")
print(f"Net Income: {income.net_income.latest()}")

# Balance Sheet
balance = company.get_balance_sheet()
print(f"Total Assets: {balance.total_assets.latest()}")
print(f"Cash: {balance.cash.latest()}")

# Cash Flow Statement
cashflow = company.get_cash_flow()
print(f"Operating Cash Flow: {cashflow.operating_cash_flow.latest()}")
print(f"Free Cash Flow: {cashflow.free_cash_flow.latest()}")

Features

  • Income Statement: Revenue, Cost of Revenue, Gross Profit, Operating Income, Net Income, EPS
  • Balance Sheet: Assets, Liabilities, Equity, Cash, Inventory, Debt
  • Cash Flow: Operating, Investing, Financing cash flows, CapEx, Dividends

Data Export

Convert to pandas DataFrame:

# Get historical data as DataFrame
df = company.get_income_statement().to_dataframe()
print(df)

Get a summary of all financials:

summary = company.summary()
print(summary)

Quarterly vs Annual Data

# Annual data (10-K filings)
annual_income = company.get_income_statement(period="annual")

# Quarterly data (10-Q filings)
quarterly_income = company.get_income_statement(period="quarterly")

Earnings Dates

Get historical and estimated future earnings dates:

company = Company("AAPL", client)

# Last earnings date
last = company.last_earnings()
print(f"Last Filing: {last['date']} ({last['form_type']})")

# Next earnings (estimated)
next_e = company.next_earnings()
print(f"Next Expected: {next_e['date']} ({next_e['fiscal_quarter']})")

# Historical earnings dates
history = company.earnings_history(limit=10)
for h in history:
    print(f"{h['date']} | {h['form_type']} | {h['fiscal_quarter']}")

# Full earnings calendar
calendar = company.get_earnings_calendar()
print(f"Fiscal Year End: {calendar.fiscal_year_end}")
df = calendar.get_historical_df()

Example Output

Last Earnings:
  Filing Date: 2026-01-30
  Period End: 2025-12-27
  Form Type: 10-Q
  Quarter: Q1

Next Earnings (Estimated):
  Expected Date: 2026-04-30
  Form Type: 10-Q
  Quarter: Q2

Rate Limiting

The client automatically respects SEC's rate limit (10 requests/second).

Batch Fetching - Index Constituents

Fetch financials for entire indices:

from secfin import SECClient, BatchFetcher

client = SECClient("MyApp contact@email.com")
fetcher = BatchFetcher(client)

# Fetch all S&P 500 companies (~500 companies)
sp500_data = fetcher.fetch_sp500()

# Fetch all NASDAQ 100 companies (~100 companies)
nasdaq_data = fetcher.fetch_nasdaq100()

# Fetch custom list of tickers
tickers = ["AAPL", "MSFT", "GOOGL", "AMZN", "META"]
custom_data = fetcher.fetch_tickers(tickers)

Progress Tracking

def my_progress(current, total, ticker, status):
    print(f"Progress: {current}/{total} - {ticker}: {status}")

fetcher = BatchFetcher(client, on_progress=my_progress)
results = fetcher.fetch_nasdaq100()

Export to DataFrame

# Get summary DataFrame with key metrics
summary_df = fetcher.summary_dataframe(results)
print(summary_df)

# Get specific metric across all companies
revenue_df = fetcher.to_dataframe(results, "income_statement", "revenue")
print(revenue_df)

Available Indices

Index Method Companies
S&P 500 fetch_sp500() ~500
NASDAQ 100 fetch_nasdaq100() ~100
Russell 2000 fetch_russell2000(tickers) ~2000 (requires ticker list)

Russell 2000

Russell 2000 constituent list is not freely available. You need to provide your own list:

# Load your Russell 2000 tickers
russell_tickers = [...]  # Your list of ~2000 tickers

results = fetcher.fetch_russell2000(tickers=russell_tickers)

Requirements

  • Python 3.9+
  • requests
  • pandas

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

secfin-0.1.0.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

secfin-0.1.0-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file secfin-0.1.0.tar.gz.

File metadata

  • Download URL: secfin-0.1.0.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.1

File hashes

Hashes for secfin-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ad176d0536a026195281604f0953bc7d44dd92846a99a95467226eb4480ee1b2
MD5 04adbfa45f68475aebf7aa120ffde99d
BLAKE2b-256 43768632c22b3b0d40749e47c53b049533f1ff94f0ffbc40c6f332b9d0a7baab

See more details on using hashes here.

File details

Details for the file secfin-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: secfin-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.1

File hashes

Hashes for secfin-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b3b1ea36df69d985080bc2c31e62228abf62d37058aa914a1a05e0dbc35ced5
MD5 cb54df3454a008bb4ec58d0587fffd9b
BLAKE2b-256 016e9be613a068c8fdd6c6d1dd2b3dca6c6c7c156972a882d74e5a0ffac4ea10

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page