Skip to main content

Crate sec_fetcher_shared

Crate sec_fetcher_shared 

Source
Expand description

Workspace-internal shared types and utilities.

Contains fiscal-period parsing, sort-rank helpers, and the canonical set of CSV column names written by the data pipeline. This crate has no external dependencies and is not published to crates.io.

§Fiscal-period sorting

The SEC’s fp field on EDGAR observations uses a variety of tokens to label fiscal periods: "Q1", "FY", "H1", "SA2", "6M", etc. parse_period_slot_token normalises all of them into a comparable integer rank so that rows can be sorted newest-first without a hardcoded lookup table.

Enums§

Period
A parsed fiscal period — either a specific year+quarter or a bare year.
PeriodSlot
Canonical period-slot categories parsed from raw fiscal-period labels.

Constants§

US_GAAP_CSV_META_COLUMNS
Ordered metadata columns present in every per-symbol US-GAAP CSV file.

Functions§

extract_first_year
Extracts the first 4-digit year (1900–2100) from a string.
normalize_fp_label
Normalises a raw SEC fp token to its canonical CSV label.
normalize_symbol
Returns the set of candidate ticker symbols that a raw input string might resolve to, normalised to uppercase and with ./- variants generated.
parse_period
Parses a raw period string into a Period.
parse_period_slot
Parses a raw fiscal-period token into a canonical PeriodSlot.
parse_period_slot_token
Returns the normalised quarter rank (1–4) for a raw fiscal-period token, or None if the token is not recognised.
parse_quarter_token
Extracts a quarter number (1–4) from tokens like "Q1", "Q3". Returns None for anything outside that range or without a Q prefix.