コード例 #1
0
def nonthreaded_get_filings():
    # create object
    print 'getting filings using a single lonely execution thread :('
    seccrawler = SecCrawler()
    date = '20170313'  # date from which filings should be downloaded
    # date = '20160922'

    count = '100'  # no of filings

    # sp_500 = open('missed_companies2.txt')

    sp_500 = open('sp_500.txt')
    lines = sp_500.readlines()
    sp_500.close()
    companies = [line.split('\t')[1:3] for line in lines[100:]]

    # OVERRIDES FOR TESTING
    # companies = [line.split('\t')[1:3] for line in lines[2:4]]
    # companies = [['AMZN', 'AMZN']]

    start = time.time()
    for companyCode, cik in companies:
        t1 = time.time()
        seccrawler.getFiling(str(companyCode), str(date), str(count), "10-K")
        # seccrawler.getFiling(str(companyCode), str(cik), str(date), str(count), "10-Q")
        # seccrawler.getFiling(str(companyCode), str(cik), str(date), str(count), "8-K")
        t2 = time.time()
        print "Total Time taken for ", companyCode, ": ", str(t2 - t1)
    end = time.time()
    print '\n\n\n FINAL TIME:'
    print end - start
コード例 #2
0
def getSingleCompanyFiling(companyCode, logPath='downloaded_companies.txt'):
    date = '20170315'  # date from which filings should be downloaded
    count = '100'  # no of filings

    seccrawler = SecCrawler()
    t1 = time.time()
    try:
        seccrawler.getFiling(str(companyCode), str(date), str(count), "10-K")
    except:
        raise Exception("".join(traceback.format_exception(*sys.exc_info())))
    # seccrawler.getFiling(str(companyCode), str(cik), str(date), str(count), "10-Q")
    # seccrawler.getFiling(str(companyCode), str(cik), str(date), str(count), "8-K")
    t2 = time.time()
    logString = "Total Time taken for " + companyCode + ": " + str(t2 - t1)
    f = open(logPath, 'a+')
    f.write(companyCode + '\n')
    f.close()
    return logString