Skip to content

Instantly share code, notes, and snippets.

@dougvk
Created January 19, 2014 01:40
Show Gist options
  • Save dougvk/8499335 to your computer and use it in GitHub Desktop.
Save dougvk/8499335 to your computer and use it in GitHub Desktop.
(stock ticker -> CIK) dictionary using SEC EDGAR
import re
from cPickle import dump
from requests import get
DEFAULT_TICKERS = ['goog', 'aapl']
URL = 'http://www.sec.gov/cgi-bin/browse-edgar?CIK={}&Find=Search&owner=exclude&action=getcompany'
CIK_RE = re.compile(r'.*CIK=(\d{10}).*')
cik_dict = {}
for ticker in DEFAULT_TICKERS:
results = CIK_RE.findall(get(URL.format(ticker)).content)
if len(results):
cik_dict[str(ticker).lower()] = str(results[0])
f = open('cik_dict', 'w')
dump(cik_dict, f)
f.close()
@BethTian
Copy link

It's failed today because the SEC has already changed the website

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment