Created
October 22, 2012 20:39
-
-
Save ddd1600/3934032 to your computer and use it in GitHub Desktop.
get SEC CIK number from ticker symbol
This file contains 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
getCIK = function(ticker) { | |
stopifnot(is.character(ticker)) | |
uri = "http://www.sec.gov/cgi-bin/browse-edgar" | |
response = getForm(uri,CIK=ticker,action="getcompany") | |
html = htmlParse(response) | |
CIKNode = getNodeSet(html, "//acronym[@title=\"Central Index Key\"][text() = \"CIK\"]") | |
CIKNodeText = sapply(CIKNode, function(x) xmlValue(getSibling(getSibling(x)))) | |
CIK = sub(" .*","",CIKNodeText) | |
CIK = sub("^0*","",CIK) | |
CIK | |
} | |
getCIK("AAPL") |
fyi I'm seeing things that don't match up in the Rank and Filed data http://rankandfiled.com/#/data/tickers
for instance Aloca Inc (AA) on the SEC site has cik code 1675149 but on rank and filed it's 4281. 4281 matches up with Arconic Inc (ARNC)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yes, using the mapping table they provide. Bash/awk implementation below as reference.
curl -sL https://www.sec.gov/include/ticker.txt | sort > tickercik.txt
awk '$2=="yourcik"{print $1}' tickercik.txt