Skip to content

Commit 97214fc

Browse files
committed
Add support for amends (e.g. 8-K/A forms)
1 parent b24b624 commit 97214fc

File tree

6 files changed

+134
-36
lines changed

6 files changed

+134
-36
lines changed

README.md

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,23 @@ metadatas = dl.get_filing_metadatas(
122122
print(metadatas)
123123
```
124124

125-
[FilingMetadata(accession_number='0000950170-23-035122',
125+
[FilingMetadata(accession_number='0000950170-24-087843',
126126
form_type='10-K',
127-
primary_doc_url='https://www.sec.gov/Archives/edgar/data/789019/000095017023035122/msft-20230630.htm',
127+
primary_doc_url='https://www.sec.gov/Archives/edgar/data/789019/000095017024087843/msft-20240630.htm',
128128
items='',
129129
primary_doc_description='10-K',
130-
filing_date='2023-07-27',
131-
report_date='2023-06-30',
130+
filing_date='2024-07-30',
131+
report_date='2024-06-30',
132132
cik='0000789019',
133133
company_name='MICROSOFT CORP',
134134
tickers=[Ticker(symbol='MSFT', exchange='Nasdaq')]),
135-
FilingMetadata(accession_number='0001564590-22-026876',
135+
FilingMetadata(accession_number='0000950170-23-035122',
136136
form_type='10-K',
137-
primary_doc_url='https://www.sec.gov/Archives/edgar/data/789019/000156459022026876/msft-10k_20220630.htm',
137+
primary_doc_url='https://www.sec.gov/Archives/edgar/data/789019/000095017023035122/msft-20230630.htm',
138138
items='',
139139
primary_doc_description='10-K',
140-
filing_date='2022-07-28',
141-
report_date='2022-06-30',
140+
filing_date='2023-07-27',
141+
report_date='2023-06-30',
142142
cik='0000789019',
143143
company_name='MICROSOFT CORP',
144144
tickers=[Ticker(symbol='MSFT', exchange='Nasdaq')])]
@@ -157,13 +157,13 @@ metadatas = dl.get_filing_metadatas("NFLX")
157157
print(metadatas)
158158
```
159159

160-
[FilingMetadata(accession_number='0001065280-23-000273',
160+
[FilingMetadata(accession_number='0001065280-24-000287',
161161
form_type='10-Q',
162-
primary_doc_url='https://www.sec.gov/Archives/edgar/data/1065280/000106528023000273/nflx-20230930.htm',
162+
primary_doc_url='https://www.sec.gov/Archives/edgar/data/1065280/000106528024000287/nflx-20240930.htm',
163163
items='',
164164
primary_doc_description='10-Q',
165-
filing_date='2023-10-20',
166-
report_date='2023-09-30',
165+
filing_date='2024-10-18',
166+
report_date='2024-09-30',
167167
cik='0001065280',
168168
company_name='NETFLIX INC',
169169
tickers=[Ticker(symbol='NFLX', exchange='Nasdaq')])]
@@ -189,7 +189,7 @@ for metadata in metadatas:
189189
break # same for all filings, let's just print the first one
190190
```
191191

192-
'<?xml version="1.0" ?><!--XBRL Document Created wi'
192+
"<?xml version='1.0' encoding='ASCII'?>\n<!--XBRL Do"
193193

194194
# Alternative implementation: Wrapper
195195

@@ -214,7 +214,7 @@ content = storage.get_file_contents()[0].content
214214
print(f"{content[:50]}...")
215215
```
216216

217-
"<?xml version='1.0' encoding='ASCII'?>\n<html xmlns..."
217+
"<?xml version='1.0' encoding='ASCII'?>\n<!--XBRL Do..."
218218

219219
Downloading multiple documents:
220220

@@ -229,10 +229,40 @@ for path, content in storage.get_file_contents():
229229
print(f"Path: {path}\nContent [len={len(content)}]: {content[:30]}...\n")
230230
```
231231

232+
('Path: sec-edgar-filings/GOOG/10-K/0001652044-25-000014/full-submission.txt\n'
233+
'Content [len=14773739]: <SEC-DOCUMENT>0001652044-25-00...\n')
232234
('Path: sec-edgar-filings/GOOG/10-K/0001652044-24-000022/full-submission.txt\n'
233235
'Content [len=13927595]: <SEC-DOCUMENT>0001652044-24-00...\n')
234-
('Path: sec-edgar-filings/GOOG/10-K/0001652044-23-000016/full-submission.txt\n'
235-
'Content [len=15264470]: <SEC-DOCUMENT>0001652044-23-00...\n')
236+
237+
``` python
238+
from sec_downloader import Downloader
239+
dl = Downloader("MyCompanyName", "my.email@domain.com")
240+
metadata = dl.get_filing_metadatas("https://www.sec.gov/Archives/edgar/data/2488/000000248825000009/0001193125-10-034401-index.htm", include_amends=True)
241+
metadata
242+
```
243+
244+
[FilingMetadata(accession_number='0000002488-25-000009', form_type='8-K', primary_doc_url='https://www.sec.gov/Archives/edgar/data/2488/000000248825000009/amd-20250204.htm', items='2.02,7.01,9.01', primary_doc_description='8-K', filing_date='2025-02-04', report_date='2025-02-04', cik='0000002488', company_name='ADVANCED MICRO DEVICES INC', tickers=[Ticker(symbol='AMD', exchange='Nasdaq')])]
245+
246+
# \# Frequently Asked Questions (FAQ)
247+
248+
#
249+
250+
# **Q: I’m encountering a ValueError stating ‘8-K/A’ forms are not supported. How can I download “8-K/A” filings?**
251+
252+
#
253+
254+
# **A:** To download amended filings such as “8-K/A”, you need to set the parameter `include_amends=True`. For example, to download [this filing](https://www.sec.gov/Archives/edgar/data/2488/000000248825000009/0001193125-10-034401-index.htm), you would use:
255+
256+
``` python
257+
from sec_downloader import Downloader
258+
dl = Downloader("MyCompanyName", "my.email@domain.com")
259+
str_cik = "0000002488"
260+
str_acc = "0001193125-10-034401"
261+
metadata = dl.get_filing_metadatas(f"{str_cik}/{str_acc}", include_amends=True)
262+
metadata
263+
```
264+
265+
[FilingMetadata(accession_number='0001193125-10-034401', form_type='8-K', primary_doc_url='https://www.sec.gov/Archives/edgar/data/2488/000119312510034401/d8ka.htm', items='5.02', primary_doc_description='FORM 8-K/A', filing_date='2010-02-19', report_date='2010-02-16', cik='0000002488', company_name='ADVANCED MICRO DEVICES INC', tickers=[Ticker(symbol='AMD', exchange='Nasdaq')])]
236266

237267
# Contributing
238268

nbs/index.ipynb

Lines changed: 76 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -222,23 +222,23 @@
222222
"name": "stdout",
223223
"output_type": "stream",
224224
"text": [
225-
"[FilingMetadata(accession_number='0000950170-23-035122',\n",
225+
"[FilingMetadata(accession_number='0000950170-24-087843',\n",
226226
" form_type='10-K',\n",
227-
" primary_doc_url='https://www.sec.gov/Archives/edgar/data/789019/000095017023035122/msft-20230630.htm',\n",
227+
" primary_doc_url='https://www.sec.gov/Archives/edgar/data/789019/000095017024087843/msft-20240630.htm',\n",
228228
" items='',\n",
229229
" primary_doc_description='10-K',\n",
230-
" filing_date='2023-07-27',\n",
231-
" report_date='2023-06-30',\n",
230+
" filing_date='2024-07-30',\n",
231+
" report_date='2024-06-30',\n",
232232
" cik='0000789019',\n",
233233
" company_name='MICROSOFT CORP',\n",
234234
" tickers=[Ticker(symbol='MSFT', exchange='Nasdaq')]),\n",
235-
" FilingMetadata(accession_number='0001564590-22-026876',\n",
235+
" FilingMetadata(accession_number='0000950170-23-035122',\n",
236236
" form_type='10-K',\n",
237-
" primary_doc_url='https://www.sec.gov/Archives/edgar/data/789019/000156459022026876/msft-10k_20220630.htm',\n",
237+
" primary_doc_url='https://www.sec.gov/Archives/edgar/data/789019/000095017023035122/msft-20230630.htm',\n",
238238
" items='',\n",
239239
" primary_doc_description='10-K',\n",
240-
" filing_date='2022-07-28',\n",
241-
" report_date='2022-06-30',\n",
240+
" filing_date='2023-07-27',\n",
241+
" report_date='2023-06-30',\n",
242242
" cik='0000789019',\n",
243243
" company_name='MICROSOFT CORP',\n",
244244
" tickers=[Ticker(symbol='MSFT', exchange='Nasdaq')])]\n"
@@ -282,13 +282,13 @@
282282
"name": "stdout",
283283
"output_type": "stream",
284284
"text": [
285-
"[FilingMetadata(accession_number='0001065280-23-000273',\n",
285+
"[FilingMetadata(accession_number='0001065280-24-000287',\n",
286286
" form_type='10-Q',\n",
287-
" primary_doc_url='https://www.sec.gov/Archives/edgar/data/1065280/000106528023000273/nflx-20230930.htm',\n",
287+
" primary_doc_url='https://www.sec.gov/Archives/edgar/data/1065280/000106528024000287/nflx-20240930.htm',\n",
288288
" items='',\n",
289289
" primary_doc_description='10-Q',\n",
290-
" filing_date='2023-10-20',\n",
291-
" report_date='2023-09-30',\n",
290+
" filing_date='2024-10-18',\n",
291+
" report_date='2024-09-30',\n",
292292
" cik='0001065280',\n",
293293
" company_name='NETFLIX INC',\n",
294294
" tickers=[Ticker(symbol='NFLX', exchange='Nasdaq')])]\n"
@@ -333,7 +333,7 @@
333333
"name": "stdout",
334334
"output_type": "stream",
335335
"text": [
336-
"'<?xml version=\"1.0\" ?><!--XBRL Document Created wi'\n"
336+
"\"<?xml version='1.0' encoding='ASCII'?>\\n<!--XBRL Do\"\n"
337337
]
338338
}
339339
],
@@ -367,7 +367,7 @@
367367
"name": "stdout",
368368
"output_type": "stream",
369369
"text": [
370-
"\"<?xml version='1.0' encoding='ASCII'?>\\n<html xmlns...\"\n"
370+
"\"<?xml version='1.0' encoding='ASCII'?>\\n<!--XBRL Do...\"\n"
371371
]
372372
}
373373
],
@@ -403,10 +403,10 @@
403403
"name": "stdout",
404404
"output_type": "stream",
405405
"text": [
406+
"('Path: sec-edgar-filings/GOOG/10-K/0001652044-25-000014/full-submission.txt\\n'\n",
407+
" 'Content [len=14773739]: <SEC-DOCUMENT>0001652044-25-00...\\n')\n",
406408
"('Path: sec-edgar-filings/GOOG/10-K/0001652044-24-000022/full-submission.txt\\n'\n",
407-
" 'Content [len=13927595]: <SEC-DOCUMENT>0001652044-24-00...\\n')\n",
408-
"('Path: sec-edgar-filings/GOOG/10-K/0001652044-23-000016/full-submission.txt\\n'\n",
409-
" 'Content [len=15264470]: <SEC-DOCUMENT>0001652044-23-00...\\n')\n"
409+
" 'Content [len=13927595]: <SEC-DOCUMENT>0001652044-24-00...\\n')\n"
410410
]
411411
}
412412
],
@@ -421,6 +421,65 @@
421421
" print(f\"Path: {path}\\nContent [len={len(content)}]: {content[:30]}...\\n\")"
422422
]
423423
},
424+
{
425+
"cell_type": "code",
426+
"execution_count": null,
427+
"metadata": {},
428+
"outputs": [
429+
{
430+
"data": {
431+
"text/plain": [
432+
"[FilingMetadata(accession_number='0000002488-25-000009', form_type='8-K', primary_doc_url='https://www.sec.gov/Archives/edgar/data/2488/000000248825000009/amd-20250204.htm', items='2.02,7.01,9.01', primary_doc_description='8-K', filing_date='2025-02-04', report_date='2025-02-04', cik='0000002488', company_name='ADVANCED MICRO DEVICES INC', tickers=[Ticker(symbol='AMD', exchange='Nasdaq')])]"
433+
]
434+
},
435+
"execution_count": null,
436+
"metadata": {},
437+
"output_type": "execute_result"
438+
}
439+
],
440+
"source": [
441+
"from sec_downloader import Downloader\n",
442+
"dl = Downloader(\"MyCompanyName\", \"my.email@domain.com\")\n",
443+
"metadata = dl.get_filing_metadatas(\"https://www.sec.gov/Archives/edgar/data/2488/000000248825000009/0001193125-10-034401-index.htm\", include_amends=True)\n",
444+
"metadata"
445+
]
446+
},
447+
{
448+
"cell_type": "markdown",
449+
"metadata": {},
450+
"source": [
451+
"# # Frequently Asked Questions (FAQ)\n",
452+
"# \n",
453+
"# **Q: I'm encountering a ValueError stating '8-K/A' forms are not supported. How can I download \"8-K/A\" filings?**\n",
454+
"# \n",
455+
"# **A:** To download amended filings such as \"8-K/A\", you need to set the parameter `include_amends=True`. For example, to download [this filing](https://www.sec.gov/Archives/edgar/data/2488/000000248825000009/0001193125-10-034401-index.htm), you would use:"
456+
]
457+
},
458+
{
459+
"cell_type": "code",
460+
"execution_count": null,
461+
"metadata": {},
462+
"outputs": [
463+
{
464+
"data": {
465+
"text/plain": [
466+
"[FilingMetadata(accession_number='0001193125-10-034401', form_type='8-K', primary_doc_url='https://www.sec.gov/Archives/edgar/data/2488/000119312510034401/d8ka.htm', items='5.02', primary_doc_description='FORM 8-K/A', filing_date='2010-02-19', report_date='2010-02-16', cik='0000002488', company_name='ADVANCED MICRO DEVICES INC', tickers=[Ticker(symbol='AMD', exchange='Nasdaq')])]"
467+
]
468+
},
469+
"execution_count": null,
470+
"metadata": {},
471+
"output_type": "execute_result"
472+
}
473+
],
474+
"source": [
475+
"from sec_downloader import Downloader\n",
476+
"dl = Downloader(\"MyCompanyName\", \"my.email@domain.com\")\n",
477+
"str_cik = \"0000002488\"\n",
478+
"str_acc = \"0001193125-10-034401\"\n",
479+
"metadata = dl.get_filing_metadatas(f\"{str_cik}/{str_acc}\", include_amends=True)\n",
480+
"metadata"
481+
]
482+
},
424483
{
425484
"cell_type": "markdown",
426485
"metadata": {},

sec_downloader/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.11.2"
1+
__version__ = "0.12.0"
22
from sec_downloader.core import Downloader
33
from sec_downloader.download_storage import DownloadStorage, FileContent
44

sec_downloader/core.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def user_agent(self):
3333
def get_filing_metadatas(
3434
self,
3535
query: Union[str, RequestedFilings, CompanyAndAccessionNumber],
36+
*,
37+
include_amends: bool = False,
3638
) -> list[FilingMetadata]:
3739
if isinstance(query, (CompanyAndAccessionNumber, str)):
3840
if isinstance(query, str):
@@ -48,6 +50,7 @@ def get_filing_metadatas(
4850
accession_number=query.accession_number,
4951
user_agent=self.user_agent,
5052
ticker_to_cik_mapping=self._ticker_to_cik_mapping,
53+
include_amends=include_amends,
5154
)
5255
]
5356

@@ -59,6 +62,7 @@ def get_filing_metadatas(
5962
requested=query,
6063
user_agent=self.user_agent,
6164
ticker_to_cik_mapping=self._ticker_to_cik_mapping,
65+
include_amends=include_amends,
6266
)
6367
return new_metadatas
6468

sec_downloader/sec_edgar_downloader_fork.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def get_filing_metadata(
2727
accession_number: str,
2828
user_agent: str,
2929
ticker_to_cik_mapping: dict[str, str],
30+
include_amends: bool = False,
3031
) -> FilingMetadata:
3132
if len(accession_number) == 18:
3233
accession_number = (
@@ -40,6 +41,7 @@ def get_filing_metadata(
4041
user_agent=user_agent,
4142
limit=1,
4243
accession_number=accession_number,
44+
include_amends=include_amends,
4345
)
4446
if len(result) == 0:
4547
raise ValueError(f"Could not find filing for {accession_number}")
@@ -52,6 +54,7 @@ def get_latest_filings_metadata(
5254
requested: RequestedFilings,
5355
user_agent: str,
5456
ticker_to_cik_mapping: dict[str, str],
57+
include_amends: bool = False,
5558
) -> list[FilingMetadata]:
5659
cik = validate_and_convert_ticker_or_cik(
5760
requested.ticker_or_cik, ticker_to_cik_mapping
@@ -80,6 +83,7 @@ def get_latest_filings_metadata(
8083
limit=limit,
8184
ticker_or_cik=requested.ticker_or_cik,
8285
form_type=requested.form_type,
86+
include_amends=include_amends,
8387
)
8488

8589

@@ -91,6 +95,7 @@ def _get_metadatas(
9195
ticker_or_cik: Optional[str] = None,
9296
accession_number: Optional[str] = None,
9397
form_type: Optional[str] = None,
98+
include_amends: bool = False,
9499
) -> list[FilingMetadata]:
95100
assert (
96101
ticker_or_cik and form_type
@@ -159,7 +164,7 @@ def _get_metadatas(
159164
if (
160165
(form_type and form_type != this_form_type)
161166
or (accession_number and accession_number != this_accession_number)
162-
or is_amend
167+
or (is_amend and not include_amends)
163168
):
164169
continue
165170

settings.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[DEFAULT]
22
repo = sec-downloader
33
lib_name = sec-downloader
4-
version = 0.11.2
4+
version = 0.12.0
55
min_python = 3.7
66
license = mit
77
black_formatting = False

0 commit comments

Comments
 (0)