Skip to content

Instantly share code, notes, and snippets.

@stefanthoss
Forked from dougvk/cik_dict.py
Last active December 2, 2019 16:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanthoss/7a01372c1e4f4e2bc5ca to your computer and use it in GitHub Desktop.
Save stefanthoss/7a01372c1e4f4e2bc5ca to your computer and use it in GitHub Desktop.
(stock ticker -> CIK) dictionary using SEC EDGAR using stdout
import re
import requests
DEFAULT_TICKERS = ["BBRY", "VOD", "T", "S"]
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(requests.get(URL.format(ticker)).content.decode("ascii"))
if len(results):
cik_dict[str(ticker).lower()] = str(results[0])
print(cik_dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment