Last active
July 23, 2023 23:38
-
-
Save dharmatech/5f07fdb0a1d3ca8394c0340894358b88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function get-recent-filings ([string]$cik) | |
| { | |
| $cik_padded = $cik.PadLeft(10, '0') | |
| $result = Invoke-RestMethod "https://data.sec.gov/submissions/CIK$cik_padded.json" -Headers @{ 'User-Agent' = $SEC_GOV_USER_AGENT } | |
| for ($i = 0; $i -lt $result.filings.recent.accessionNumber.Count; $i++) | |
| { | |
| $a = $result.filings.recent.accessionNumber[$i] -replace '-', '' | |
| $b = $result.filings.recent.primaryDocument[$i] | |
| $url = "https://www.sec.gov/Archives/edgar/data/$($result.cik)/$a/$b" | |
| $primary_document_components = $result.filings.recent.primaryDocument[$i] -split '/' | |
| $c = $primary_document_components[-1] | |
| $xml = "https://www.sec.gov/Archives/edgar/data/$($result.cik)/$a/$c" | |
| [PSCustomObject]@{ | |
| accessionNumber = $result.filings.recent.accessionNumber[$i] | |
| filingDate = $result.filings.recent.filingDate[$i] | |
| reportDate = $result.filings.recent.reportDate[$i] | |
| acceptanceDateTime = $result.filings.recent.acceptanceDateTime[$i] | |
| act = $result.filings.recent.act[$i] | |
| form = $result.filings.recent.form[$i] | |
| fileNumber = $result.filings.recent.fileNumber[$i] | |
| filmNumber = $result.filings.recent.filmNumber[$i] | |
| items = $result.filings.recent.items[$i] | |
| size = $result.filings.recent.size[$i] | |
| isXBRL = $result.filings.recent.isXBRL[$i] | |
| isInlineXBRL = $result.filings.recent.isInlineXBRL[$i] | |
| primaryDocument = $result.filings.recent.primaryDocument[$i] | |
| primaryDocDescription = $result.filings.recent.primaryDocDescription[$i] | |
| xml = $xml | |
| url = $url | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment