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.

Running Examples

Loading…

Running Examples

Relevant source files

This page demonstrates how to run the example programs included in the rust-sec-fetcher repository. These programs illustrate the library’s capabilities, ranging from simple company lookups to complex filing rendering and EDGAR feed polling.

Example Programs Overview

The repository includes a variety of example programs in the examples/ directory. These serve as functional documentation for the system’s core modules.

Example ProgramPrimary PurposeKey Functions / Models
config_showVerify active configuration and credentialsConfigManager::load, AppConfig::pretty_print
company_searchFuzzy-match names against the SEC ticker listfetch_company_tickers, Ticker::get_by_fuzzy_matched_name
company_showDisplay full SEC profile and industry metadatafetch_company_profile, fetch_company_description
cik_showLookup CIK and find specific recent filingsfetch_cik_by_ticker_symbol, CikSubmission::most_recent_by_form
8k_listList all 8-K filings for a ticker with URLsfetch_8k_filings, as_primary_document_url
filing_renderFetch and render any SEC URL to clean textfetch_and_render, MarkdownView, EmbeddingTextView
filing_showRender primary documents and/or exhibitsrender_filing, fetch_filings
edgar_feed_pollDelta-poll the live SEC Atom feedfetch_edgar_feeds_since, FeedEntry
edgar_index_browseBrowse historical quarterly master indexesfetch_edgar_master_index, MasterIndexEntry
fund_series_listList registered mutual funds and share classesfetch_investment_company_series_and_class_dataset

Sources: examples/config_show.rs:1-12 examples/company_search.rs:1-9 examples/company_show.rs:1-14 examples/cik_show.rs:1-15 examples/8k_list.rs:1-10 examples/filing_render.rs:1-12 examples/filing_show.rs:1-7 examples/edgar_feed_poll.rs:1-36 examples/edgar_index_browse.rs:1-21 examples/fund_series_list.rs:1-14

System Integration Architecture

Diagram: Example Program Data Flow

Sources: examples/company_search.rs:46-49 examples/company_show.rs:88-109 examples/filing_render.rs:67-79 examples/edgar_feed_poll.rs:144-157

company_search: Fuzzy Matching

Purpose : Resolves ambiguous company names or ticker symbols against the official SEC ticker list using tokenization and fuzzy matching.

Usage :

Implementation :

  1. It calls fetch_company_tickers to get the master list examples/company_search.rs49
  2. It tokenizes the query using Ticker::tokenize_company_name examples/company_search.rs43
  3. It performs an exact match check before falling back to Ticker::get_by_fuzzy_matched_name examples/company_search.rs:58-78

company_show: Detailed Metadata

Purpose : Aggregates data from multiple SEC endpoints to build a comprehensive profile, including SIC codes, industry descriptions, and fiscal year details.

Usage :

Implementation :

Sources: examples/company_search.rs:1-83 examples/company_show.rs:1-150

Filing Retrieval and Rendering

filing_render: Generic URL Rendering

Purpose : Fetches any arbitrary SEC document URL and converts it to clean text using a specified FilingView.

Usage :

Implementation : The program uses fetch_and_render, passing either MarkdownView or EmbeddingTextView examples/filing_render.rs:76-79

filing_show: Smart Part Selection

Purpose : Automatically finds the most recent filing of a specific type (e.g., 10-K, 8-K) and renders the body, exhibits, or both.

Usage :

Implementation :

  • It uses fetch_filings to locate the target document examples/filing_show.rs97
  • It calls ops::render_filing, which handles the complexity of identifying “substantive” exhibits (filtering out SOX certifications, XBRL schemas, and graphics) examples/filing_show.rs115

Sources: examples/filing_render.rs:1-84 examples/filing_show.rs:1-158

Live Feeds and Historical Indexes

edgar_feed_poll: Real-time Delta Polling

Purpose : Monitors the SEC Atom feed for new filings. It supports “delta mode,” where it only shows filings strictly newer than a provided high-water mark timestamp.

Usage :

Implementation : The core logic resides in fetch_edgar_feeds_since, which handles pagination and timestamp filtering examples/edgar_feed_poll.rs157 It identifies special routes like earnings releases by checking is_earnings_release() on FeedEntry examples/edgar_feed_poll.rs84

edgar_index_browse: Historical Backfills

Purpose : Accesses the quarterly master.idx files, which contain every filing since 1993.

Usage :

Implementation : It uses fetch_edgar_master_index to download and parse the pipe-delimited index file for the requested year and quarter examples/edgar_index_browse.rs113

Sources: examples/edgar_feed_poll.rs:1-209 examples/edgar_index_browse.rs:1-186

Code Entity Mapping

Diagram: Example Program CLI to Model Mapping

Sources: examples/cik_show.rs33 examples/8k_list.rs44 examples/edgar_feed_poll.rs:119-129 examples/edgar_index_browse.rs:98-99

Execution Patterns

All examples share a standard initialization sequence:

  1. Config Loading : ConfigManager::load() is called to resolve environment variables and .toml files examples/config_show.rs32
  2. Client Setup : SecClient::from_config_manager(&config) initializes the HTTP client with required User-Agent headers and rate limiting examples/company_show.rs89
  3. Async Runtime : Examples use the #[tokio::main] attribute to manage asynchronous network calls examples/cik_show.rs30

Common CLI Pattern : Most examples use clap for argument parsing, providing consistent help menus and type validation examples/filing_show.rs:54-69

Sources: examples/config_show.rs:26-37 examples/company_show.rs:83-100 examples/cik_show.rs:30-92

Dismiss

Refresh this wiki

Enter email to refresh