{"id":256401,"date":"2026-09-16T14:40:36","date_gmt":"2026-09-16T18:40:36","guid":{"rendered":"https:\/\/ibkrcampus.com\/campus\/?p=256401"},"modified":"2026-09-16T14:43:34","modified_gmt":"2026-09-16T18:43:34","slug":"secfile-sec-edgar-filings-in-r-and-python","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/secfile-sec-edgar-filings-in-r-and-python\/","title":{"rendered":"secfile: SEC EDGAR Filings in R and Python"},"content":{"rendered":"\n<p class=\"has-text-align-left wp-block-paragraph\" id=\"h-secfile-sec-edgar-filings-in-r-and-python\"><strong>Open Source Quantitative Finance<\/strong><\/p>\n\n\n\n<h2 id=\"h-overview\" class=\"wp-block-heading\">Overview<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>secfile<\/strong> is a package that provides simple and efficient access to the SEC\u2019s EDGAR APIs (<a href=\"https:\/\/www.sec.gov\/search-filings\">https:\/\/www.sec.gov\/search-filings<\/a>) for querying and retrieving filings.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The core functionality of the <strong>secfile<\/strong> package abstracts the complexities of interacting with SEC EDGAR APIs, such as session management, user agent declaration, rate limiting, index parsing, pagination of filing metadata, URL construction, document caching, and inline XBRL parsing. This abstraction allows users to focus on retrieving data rather than managing API details. Use cases include retrieving data across a range of workflows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Indexes<\/strong>: master index of all filings by form type and date for universe construction<\/li>\n\n\n\n<li><strong>Tenures<\/strong>: status windows built by pairing entry and exit form filings<\/li>\n\n\n\n<li><strong>Submissions<\/strong>: filing metadata for any filer with form type and date range filters<\/li>\n\n\n\n<li><strong>Facts<\/strong>: investment-level or company-level facts extracted from inline XBRL filings<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The package supports flexible query capabilities, including customizable form types, date ranges, and dimensions, and validates the retrieved data automatically. It handles the SEC\u2019s fair access requirements, such as user agent declaration and rate limiting between requests, and caches downloaded documents for efficient retrieval of large datasets.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The implementation uses standard HTTP libraries to handle API interactions efficiently and supports both R and Python to make it accessible for a broad audience.<\/p>\n\n\n\n<h2 id=\"h-installation-in-r\" class=\"wp-block-heading\">Installation in R<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install the released version from CRAN:<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"r\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">install.packages(\"secfile\")<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Or the development version from GitHub:<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"r\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># install.packages(\"pak\")\npak::pak(\"jasonjfoster\/file\/r\")<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Then load the package:<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"r\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">library(secfile)<\/pre>\n\n\n\n<h2 id=\"h-installation-in-python\" class=\"wp-block-heading\">Installation in Python<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install the released version from PyPI:<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pip install secfile<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Or the development version from GitHub:<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pip install \\\n  git+https:\/\/github.com\/jasonjfoster\/file.git@main#subdirectory=python<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Then import the package:<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import secfile as sec<\/pre>\n\n\n\n<h2 id=\"h-available-forms\" class=\"wp-block-heading\">Available forms<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Load the package and explore the available form types using <strong>secfile::data_forms<\/strong> in R or <strong>sec.data_forms<\/strong> in Python, and the available current report (\u201c8-K\u201d) item numbers using <strong>secfile::data_items<\/strong> in R or <strong>sec.data_items<\/strong> in Python:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><td><strong>Workflows<\/strong><\/td><td><strong>Form types<\/strong><\/td><td><strong>Item numbers<\/strong><\/td><\/tr><\/thead><tbody><tr><td><strong>Indexes<\/strong><\/td><td><strong>10-K<\/strong><\/td><td><strong>1.01<\/strong><\/td><\/tr><tr><td><strong>Tenures<\/strong><\/td><td><strong>10-Q<\/strong><\/td><td><strong>1.05<\/strong><\/td><\/tr><tr><td><strong>Submissions<\/strong><\/td><td><strong>8-K<\/strong><\/td><td><strong>2.02<\/strong><\/td><\/tr><tr><td><strong>Facts<\/strong><\/td><td><strong>8-A12B<\/strong><\/td><td><strong>5.02<\/strong><\/td><\/tr><tr><td>&nbsp;<\/td><td><strong>\u22ee<\/strong><\/td><td><strong>\u22ee<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The SEC requires a user agent that declares contact information (e.g., <strong>&#8220;username@domain.com&#8221;<\/strong>) for fair access, so pass the <strong>user_agent<\/strong> argument to identify the user. Alternatively, pass <strong>session = get_session(user_agent)<\/strong> to reuse a connection across function calls.<\/p>\n\n\n\n<h2 id=\"h-usage\" class=\"wp-block-heading\">Usage<\/h2>\n\n\n\n<h3 id=\"h-get-ciks\" class=\"wp-block-heading\">Get CIKs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>secfile::get_ciks<\/strong> function in R and <strong>sec.get_ciks<\/strong> function in Python get the Central Index Key (\u201cCIK\u201d) for one or more tickers from the SEC EDGAR APIs.<\/p>\n\n\n\n<h3 id=\"h-parameters\" class=\"wp-block-heading\">Parameters<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>tickers<\/strong>: string. Ticker or vector of tickers to filter, or <strong>NULL<\/strong> (<strong>None<\/strong> in Python) for all tickers.<\/li>\n\n\n\n<li><strong>user_agent<\/strong>: string. User agent with contact information.<\/li>\n\n\n\n<li><strong>session<\/strong>: list. Session created using the <strong>get_session()<\/strong> function. When a session is provided, the <strong>user_agent<\/strong> argument is ignored.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Value<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A data frame that contains the company, CIK, and ticker for each filer.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Examples<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Company fundamentals<\/strong>: retrieve annual report filings for one or more known filers, then extract company-level facts from the inline XBRL filings.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>R<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"r\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">user_agent &lt;- \"username@domain.com\"\nciks &lt;- secfile::get_ciks(c(\"AAPL\", \"MSFT\"), user_agent = user_agent)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Python<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">user_agent = \"username@domain.com\"\nciks = sec.get_ciks([\"AAPL\", \"MSFT\"], user_agent = user_agent)<\/pre>\n\n\n\n<h2 id=\"h-get-submissions\" class=\"wp-block-heading\">Get submissions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>secfile::get_submissions<\/strong> function in R and <strong>sec.get_submissions<\/strong> function in Python get the filing metadata (\u201csubmissions\u201d) from the SEC EDGAR APIs for one or more filers with optional form type and date range filters.<\/p>\n\n\n\n<h3 id=\"h-parameters-0\" class=\"wp-block-heading\">Parameters<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ciks<\/strong>: string, numeric, or data frame. CIK or vector of CIKs, or a data frame created using <strong>get_ciks()<\/strong> or <strong>create_tenures()<\/strong> that contains a <strong>cik<\/strong> column with optional <strong>start_date<\/strong> and <strong>end_date<\/strong> columns.<\/li>\n\n\n\n<li><strong>forms<\/strong>: string. Form type or vector of form types to filter (see <strong>data_forms<\/strong>), or <strong>NULL<\/strong> (<strong>None<\/strong> in Python) for all form types.<\/li>\n\n\n\n<li><strong>from_date<\/strong>: string. Start date in \u201cYYYY-MM-DD\u201d format.<\/li>\n\n\n\n<li><strong>to_date<\/strong>: string. End date in \u201cYYYY-MM-DD\u201d format.<\/li>\n\n\n\n<li><strong>user_agent<\/strong>: string. User agent with contact information.<\/li>\n\n\n\n<li><strong>session<\/strong>: list. Session created using the <strong>get_session()<\/strong> function. When a session is provided, the <strong>user_agent<\/strong> argument is ignored.<\/li>\n<\/ul>\n\n\n\n<h3 id=\"h-value\" class=\"wp-block-heading\">Value<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A data frame that contains the filing metadata for the specified filer(s) with the archives URL for each filing.<\/p>\n\n\n\n<h3 id=\"h-examples\" class=\"wp-block-heading\">Examples<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>R<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"r\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">submissions &lt;- secfile::get_submissions(ciks, forms = \"10-K\",\n                                        from_date = \"2023-01-01\",\n                                        user_agent = user_agent)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Python<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">submissions = sec.get_submissions(ciks, forms = \"10-K\",\n                                  from_date = \"2023-01-01\",\n                                  user_agent = user_agent)<\/pre>\n\n\n\n<h2 id=\"h-get-data\" class=\"wp-block-heading\">Get data<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>secfile::get_data<\/strong> function in R and <strong>sec.get_data<\/strong> function in Python get facts from inline XBRL filings from the SEC EDGAR APIs using the specified filing metadata. By default, the result contains all contexts that match the report date of each filing and includes the period type, start and end dates, and dimension axes and members for each context.<\/p>\n\n\n\n<h3 id=\"h-parameters-1\" class=\"wp-block-heading\"><strong>Parameters<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>data<\/strong>: data frame. Filing metadata that contains the CIK, accession number, primary document, and report date for each filing created using the <strong>get_submissions()<\/strong> function.<\/li>\n\n\n\n<li><strong>dimension<\/strong>: string. Dimension of contexts to match (i.e., <strong>&#8220;typed&#8221;<\/strong>, <strong>&#8220;explicit&#8221;<\/strong>, or an axis name such as <strong>&#8220;InvestmentIdentifierAxis&#8221;<\/strong>), or <strong>NULL<\/strong> (<strong>None<\/strong> in Python) for all contexts.<\/li>\n\n\n\n<li><strong>date<\/strong>: string. Date in \u201cYYYY-MM-DD\u201d format to match context periods, or <strong>NULL<\/strong> (<strong>None<\/strong> in Python) for the report date of each filing. Instant contexts match when the instant equals the date and duration contexts match when the end date equals the date.<\/li>\n\n\n\n<li><strong>cache_dir<\/strong>: string. Directory to cache downloaded XBRL instance documents, or <strong>NULL<\/strong> (<strong>None<\/strong> in Python) to disable caching.<\/li>\n\n\n\n<li><strong>user_agent<\/strong>: string. User agent with contact information.<\/li>\n\n\n\n<li><strong>session<\/strong>: list. Session created using the <strong>get_session()<\/strong> function. When a session is provided, the <strong>user_agent<\/strong> argument is ignored.<\/li>\n<\/ul>\n\n\n\n<h3 id=\"h-value-0\" class=\"wp-block-heading\">Value<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A data frame that contains facts from the SEC EDGAR APIs for the specified filing metadata with the period type, start and end dates, and dimension axes and members for each context.<\/p>\n\n\n\n<h3 id=\"h-examples-0\" class=\"wp-block-heading\">Examples<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>R<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"r\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">data &lt;- secfile::get_data(submissions, cache_dir = \"cache\",\n                          user_agent = user_agent)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Python<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">data = sec.get_data(submissions, cache_dir = \"cache\",\n                    user_agent = user_agent)<\/pre>\n\n\n\n<h2 id=\"h-view-data\" class=\"wp-block-heading\">View data<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Company-level totals are the contexts without dimensions (i.e., the rows where <strong>axis<\/strong> is empty). Balance-sheet facts are reported for a point in time, so filter the <strong>period_type<\/strong> column to <strong>&#8220;instant&#8221;<\/strong> contexts (duration contexts carry income-statement facts instead):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>R<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"r\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">totals &lt;- data[which((data[[\"axis\"]] == \"\") &amp;\n                     (data[[\"period_type\"]] == \"instant\")), ]\nhead(totals[ , c(\"cik\", \"report_date\", \"Assets\",\n                 \"Liabilities\", \"StockholdersEquity\", ...)])<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Python<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">totals = data[(data[\"axis\"] == \"\") &amp; (data[\"period_type\"] == \"instant\")]\ntotals[[\"cik\", \"report_date\", \"Assets\",\n        \"Liabilities\", \"StockholdersEquity\", ...]].head()<\/pre>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><td><strong>cik<\/strong><\/td><td><strong>report date<\/strong><\/td><td><strong>assets (b)<\/strong><\/td><td><strong>liabilities (b)<\/strong><\/td><td><strong>equity (b)<\/strong><\/td><td><strong>\u22ef<\/strong><\/td><\/tr><\/thead><tbody><tr><td><strong>320193<\/strong><\/td><td><strong>2023-09-30<\/strong><\/td><td><strong>352.58<\/strong><\/td><td><strong>290.44<\/strong><\/td><td><strong>62.15<\/strong><\/td><td><strong>\u22ef<\/strong><\/td><\/tr><tr><td><strong>320193<\/strong><\/td><td><strong>2024-09-28<\/strong><\/td><td><strong>364.98<\/strong><\/td><td><strong>308.03<\/strong><\/td><td><strong>56.95<\/strong><\/td><td><strong>\u22ef<\/strong><\/td><\/tr><tr><td><strong>789019<\/strong><\/td><td><strong>2023-06-30<\/strong><\/td><td><strong>411.98<\/strong><\/td><td><strong>205.75<\/strong><\/td><td><strong>206.22<\/strong><\/td><td><strong>\u22ef<\/strong><\/td><\/tr><tr><td><strong>789019<\/strong><\/td><td><strong>2024-06-30<\/strong><\/td><td><strong>512.16<\/strong><\/td><td><strong>243.69<\/strong><\/td><td><strong>268.48<\/strong><\/td><td><strong>\u22ef<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 id=\"h-more-workflows-in-r\" class=\"wp-block-heading\">More workflows in R<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Each workflow defines the form types and date range, then follows the same steps to get the session and get the index, or to get the CIKs and get the submissions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Filing index<\/strong>: build a universe of filings from the master index by form type and date for bulk download or historical research.<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"r\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">session &lt;- secfile::get_session(user_agent)\nindex &lt;- secfile::get_index(from_year = 2024, to_year = 2024,\n                            forms = \"10-K\", session = session)<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Tenures<\/strong>: pair exchange listing registration (\u201c8-A12B\u201d) and removal filings to determine listing status windows for each filer and construct survivorship-bias-free universes at any date. Removals are filed by the issuer (\u201c25\u201d) or the exchange (\u201c25-NSE\u201d) and occur at any later date, so omit <strong>to_year<\/strong> to run the index through the present.<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"r\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">index &lt;- secfile::get_index(from_year = 2024,\n                            forms = c(\"8-A12B\", \"25\", \"25-NSE\"),\n                            session = session)\ntenures &lt;- secfile::create_tenures(index, \"8-A12B\", c(\"25\", \"25-NSE\"))<\/pre>\n\n\n\n<h2 id=\"h-more-workflows-in-python\" class=\"wp-block-heading\">More workflows in Python<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Each workflow defines the form types and date range, then follows the same steps to get the session and get the index, or to get the CIKs and get the submissions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Tenures<\/strong>: pair exchange listing registration (\u201c8-A12B\u201d) and removal (\u201c25\u201d and \u201c25-NSE\u201d) filings to determine listing status windows for each filer.<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">session = sec.get_session(user_agent)\nindex = sec.get_index(from_year = 2024,\n                      forms = [\"8-A12B\", \"25\", \"25-NSE\"],\n                      session = session)\ntenures = sec.create_tenures(index, \"8-A12B\", [\"25\", \"25-NSE\"])<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Event monitoring<\/strong>: track material events by retrieving current report (\u201c8-K\u201d) filing metadata for a watchlist of filers over a recent date range.<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ciks = sec.get_ciks([\"AAPL\", \"MSFT\", \"TSLA\"], user_agent = user_agent)\nsubmissions = sec.get_submissions(ciks, forms = \"8-K\",\n                                  from_date = \"2026-01-01\",\n                                  user_agent = user_agent)<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Items<\/strong>: filter the item numbers in the <strong>items<\/strong> column (see <strong>sec.data_items<\/strong>) for specific events, such as results of operations (\u201c2.02\u201d) or officer departures and appointments (\u201c5.02\u201d).<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">results = submissions[submissions[\"items\"].str.contains(\"2.02\", regex = False)]<\/pre>\n\n\n\n<h2 id=\"h-application\" class=\"wp-block-heading\">Application<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Next we use the <strong>secfile<\/strong> package to analyze how survivorship bias influences fundamental analysis of U.S. filers. A universe built from filers listed today ignores filers that were delisted along the way, so backtests inherit a selection bias toward survivors. To construct a point-in-time universe, we pair exchange listing registration (\u201c8-A12B\u201d) and removal (\u201c25\u201d and \u201c25-NSE\u201d) filings with the <strong>create_tenures<\/strong> function to determine listing status windows for each filer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We focus on the cohort of filers that listed during 2020\u20132021, a period with a large share of initial public offerings and special-purpose acquisition companies, for three reasons. First, 2021 is the largest listing year in the sample, with roughly three times the listings of each of the 2016\u20132019 cohorts. Second, the 2020 and 2021 cohorts show the highest attrition within three years of listing (with 2022 close behind). Third, the cohort is the earliest observable over its entire life with inline XBRL, which phased in between 2019 and 2021. The table below reports listings and attrition by entry year. The <strong>delisted (%)<\/strong> column is cumulative as of June 30, 2026, and attrition horizons a cohort has not yet reached are marked \u201cNA\u201d (e.g., the three-year horizon for the 2023 cohort is incomplete until the end of 2026).<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><td><strong>entry year<\/strong><\/td><td><strong>listings<\/strong><\/td><td><strong>delisted (%)<\/strong><\/td><td><strong>\u2264 1y (%)<\/strong><\/td><td><strong>\u2264 2y (%)<\/strong><\/td><td><strong>\u2264 3y (%)<\/strong><\/td><\/tr><\/thead><tbody><tr><td><strong>2016<\/strong><\/td><td><strong>438<\/strong><\/td><td><strong>75<\/strong><\/td><td><strong>32<\/strong><\/td><td><strong>38<\/strong><\/td><td><strong>49<\/strong><\/td><\/tr><tr><td><strong>2017<\/strong><\/td><td><strong>506<\/strong><\/td><td><strong>71<\/strong><\/td><td><strong>26<\/strong><\/td><td><strong>37<\/strong><\/td><td><strong>45<\/strong><\/td><\/tr><tr><td><strong>2018<\/strong><\/td><td><strong>555<\/strong><\/td><td><strong>66<\/strong><\/td><td><strong>25<\/strong><\/td><td><strong>36<\/strong><\/td><td><strong>45<\/strong><\/td><\/tr><tr><td><strong>2019<\/strong><\/td><td><strong>539<\/strong><\/td><td><strong>67<\/strong><\/td><td><strong>29<\/strong><\/td><td><strong>42<\/strong><\/td><td><strong>48<\/strong><\/td><\/tr><tr><td><strong>2020<\/strong><\/td><td><strong>826<\/strong><\/td><td><strong>70<\/strong><\/td><td><strong>31<\/strong><\/td><td><strong>45<\/strong><\/td><td><strong>56<\/strong><\/td><\/tr><tr><td><strong>2021<\/strong><\/td><td><strong>1,497<\/strong><\/td><td><strong>68<\/strong><\/td><td><strong>15<\/strong><\/td><td><strong>36<\/strong><\/td><td><strong>53<\/strong><\/td><\/tr><tr><td><strong>2022<\/strong><\/td><td><strong>549<\/strong><\/td><td><strong>61<\/strong><\/td><td><strong>25<\/strong><\/td><td><strong>41<\/strong><\/td><td><strong>52<\/strong><\/td><\/tr><tr><td><strong>2023<\/strong><\/td><td><strong>454<\/strong><\/td><td><strong>49<\/strong><\/td><td><strong>33<\/strong><\/td><td><strong>42<\/strong><\/td><td><strong>NA<\/strong><\/td><\/tr><tr><td><strong>2024<\/strong><\/td><td><strong>816<\/strong><\/td><td><strong>26<\/strong><\/td><td><strong>19<\/strong><\/td><td><strong>NA<\/strong><\/td><td><strong>NA<\/strong><\/td><\/tr><tr><td><strong>2025<\/strong><\/td><td><strong>896<\/strong><\/td><td><strong>21<\/strong><\/td><td><strong>NA<\/strong><\/td><td><strong>NA<\/strong><\/td><td><strong>NA<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">For comparison, a tally by Jay Ritter at the University of Florida also peaks in 2021 (<a href=\"https:\/\/site.warrington.ufl.edu\/ritter\/ipo-data\/\">https:\/\/site.warrington.ufl.edu\/ritter\/ipo-data\/<\/a>). It reports 413 initial public offerings in 2020 and a record 924 in 2021, with special-purpose acquisition companies accounting for more than half of each year\u2019s total. The tenure counts are higher because exchange listing registration also captures listings outside this tally, such as uplistings from over-the-counter markets, transfers between exchanges, spin-offs, and smaller offerings the tally excludes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We then retrieve annual report (\u201c10-K\u201d) filings and extract company-level facts from the inline XBRL filings to compare a fundamental metric across two universes at each quarter-end. The metric is leverage, defined as total liabilities divided by total assets from the balance-sheet facts, and the universes are cohort filers listed at that time (\u201cpoint-in-time\u201d) and cohort filers still listed as of June 30, 2026 (\u201csurvivors\u201d). Each universe uses each filer\u2019s most recent annual report within the trailing year, so membership requires both an active tenure and a report in that window. Note that the analysis uses report dates for simplicity. This assumes the facts are available at the report date rather than at the later filing date, and the assumption applies to both universes. The objective is to measure the survivorship bias in the cross-sectional estimate:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" width=\"215\" height=\"34\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/09\/image-65.png\" alt=\"Bias\" class=\"wp-image-256443 lazyload\" style=\"--smush-placeholder-width: 215px; aspect-ratio: 215\/34;width:215px;height:auto\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">where <img decoding=\"async\" width=\"14\" height=\"31\" src=\"image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAfCAMAAADgHAzdAAAAAXNSR0IArs4c6QAAAGZQTFRFAAAAAAAAAAA6AABmADqQAGa2OgAAOgA6OgBmOjqQOpC2OpDbZgAAZgA6ZgBmZjpmZrbbZrb\/kDoAkDo6kNv\/tmYAtmY6tpA6ttv\/tv\/\/25A625C22\/\/\/\/7Zm\/9uQ\/9u2\/\/+2\/\/\/bA+VZwAAAAAF0Uk5TAEDm2GYAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAZdEVYdFNvZnR3YXJlAE1pY3Jvc29mdCBPZmZpY2V\/7TVxAAAAcklEQVQoU+VPVxbAIAiD7j3stFPvf8mKFt\/rGZoPH4GQCMD\/cA8Y9P5sVRXHGUrmUwxwpeNLbXVlPN2iA8CLtUAC9QiqKgG0MI+jNa1+ncicxZ1eKFW11vxMMF+NPkH0GtPe2M1tzfwvl9DI\/c22VNBVD8XjBgRimTRGAAAAAElFTkSuQmCC\">\u00a0is the cross-sectional median of the fundamental metric at time <img decoding=\"async\" width=\"7\" height=\"31\" src=\"image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAfCAMAAAAcCScXAAAAAXNSR0IArs4c6QAAAEtQTFRFAAAAAAAAAAA6AABmADqQAGa2OgA6OgBmOpDbZgAAZpDbZrb\/kDoAkLb\/kNv\/tmYAtmY6tpBmtv\/\/25A62\/\/\/\/7Zm\/9uQ\/\/+2\/\/\/bx7BqPwAAAAF0Uk5TAEDm2GYAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAZdEVYdFNvZnR3YXJlAE1pY3Jvc29mdCBPZmZpY2V\/7TVxAAAAP0lEQVQYV2NgGHRAjF0I5CYJARYRICXOycjIyAwUkeDhBjtVjI0PTIuCpRkY+FnBlAQPh4QgL5AhzMjERdhPAHsoAcRcWhBgAAAAAElFTkSuQmCC\">. The point-in-time universe includes every cohort filer whose tenure contains time <img decoding=\"async\" width=\"7\" height=\"31\" src=\"image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAfCAMAAAAcCScXAAAAAXNSR0IArs4c6QAAAEtQTFRFAAAAAAAAAAA6AABmADqQAGa2OgA6OgBmOpDbZgAAZpDbZrb\/kDoAkLb\/kNv\/tmYAtmY6tpBmtv\/\/25A62\/\/\/\/7Zm\/9uQ\/\/+2\/\/\/bx7BqPwAAAAF0Uk5TAEDm2GYAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAZdEVYdFNvZnR3YXJlAE1pY3Jvc29mdCBPZmZpY2V\/7TVxAAAAP0lEQVQYV2NgGHRAjF0I5CYJARYRICXOycjIyAwUkeDhBjtVjI0PTIuCpRkY+FnBlAQPh4QgL5AhzMjERdhPAHsoAcRcWhBgAAAAAElFTkSuQmCC\">, regardless of subsequent delisting, while the survivor universe conditions on tenures that remain active as of June 30, 2026.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At each date, the bias is the difference in medians, where <strong>leverage<\/strong> holds the cross-section of the metric, and <strong>survivors<\/strong> and <strong>point_in_time<\/strong> index the two universes at that date:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>R<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"r\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bias &lt;- median(leverage[survivors]) - median(leverage[point_in_time])<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Python<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bias = leverage[survivors].median() - leverage[point_in_time].median()<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The two universes draw on the same facts and differ only in membership, so the bias isolates the effect of conditioning on survival rather than differences in measurement. Note that the survivor universe is observable only in hindsight because membership conditions on tenures active as of June 30, 2026, while the point-in-time universe is available at each date.<\/p>\n\n\n\n<h2 id=\"h-results\" class=\"wp-block-heading\">Results<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After the tenures and facts are combined, we compare the cross-sectional estimates over time. The chart below shows the median leverage for the point-in-time and survivor universes. The analysis provides insight into how universe construction, specifically the inclusion or exclusion of delisted filers, affects conclusions drawn from fundamental data.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"560\" height=\"280\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/09\/secfile-open-source-package.jpg\" alt=\"secfile: SEC EDGAR Filings in R and Python\" class=\"wp-image-256453 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/09\/secfile-open-source-package.jpg 560w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/09\/secfile-open-source-package-300x150.jpg 300w\" data-sizes=\"(max-width: 560px) 100vw, 560px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 560px; aspect-ratio: 560\/280;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Data source: SEC EDGAR APIs: <a href=\"https:\/\/www.sec.gov\/search-filings\">https:\/\/www.sec.gov\/search-filings<\/a><\/em><br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The survivor universe shows a higher median than the point-in-time universe from December 2021 through December 2023: the difference opens at the 2021 cohort\u2019s first annual reports and peaks at roughly 22 percentage points on September 30, 2022. The direction is the opposite of the classical expectation that distressed, highly levered filers delist: among the filers that exited, 64% had leverage below 10% at the peak, and median leverage was roughly 8% for exits versus 33% for survivors. The exits were therefore predominantly shells rather than distressed operators. In the tally above, a large share were special-purpose acquisition companies, which hold trust assets with minimal liabilities. These companies typically have about two years, plus extensions, to complete an acquisition before liquidating, a deadline that concentrated the 2021 cohort\u2019s attrition in the second and third years after listing. The two universes converge by construction once delisted filers no longer report within the trailing year. In this cohort, conditioning on surviving filers overstates the cross-sectional median because the filers that later exited had lower leverage than the survivors. The concentration of the 2021 cohort\u2019s exits in the second and third years after listing determines how large the bias becomes and how long it persists. More generally, the sign of the bias depends on where the filers that later exit sit in the leverage distribution relative to survivors.<\/p>\n\n\n\n<h2 id=\"h-conclusion\" class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>secfile<\/strong> package provides simple and efficient access to the SEC\u2019s EDGAR APIs for querying and retrieving filings. It abstracts the complexities of session management, user agent declaration, rate limiting, index parsing, pagination of filing metadata, URL construction, document caching, and inline XBRL parsing. This allows users to focus on retrieving data across a range of workflows, including indexes, tenures, submissions, and facts. The package supports flexible query capabilities, such as customizable form types, date ranges, and dimensions, and handles the SEC\u2019s fair access requirements automatically while caching downloaded documents to retrieve large datasets efficiently. It is available for both R and Python to make it accessible for a broad audience. The analysis of survivorship bias illustrates how the package can be used to construct point-in-time universes and interpret differences in fundamental estimates across universes. The workflow is available in both languages: for more examples, go to <a href=\"https:\/\/github.com\/jasonjfoster\/file\/tree\/main\/r\/examples\">https:\/\/github.com\/jasonjfoster\/file\/tree\/main\/r\/examples<\/a> for R code and <a href=\"https:\/\/github.com\/jasonjfoster\/file\/tree\/main\/python\/examples\">https:\/\/github.com\/jasonjfoster\/file\/tree\/main\/python\/examples<\/a> for Python code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>secfile is a package that provides simple and efficient access to the SEC\u2019s EDGAR APIs for querying and retrieving filings.<\/p>\n","protected":false},"author":1534,"featured_media":227240,"comment_status":"open","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[339,343,349,338,341,342],"tags":[806,4804,595,487,22157],"contributors-categories":[17926],"class_list":["post-256401","post","type-post","status-publish","format-standard","has-post-thumbnail","category-data-science","category-programing-languages","category-python-development","category-ibkr-quant-news","category-quant-development","category-r-development","tag-data-science","tag-pypi","tag-python","tag-r","tag-secfile-package","contributors-categories-jason-foster"],"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v28.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>secfile: SEC EDGAR Filings in R and Python | IBKR Quant<\/title>\n<meta name=\"description\" content=\"secfile is a package that provides simple and efficient access to the SEC\u2019s EDGAR APIs for querying and retrieving filings.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/256401\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"secfile: SEC EDGAR Filings in R and Python\" \/>\n<meta property=\"og:description\" content=\"secfile is a package that provides simple and efficient access to the SEC\u2019s EDGAR APIs for querying and retrieving filings.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/secfile-sec-edgar-filings-in-r-and-python\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-16T18:40:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-09-16T18:43:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/07\/programming-abstract-code-blue-background.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"563\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jason Foster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jason Foster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\\\/\\\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"NewsArticle\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/secfile-sec-edgar-filings-in-r-and-python\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/secfile-sec-edgar-filings-in-r-and-python\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Jason Foster\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/9ff0beaf9880732481f3c12fb84dfb93\"\n\t            },\n\t            \"headline\": \"secfile: SEC EDGAR Filings in R and Python\",\n\t            \"datePublished\": \"2026-09-16T18:40:36+00:00\",\n\t            \"dateModified\": \"2026-09-16T18:43:34+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/secfile-sec-edgar-filings-in-r-and-python\\\/\"\n\t            },\n\t            \"wordCount\": 2158,\n\t            \"commentCount\": 0,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/secfile-sec-edgar-filings-in-r-and-python\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2025\\\/07\\\/programming-abstract-code-blue-background.jpg\",\n\t            \"keywords\": [\n\t                \"Data Science\",\n\t                \"PyPi\",\n\t                \"Python\",\n\t                \"R\",\n\t                \"secfile package\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\n\t                \"Programming Languages\",\n\t                \"Python Development\",\n\t                \"Quant\",\n\t                \"Quant Development\",\n\t                \"R Development\"\n\t            ],\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"CommentAction\",\n\t                    \"name\": \"Comment\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/secfile-sec-edgar-filings-in-r-and-python\\\/#respond\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/secfile-sec-edgar-filings-in-r-and-python\\\/\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/secfile-sec-edgar-filings-in-r-and-python\\\/\",\n\t            \"name\": \"secfile: SEC EDGAR Filings in R and Python | IBKR Campus US\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/secfile-sec-edgar-filings-in-r-and-python\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/secfile-sec-edgar-filings-in-r-and-python\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2025\\\/07\\\/programming-abstract-code-blue-background.jpg\",\n\t            \"datePublished\": \"2026-09-16T18:40:36+00:00\",\n\t            \"dateModified\": \"2026-09-16T18:43:34+00:00\",\n\t            \"description\": \"secfile is a package that provides simple and efficient access to the SEC\u2019s EDGAR APIs for querying and retrieving filings.\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/secfile-sec-edgar-filings-in-r-and-python\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/secfile-sec-edgar-filings-in-r-and-python\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2025\\\/07\\\/programming-abstract-code-blue-background.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2025\\\/07\\\/programming-abstract-code-blue-background.jpg\",\n\t            \"width\": 1000,\n\t            \"height\": 563,\n\t            \"caption\": \"Programming Code Quant\"\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"name\": \"IBKR Campus US\",\n\t            \"description\": \"Financial Education from Interactive Brokers\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\",\n\t            \"name\": \"Interactive Brokers\",\n\t            \"alternateName\": \"IBKR\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\",\n\t                \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"width\": 669,\n\t                \"height\": 669,\n\t                \"caption\": \"Interactive Brokers\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\"\n\t            },\n\t            \"publishingPrinciples\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/about-ibkr-campus\\\/\",\n\t            \"ethicsPolicy\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/cyber-security-notice\\\/\"\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/9ff0beaf9880732481f3c12fb84dfb93\",\n\t            \"name\": \"Jason Foster\",\n\t            \"description\": \"Jason Foster is a director and risk manager for public and private credit portfolios at a global credit manager in New York. Previously, he was a risk manager on flagship fixed income and multi-asset portfolios at one of the world's largest asset managers. He is the author of open-source R and Python packages for analytical computation and financial data retrieval, available on CRAN and PyPI. Mr. Foster holds bachelor's degrees in mathematics and finance and a master's degree in financial engineering. https:\\\/\\\/www.linkedin.com\\\/in\\\/jasonjfoster\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/jasonfoster\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"secfile: SEC EDGAR Filings in R and Python | IBKR Quant","description":"secfile is a package that provides simple and efficient access to the SEC\u2019s EDGAR APIs for querying and retrieving filings.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/256401\/","og_locale":"en_US","og_type":"article","og_title":"secfile: SEC EDGAR Filings in R and Python","og_description":"secfile is a package that provides simple and efficient access to the SEC\u2019s EDGAR APIs for querying and retrieving filings.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/secfile-sec-edgar-filings-in-r-and-python\/","og_site_name":"IBKR Campus US","article_published_time":"2026-09-16T18:40:36+00:00","article_modified_time":"2026-09-16T18:43:34+00:00","og_image":[{"width":1000,"height":563,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/07\/programming-abstract-code-blue-background.jpg","type":"image\/jpeg"}],"author":"Jason Foster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Jason Foster","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/secfile-sec-edgar-filings-in-r-and-python\/#article","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/secfile-sec-edgar-filings-in-r-and-python\/"},"author":{"name":"Jason Foster","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/9ff0beaf9880732481f3c12fb84dfb93"},"headline":"secfile: SEC EDGAR Filings in R and Python","datePublished":"2026-09-16T18:40:36+00:00","dateModified":"2026-09-16T18:43:34+00:00","mainEntityOfPage":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/secfile-sec-edgar-filings-in-r-and-python\/"},"wordCount":2158,"commentCount":0,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/secfile-sec-edgar-filings-in-r-and-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/07\/programming-abstract-code-blue-background.jpg","keywords":["Data Science","PyPi","Python","R","secfile package"],"articleSection":["Data Science","Programming Languages","Python Development","Quant","Quant Development","R Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/secfile-sec-edgar-filings-in-r-and-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/secfile-sec-edgar-filings-in-r-and-python\/","url":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/secfile-sec-edgar-filings-in-r-and-python\/","name":"secfile: SEC EDGAR Filings in R and Python | IBKR Campus US","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/secfile-sec-edgar-filings-in-r-and-python\/#primaryimage"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/secfile-sec-edgar-filings-in-r-and-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/07\/programming-abstract-code-blue-background.jpg","datePublished":"2026-09-16T18:40:36+00:00","dateModified":"2026-09-16T18:43:34+00:00","description":"secfile is a package that provides simple and efficient access to the SEC\u2019s EDGAR APIs for querying and retrieving filings.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/secfile-sec-edgar-filings-in-r-and-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/secfile-sec-edgar-filings-in-r-and-python\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/07\/programming-abstract-code-blue-background.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/07\/programming-abstract-code-blue-background.jpg","width":1000,"height":563,"caption":"Programming Code Quant"},{"@type":"WebSite","@id":"https:\/\/ibkrcampus.com\/campus\/#website","url":"https:\/\/ibkrcampus.com\/campus\/","name":"IBKR Campus US","description":"Financial Education from Interactive Brokers","publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ibkrcampus.com\/campus\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ibkrcampus.com\/campus\/#organization","name":"Interactive Brokers","alternateName":"IBKR","url":"https:\/\/ibkrcampus.com\/campus\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","width":669,"height":669,"caption":"Interactive Brokers"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/"},"publishingPrinciples":"https:\/\/www.interactivebrokers.com\/campus\/about-ibkr-campus\/","ethicsPolicy":"https:\/\/www.interactivebrokers.com\/campus\/cyber-security-notice\/"},{"@type":"Person","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/9ff0beaf9880732481f3c12fb84dfb93","name":"Jason Foster","description":"Jason Foster is a director and risk manager for public and private credit portfolios at a global credit manager in New York. Previously, he was a risk manager on flagship fixed income and multi-asset portfolios at one of the world's largest asset managers. He is the author of open-source R and Python packages for analytical computation and financial data retrieval, available on CRAN and PyPI. Mr. Foster holds bachelor's degrees in mathematics and finance and a master's degree in financial engineering. https:\/\/www.linkedin.com\/in\/jasonjfoster\/","url":"https:\/\/www.interactivebrokers.com\/campus\/author\/jasonfoster\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/07\/programming-abstract-code-blue-background.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/256401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/users\/1534"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=256401"}],"version-history":[{"count":50,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/256401\/revisions"}],"predecessor-version":[{"id":256518,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/256401\/revisions\/256518"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/227240"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=256401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=256401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=256401"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=256401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}