Skip to main content

SEC EDGAR financial statement data, local caching, screening, and valuation tools.

Project description

SecRS

SecRS is a Python toolkit for pulling SEC EDGAR financial statement data, caching it locally, and computing common equity research metrics. It works with Polars DataFrames and includes helpers for single-ticker analysis, batch statement loading, fundamental screening, spreadsheet export, and discounted cash flow valuation.

Features

  • Fetch income statements, balance sheets, cash flow statements, and filing metadata from SEC EDGAR.
  • Cache filings and parsed statement data in a local SQLite database.
  • Work with annual 10-K data or quarterly 10-Q data.
  • Compute ratios, margins, leverage, liquidity, valuation, and growth metrics.
  • Screen ticker universes with metric filters.
  • Export a ticker model to an .xlsx workbook.
  • Run a DCF model with manual or auto-derived assumptions.

Installation

This project requires Python 3.12 or newer.

pip install -e .

Or install the direct requirements first:

pip install -r requirements.txt

Quick Start

from secrs.ticker import Ticker

aapl = Ticker("AAPL")

print(aapl.info)
print(aapl.income_statement.revenue)
print(aapl.balance_sheet.total_assets)
print(aapl.cash_flow.free_cash_flow)
print(aapl.ratios)
print(aapl.margins)

Use quarterly data by passing quarterly=True:

from secrs.ticker import Ticker

msft = Ticker("MSFT", quarterly=True)
print(msft.income_statement.data)

Force a refresh of cached statement data:

from secrs.ticker import Ticker

nvda = Ticker("NVDA", force_refresh=True)
print(nvda.cash_flow.data)

Batch Statements

Tickers provides convenience methods for loading multiple companies into one DataFrame.

from secrs.ticker import Tickers

tickers = Tickers()

income = tickers.get_income_statements(["AAPL", "MSFT", "GOOG"], pivot=True)
balance = tickers.get_balance_sheets(["AAPL", "MSFT", "GOOG"], pivot=True)
cash_flow = tickers.get_cash_flows(["AAPL", "MSFT", "GOOG"], pivot=True)

print(income)
print(balance)
print(cash_flow)

Screening

Use Screener or screen_tickers to filter a list of tickers by computed metrics.

from secrs.screener import screen_tickers

results = screen_tickers(
    ["AAPL", "MSFT", "GOOG", "NVDA"],
    pe_ratio=("<", 35),
    gross_margin=(">", 0.40),
    revenue_growth=(">", 0.05),
    include_metrics=["market_cap", "enterprise_value", "current_ratio"],
)

print(results)

Supported filter operators are <, <=, >, >=, ==, and !=.

Common metric groups include:

  • Ratios: pe_ratio, ps_ratio, pb_ratio, pfcf_ratio
  • Margins: gross_margin, operating_margin, net_margin, fcf_margin, roa, roe, roic
  • Leverage: debt_to_equity, debt_to_assets, net_debt_to_ebitda, interest_coverage
  • Liquidity: current_ratio, quick_ratio, cash_ratio, net_cash, net_cash_per_share
  • Valuation: market_cap, enterprise_value, ev_sales_ratio, ev_ebitda_ratio, ev_fcf_ratio
  • Growth: revenue_growth, gross_profit_growth, operating_income_growth, net_income_growth, eps_growth, fcf_growth

DCF Valuation

from secrs.dcf import dcf

result = dcf(
    "AAPL",
    discount_rate=0.10,
    terminal_growth_rate=0.03,
    forecast_years=5,
)

print(result.intrinsic_value_per_share)
print(result.enterprise_value)
print(result.projections)
print(result.assumptions)
print(result.warnings)

Auto mode derives assumptions from available fundamentals and market data:

from secrs.dcf import dcf

result = dcf("MSFT", auto=True)
print(result)

Revenue Segments

SecRS can parse inline XBRL filings for revenue by segment.

from secrs.ticker import Ticker

aapl = Ticker("AAPL")
segments = aapl.segments(start_date="2020-01-01")

print(segments)

Spreadsheet Export

from secrs.ticker import Ticker

model = Ticker("AAPL")
path = model.export_to_spreadsheet("aapl_model.xlsx")

print(path)

Data Storage

SecRS stores parsed data in a local SQLite database and saves downloaded filing text under a local data directory.

Default locations are platform-specific:

  • Database: user config directory, under secrs/secrs.db
  • Filing data: user data directory, under secrs/filings

Override paths with environment variables:

export SECRS_DB=/path/to/secrs.db
export SECRS_DATA_DIR=/path/to/secrs-data

Data Sources

SecRS uses SEC EDGAR for company filings and statement data. Market prices and company information are fetched through Yahoo Finance-backed dependencies (yahoors and yfinance). Network calls are cached where the project has local caching support, but external services can still rate-limit, change response formats, or return incomplete data.

Project Layout

secrs/
  ticker.py                 Single and batch ticker APIs
  screener.py               Fundamental screening
  dcf.py                    Discounted cash flow valuation
  modules/                  Statement, ratio, margin, liquidity, leverage, valuation logic
  periphery/                SEC metadata, filing parsing, candles, spreadsheet export
  data/                     SQLite initialization and path configuration
  utils/                    Fetching, formatting, dates, metrics, constants

Notes

  • Returned tables are Polars DataFrames.
  • First runs can be slower because filings and market data need to be downloaded.
  • SEC concepts vary by company and filing. Some metrics may be null when a company does not report the required concept or reports it under an unsupported tag.
  • This package is for research workflows and does not provide investment advice.

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

secrs-0.1.0.tar.gz (58.1 kB view details)

Uploaded Source

Built Distribution

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

secrs-0.1.0-py3-none-any.whl (69.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for secrs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 095fe949ead5e3bcffba09c80e8361297bdc8369f9f60c3ad4323fc6a6bc2595
MD5 700241f8053a1a6247183767b942e9df
BLAKE2b-256 c0599d565eee445a864b91234e54eec962b3b98c78ad9b3c24eb221ba8a725a8

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for secrs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d223c2f36258670616930b141740ae9a11131ecf011d0364fb8447bd8ab090b
MD5 0cfac2c544a98be27b08f98d23dc6974
BLAKE2b-256 a9df2dd2e347ade647f996237ff70b6782c9eff1e78b480ed0ae97a05ab7af1b

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