Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

GitHub

This documentation is part of the "Projects with Books" initiative at zenOSmosis.

The source code for this project is available on GitHub.

Operations & Business Logic

Loading…

Operations & Business Logic

Relevant source files

The ops module provides high-level, orchestrated operations built on top of the lower-level network fetch functions. Each operation encapsulates multi-step workflows—such as filing index parsing, portfolio position normalization, and automated feed polling—allowing callers to work at a higher level of abstraction than raw HTTP requests.

Filing Operations

Filing operations handle the retrieval and transformation of SEC documents into human-readable or machine-learning-ready text. The primary entry point is render_filing, which coordinates fetching the primary document and its associated exhibits.

Rendering Pipeline

The rendering logic distinguishes between “substantive” exhibits (press releases, material contracts) and boilerplate (SOX certifications, auditor consents).

Sources: src/ops/filing.rs:61-84 src/ops/filing.rs:130-141

graph TD
    subgraph "ops::filing"
        RF["render_filing()"]
RE["render_exhibit_docs()"]
RED["render_exhibit_doc()"]
end

    subgraph "network::filings"
        FI["fetch_filing_index()"]
FAR["fetch_and_render()"]
end

 
   RF -->|if render_body| FAR
 
   RF -->|if render_exhibits| FI
 
   FI -->|FilingIndex| RE
 
   RE --> RED
 
   RED --> FAR
 
   FAR -->|FilingView| Output["Rendered Text"]

Key Functions and Structures

EntityRoleSource
RenderedFilingContainer for the optional body text and a Vec of RenderedExhibit.src/ops/filing.rs:20-25
render_filingHigh-level orchestrator that fetches the primary doc and substantive exhibits.src/ops/filing.rs:61-84
render_all_exhibitsVariant that skips substantive filtering to return every document in the archive.src/ops/filing.rs:92-100
fetch_filing_indexParses the EDGAR -index.htm page to find document filenames and types.src/network/filings/filing_index.rs:108-114

The FilingIndex parser uses regex to extract data from the SEC’s HTML table, identifying documents by their Seq, Description, and Type src/network/filings/filing_index.rs:23-76

Holdings Operations

Holdings operations normalize investment data from disparate SEC forms (13F for institutional managers and N-PORT for registered investment companies) into a common Position format for comparison.

Position Normalization and Diffing

The system matches positions by CUSIP and calculates weight changes. A “significant” change is defined by the WEIGHT_CHANGE_THRESHOLD (default 0.10 percentage points).

Sources: src/ops/holdings.rs:45-71 src/ops/holdings.rs:79-120

graph LR
 
   NPORT["NportInvestment"] -->|positions_from_nport| P1["Position"]
T13F["ThirteenfHolding"] -->|positions_from_13f| P2["Position"]
P1 --> DH["diff_holdings()"]
P2 --> DH
    
 
   DH -->|Result| Diff["Diff Structure"]
subgraph "Diff Results"
 
       Diff --> Added["added: Vec<Position>"]
Diff --> Removed["removed: Vec<Position>"]
Diff --> Changed["changed: Vec<(Old, New)>"]
end

Implementation Details

IPO Operations & Lifecycle

The IPO module manages the discovery and retrieval of registration statements (S-1/F-1) and their subsequent amendments (S-1/A, F-1/A).

Registration Filing Lifecycle

The system tracks companies through the registration process, starting from the initial filing through amendments to the final pricing prospectus.

Form TypeDescriptionConstant Group
S-1 / F-1Initial registration statement.FormType::IPO_REGISTRATION_FORM_TYPES
S-1/A / F-1/AAmendments responding to SEC comments.FormType::IPO_REGISTRATION_FORM_TYPES
424B4Final pricing prospectus (deal terms).FormType::IPO_PRICING_FORM_TYPES

Sources: src/ops/ipo.rs:40-43 examples/ipo_show.rs:26-32

Feed Polling and Deduplication

The get_ipo_feed_entries function provides a “delta-poll” capability. It filters the EDGAR Atom feed, which uses prefix matching (e.g., searching “S-1” returns “S-11”), to ensure exact form type matches.

Sources: src/ops/ipo.rs:83-110

graph TB
    Start["get_ipo_feed_entries()"]
Fetch["fetch_edgar_feeds_since()"]
ExactMatch{"Exact Form Match?"}
Dedup{"Seen Accession?"}
Start --> Fetch
 
   Fetch --> ExactMatch
 
   ExactMatch -->|No| Drop["Discard (e.g. S-11)"]
ExactMatch -->|Yes| Dedup
 
   Dedup -->|New| Collect["Add to Results"]
Dedup -->|Duplicate| Drop
    
 
   Collect --> HW["Update High Water Mark"]

Identity Resolution

Because pre-IPO companies lack ticker symbols, the logic supports resolution via CIK. The ipo_show example demonstrates this by prioritizing CIK lookup and falling back to ticker-based CIK discovery for companies that have already listed examples/ipo_show.rs:115-121

Sources: src/ops/ipo.rs:8-49 examples/ipo_list.rs:87-108

Dismiss

Refresh this wiki

Enter email to refresh