pipeline

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package pipeline is the conductor: the one place that knows the full ticker → fetch → detect → parse → project → partition → assemble sequence and returns a normalized *model.Document. Both the `get` command and (eventually) the Python wrapper drive it, so the orchestration lives here once rather than being re-implemented per surface.

Failure is partial, not total: if a statement does not project or section partitioning is low-confidence, the document still assembles with what succeeded, and the document-level confidence reflects the gap. This is the LLM-consumption stance — return the best available structured view, labeled with how much to trust it.

Index

Constants

This section is empty.

Variables

View Source
var StatementKeywords = map[string][]string{
	"income":        {"statementsofoperations", "statementsofincome"},
	"balance":       {"balancesheets", "financialposition"},
	"cashflow":      {"statementsofcashflows", "cashflow"},
	"equity":        {"stockholdersequity", "shareholdersequity"},
	"comprehensive": {"comprehensiveincome"},
}

StatementKeywords maps a statement selector to the role-URI fragments that identify that financial statement. A role matches if its URI (case-folded, punctuation removed) contains any fragment. Moved here from cmd/sec-cli so the command and the pipeline share one copy.

Functions

func CollectTables

func CollectTables(doc *html.Node) []*html.Node

CollectTables returns every <table> element in the document, in document order. It backs the `table --layout` debug surface.

func IndexFetcher

func IndexFetcher(fetch cache.FetchFunc, cik int64, filing edgar.Filing) router.Fetcher

IndexFetcher returns a router.Fetcher that resolves a filing-index document reference against EDGAR through the caching fetch. References may be absolute URLs, site-absolute paths, or filenames relative to the filing's Archives directory.

func LoadRoles

func LoadRoles(ctx context.Context, client *edgar.Client, fetch cache.FetchFunc, cik int64, filing edgar.Filing) ([]ixbrl.LinkbaseRole, error)

LoadRoles fetches a filing's presentation and label linkbases plus its schema, parses them, and returns every statement role. The directory listing comes from the EDGAR client; the linkbase and schema bytes flow through the caching fetch so a re-run serves them from the raw layer.

func Run

func Run(ctx context.Context, opts Options) (*model.Document, error)

Run executes the full pipeline and returns the assembled Document. It resolves the filing, serves an already-parsed document straight from the cache when one exists for this accession and parser version, and otherwise fetches, detects, parses, projects, partitions, assembles, and caches.

func SelectRole

func SelectRole(roles []ixbrl.LinkbaseRole, keywords []string) (ixbrl.LinkbaseRole, bool)

SelectRole returns the first non-disclosure statement role whose URI matches a keyword. Roles for disclosure details, tables, and parentheticals are skipped so a keyword resolves to the primary statement.

Types

type Options

type Options struct {
	// Ticker is the company symbol (case-insensitive).
	Ticker string
	// Form is the filing form type; empty defaults to "10-K".
	Form string
	// Year selects the filing filed in that calendar year; 0 means latest.
	// Ignored when Accession is set.
	Year int
	// Accession pins to a specific filing accession number (handles amendments).
	// When set, Year is ignored and the filing is resolved by accession instead.
	Accession string
	// Statements is the set of statement keys to project (income, balance,
	// cashflow, equity, comprehensive); empty means the default set.
	Statements []string
	// Cache is the raw+parsed cache. A nil cache behaves as a no-op (every lookup
	// misses, every write is dropped), so callers can pass nil for an uncached run.
	Cache *cache.Cache
	// Client is the EDGAR client; nil means construct one with edgar.NewClient.
	// Tests inject a fixture-backed client here.
	Client *edgar.Client
}

Options drives one pipeline run.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL