Example #1
0
def get_filings(companyCode, date='20200101', cik=None, count=100):
    if cik is None:
        with open('company_list.txt', 'r') as f:
            for line in f:
                if companyCode in line:
                    line_arr = line.rstrip().split(' ')
                    cik = line_arr[-1]

    if cik is None:
        print("cik not provided and not found in list. please try again.")
        return

    # create object
    seccrawler = SecCrawler()
    seccrawler.filing_10K(str(companyCode), str(cik), str(date), str(count))

    dest_dir = companyCode + "/"
    src_dir = dest_dir + cik + "/10-K/"
    years_downloaded = []

    for old_filename in os.listdir(src_dir):
        parts = old_filename.split('-')
        old_year = parts[1]
        if int(old_year) > 50:
            new_year = '19' + old_year
        else:
            new_year = '20' + old_year

        years_downloaded.append(new_year)
        os.rename(src_dir + old_filename, dest_dir + companyCode + '_10K_' + new_year + '.txt')

    shutil.rmtree(dest_dir + cik + '/')

    # create object
    seccrawler = SecCrawler()
    seccrawler.filing_10Q(str(companyCode), str(cik), str(date), str(count))

    dest_dir = companyCode + "/"
    src_dir = dest_dir + cik + "/10-Q/"
    years_downloaded = []

    for old_filename in os.listdir(src_dir):
        parts = old_filename.split('-')
        old_year = parts[1]
        if int(old_year) > 20:
            new_year = '19' + old_year
        else:
            new_year = '20' + old_year

        years_downloaded.append(new_year)
        os.rename(src_dir + old_filename, dest_dir + companyCode + '_10Q_' + new_year + '.txt')

    shutil.rmtree(dest_dir + cik + '/')
    return years_downloaded
Example #2
0
def get_filings(cik, ticker):
    t1 = time.time()

    # create object
    seccrawler = SecCrawler()

    companyCode = ticker
    cik = cik
    date = '20170101'
    count = '10'

    seccrawler.filing_10K(str(companyCode), str(cik), str(date), str(count))

    t2 = time.time()
    print("Total Time taken: "),
    print(t2 - t1)
Example #3
0
def get_filings(cik, ticker):
    t1 = time.time()

    # create object
    seccrawler = SecCrawler()

    companyCode = ticker  # company code for apple
    cik = cik  # cik code for apple
    date = '20170101'  # date from which filings should be downloaded
    count = '10'  # no of filings

    seccrawler.filing_10K(str(companyCode), str(cik), str(date), str(count))

    t2 = time.time()
    print("Total Time taken: "),
    print(t2 - t1)
Example #4
0
def getfilings():
    t1 = time.time()

    # create object
    seccrawler = SecCrawler()

    companyCode = 'AAPL'  # compnay ticker symbol for Apple
    cik = '0000320193'  # cik code for Apple
    date = '20010101'  # date from which filings should be downloaded (01/01/2001 in this case)
    count = '10'  # the number of filings

    seccrawler.filing_10Q(str(companyCode), str(cik), str(date), str(count))
    seccrawler.filing_10K(str(companyCode), str(cik), str(date), str(count))
    seccrawler.filing_8K(str(companyCode), str(cik), str(date), str(count))
    seccrawler.filing_13F(str(companyCode), str(cik), str(date), str(count))

    t2 = time.time()
    print("Total time taken: ")
    print(t2 - t1)
Example #5
0
 def get_all_filings(self, deadline):
     ''' get the SEC filings for all companies in US stock universe'''
     t1 = time.time()
  
     # create object
     seccrawler = SecCrawler()
  
     companyCode = 'AAPL'    # company code for apple 
     cik = '0000320193'      # cik code for apple
     date = '20160101'       # date from which filings should be downloaded
     count = '100'            # no of filings
  
     seccrawler.filing_10Q(str(companyCode), str(cik), str(date), str(count))
     seccrawler.filing_10K(str(companyCode), str(cik), str(date), str(count))
     seccrawler.filing_8K(str(companyCode), str(cik), str(date), str(count))
     seccrawler.filing_13F(str(companyCode), str(cik), str(date), str(count))
  
     t2 = time.time()
     print "Total Time taken: " + str(t2-t1),
Example #6
0
def get_filings():
    t1 = time.time()

    # create object
    seccrawler = SecCrawler()

    companyCode = "AAPL"  # company code for apple
    cik = "0000320193"  # cik code for apple
    date = "20010101"  # date from which filings should be downloaded
    count = "10"  # no of filings

    seccrawler.filing_10Q(str(companyCode), str(cik), str(date), str(count))
    seccrawler.filing_10K(str(companyCode), str(cik), str(date), str(count))
    seccrawler.filing_8K(str(companyCode), str(cik), str(date), str(count))
    seccrawler.filing_13F(str(companyCode), str(cik), str(date), str(count))

    t2 = time.time()
    print
    "Total Time taken: ",
    print(t2 - t1)
Example #7
0
def get_filings():
    t1 = time.time()

    DEFAULT_DATA_PATH = os.path.join(os.path.abspath(os.getcwd()), 'output')

    # create object
    seccrawler = SecCrawler()

    companyCode = 'AAPL'  # company code for apple
    cik = '0000320193'  # cik code for apple
    date = '20010101'  # date from which filings should be downloaded
    count = '10'  # no of filings

    seccrawler.filing_10Q(str(companyCode), str(cik), str(date), str(count))
    seccrawler.filing_10K(str(companyCode), str(cik), str(date), str(count))
    seccrawler.filing_8K(str(companyCode), str(cik), str(date), str(count))
    seccrawler.filing_13F(str(companyCode), str(cik), str(date), str(count))

    t2 = time.time()
    print("Total Time taken: "),
    print(t2 - t1)
Example #8
0
def get_filings(): 
t1 = time.time() 

# create object 
seccrawler = SecCrawler() 

companyCode = 'AAPL' # company code for apple 
cik = '0000320193' # cik code for apple 
date = '20010101' # date from which filings should be downloaded 
count = '10' # no of filings 

seccrawler.filing_10Q(str(companyCode), str(cik), str(date), str(count)) 
seccrawler.filing_10K(str(companyCode), str(cik), str(date), str(count)) 
seccrawler.filing_8K(str(companyCode), str(cik), str(date), str(count)) 
seccrawler.filing_13F(str(companyCode), str(cik), str(date), str(count)) 

t2 = time.time() 
print "Total Time taken: ", 
print (t2-t1) 

if __name__ == '__main__': 
get_filings()	
Example #9
0
"""
#%%
import re
from SECEdgar.crawler import SecCrawler
#%% GEt names of companies

sector_code = '10'

list_companies = []
with open('tic_company_gics.txt') as file:
    for line in file:
        sector = line[-3:-1]
        if sector == sector_code:
            name_company = re.search('[\w\.]+', line).group()#[:-1]
            list_companies.append(name_company)
            
list_companies = list(set(list(list_companies)))
        

        
#%%  Download the 10K
number_of_companies = 50
date_retrieve = '20150101'
number_10K = 5

secCrawler = SecCrawler()

for company in list_companies[0:number_of_companies]:
    secCrawler.filing_10K(company, date_retrieve, number_10K)

Example #10
0
    cik = ''
    results = CIK_RE.findall(get(URL.format(name)).content)
    if len(results):
        cik = str(results[0])
    
    return cik

list_companies = []
with open('tic_company_gics.txt') as file:
    for line in file:
        sector = line[-3:-1]
        if sector == sector_code:
            name_company = re.search('[\w\.]+', line).group()#[:-1]
            list_companies.append(name_company)
            
list_companies = list(set(list(list_companies)))
#%% GEt SIC code for each company
list_companies_cik = []

for company in list_companies:
    cik = get_cik(company)
    if len(cik) > 0:
        list_companies_cik.append((company, cik))
        
#%% Get 10K

secCrawler = SecCrawler()

for name, cik in list_companies_cik:
    secCrawler.filing_10K(name, cik, '20150101', '1')