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
- deny.toml
- examples/8k_exhibits_as_markdown.rs
- examples/8k_list.rs
- examples/cik_show.rs
- examples/company_search.rs
- examples/company_show.rs
- examples/config_show.rs
- examples/edgar_feed_poll.rs
- examples/edgar_index_browse.rs
- examples/filing_render.rs
- examples/filing_show.rs
- examples/fund_series_list.rs
- examples/holdings_show.rs
- examples/nport_render.rs
- examples/press_release_show.rs
- examples/ticker_list.rs
- examples/ticker_show.rs
- examples/us_gaap_column_stats.rs
- examples/us_gaap_search.rs
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 Program | Primary Purpose | Key Functions / Models |
|---|---|---|
config_show | Verify active configuration and credentials | ConfigManager::load, AppConfig::pretty_print |
company_search | Fuzzy-match names against the SEC ticker list | fetch_company_tickers, Ticker::get_by_fuzzy_matched_name |
company_show | Display full SEC profile and industry metadata | fetch_company_profile, fetch_company_description |
cik_show | Lookup CIK and find specific recent filings | fetch_cik_by_ticker_symbol, CikSubmission::most_recent_by_form |
8k_list | List all 8-K filings for a ticker with URLs | fetch_8k_filings, as_primary_document_url |
filing_render | Fetch and render any SEC URL to clean text | fetch_and_render, MarkdownView, EmbeddingTextView |
filing_show | Render primary documents and/or exhibits | render_filing, fetch_filings |
edgar_feed_poll | Delta-poll the live SEC Atom feed | fetch_edgar_feeds_since, FeedEntry |
edgar_index_browse | Browse historical quarterly master indexes | fetch_edgar_master_index, MasterIndexEntry |
fund_series_list | List registered mutual funds and share classes | fetch_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 Lookup and Search
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 :
- It calls
fetch_company_tickersto get the master list examples/company_search.rs49 - It tokenizes the query using
Ticker::tokenize_company_nameexamples/company_search.rs43 - It performs an exact match check before falling back to
Ticker::get_by_fuzzy_matched_nameexamples/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 :
- It fetches the CIK via
fetch_cik_by_ticker_symbolexamples/company_show.rs106 - It retrieves the core profile via
fetch_company_profileexamples/company_show.rs108 - It fetches the extended company description via
fetch_company_descriptionexamples/company_show.rs109
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_filingsto 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:
- Config Loading :
ConfigManager::load()is called to resolve environment variables and.tomlfiles examples/config_show.rs32 - Client Setup :
SecClient::from_config_manager(&config)initializes the HTTP client with required User-Agent headers and rate limiting examples/company_show.rs89 - 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