Exemplo n.º 1
0
    def test_valid_nq_filing_with_text_report(self):
        ## Jim wants to find out the latest holdings of a fund he's
        ## invested in, the Vanguard Institutional Index Funds

        ## He searches by the trust's ticker
        cik = 'viiix'

        # The parser performs the initial search on EDGAR database
        forms = ['N-Q']
        submission_type, archives = web.get_archive_links(cik, *forms)

        # The parser looks for the most recent holdings
        holdings_statement = web.get_holding_info(archives[0])

        # With the complete submission, the parser extracts the accepted_date,
        # series / contract information, and parses the HTML to read the holdings
        # into a more useable form
        current_nq = reportnq.get_nq_report(holdings_statement[0])

        self.assertEqual(current_nq.cik, '0000862084')
        self.assertEqual(current_nq.submission_type, 'N-Q')

        # With the holdings extracted, the parser prints them into neatly
        # formatted tab-separated reports for Mim
        reportnames = current_nq.generate_report()

        ## Jim inspects the reports to make sure he has the correct info
        for reportname in reportnames:
            with open('reports/' + reportname, 'r') as report:
                reader = csv.DictReader(report, delimiter='\t')
                for row in reader:
                    self.assertIsInstance(int(row['value'].replace(',', '')), int)
                    self.assertIsInstance(int(row['shares'].replace(',', '')), int)
Exemplo n.º 2
0
    def test_valid_nq_filing_with_text_report(self):
        ## Jim wants to find out the latest holdings of a fund he's
        ## invested in, the Vanguard Institutional Index Funds

        ## He searches by the trust's ticker
        cik = 'viiix'

        # The parser performs the initial search on EDGAR database
        forms = ['N-Q']
        submission_type, archives = web.get_archive_links(cik, *forms)

        # The parser looks for the most recent holdings
        holdings_statement = web.get_holding_info(archives[0])

        # With the complete submission, the parser extracts the accepted_date,
        # series / contract information, and parses the HTML to read the holdings
        # into a more useable form
        current_nq = reportnq.get_nq_report(holdings_statement[0])

        self.assertEqual(current_nq.cik, '0000862084')
        self.assertEqual(current_nq.submission_type, 'N-Q')

        # With the holdings extracted, the parser prints them into neatly
        # formatted tab-separated reports for Mim
        series_plural = current_nq.generate_report()

        ## Jim inspects the reports to make sure he has the correct info
        for series in series_plural:
            for holding in series['holdings']:
                self.assertIsInstance(int(holding[1].replace(',', '')), int)
                self.assertIsInstance(int(holding[2].replace(',', '')), int)
Exemplo n.º 3
0
    def test_valid_13fhr_filing(self):
        ## Mary wants to find out the latest holdings of a fund she's
        ## invested in, the Bill and Melinda Gates Foundation Trust

        ## She searches by the trust's CIK number
        cik = '0001166559'

        # The parser performs the initial search on EDGAR database
        forms = ['13F-HR', '13F-HR/A']
        submission_type, archives = web.get_archive_links(cik, *forms)

        # The parser looks for the most recent holdings
        holdings_statement = web.get_holding_info(archives[0])

        # With the complete submission, the parser cuts down unnecessary info
        accepted_date, submission_type, holdings_xml = report13fhr.get_13f_xml(holdings_statement[0])

        # With all the holdings statements, the parser converts the xml
        # into a more useable form
        current_13fhr = report13fhr.get_13f_holdings(cik, accepted_date,
                                                submission_type, holdings_xml)

        self.assertEqual(current_13fhr.cik, '0001166559')
        self.assertEqual(current_13fhr.submission_type, '13F-HR')

        # With the holdings extracted, the parser prints them into a neatly
        # formatted tab-separated report for Mary
        reportnames = current_13fhr.generate_report()

        ## Mary inspects the report to make sure she has the correct info
        with open('reports/' + reportnames[0], 'r') as report:
            reader = csv.DictReader(report, delimiter='\t')
            for row in reader:
                self.assertIsInstance(int(row['value'].replace(',', '')), int)
                self.assertIsInstance(int(row['shares'].replace(',', '')), int)
Exemplo n.º 4
0
    def test_returns_holdings_info_text(self):
        urls = ['https://www.sec.gov/Archives/edgar/data/1166559/000110465916156931/0001104659-16-156931-index.htm',
                'https://www.sec.gov/Archives/edgar/data/1418814/000141881216000209/0001418812-16-000209-index.htm']

        holding_info = web.get_holding_info(*urls)
        self.assertNotEqual([], holding_info)

        for info in holding_info:
            self.assertTrue(info.startswith('<SEC-DOCUMENT>'),
                            info)
Exemplo n.º 5
0
def generate_13fhr_report(cik, forms, archives):
    # The parser looks for the most recent holdings
    holdings_statement = web.get_holding_info(archives[0])
    accepted_date, submission_type, holdings_xml = report13fhr.get_13f_xml(holdings_statement[0])

    current_13fhr = report13fhr.get_13f_holdings(cik, accepted_date,
                                            submission_type, holdings_xml)
    reportnames   = current_13fhr.generate_report()

    return reportnames
Exemplo n.º 6
0
def generate_nq_report(cik, archives):
    """generate nq report

       Requires 2 arguments cik and archives
    """
    holdings_statement = web.get_holding_info(archives[0])
    current_nq = reportnq.get_nq_report(holdings_statement[0])
    reports = current_nq.generate_report()

    return reports
Exemplo n.º 7
0
def generate_13fhr_report(cik, archives, forms=['13F-HR', '13F-HR/A', 'N-Q']):
    """generate 13fhr report

       Requires 3 arguments cik, forms, and archives
    """
    # The parser looks for the most recent holdings
    holdings_statement = web.get_holding_info(archives[0])
    accepted_date, submission_type, holdings_xml = report13fhr.get_13f_xml(
        holdings_statement[0])

    current_13fhr = report13fhr.get_13f_holdings(cik, accepted_date,
                                                 submission_type, holdings_xml)
    reportnames = current_13fhr.generate_report()

    return reportnames
Exemplo n.º 8
0
    def test_valid_13fhr_filing(self):
        ## Mary wants to find out the latest holdings of a fund she's
        ## invested in, the Bill and Melinda Gates Foundation Trust

        ## She searches by the trust's CIK number
        cik = '0001166559'

        # The parser performs the initial search on EDGAR database
        forms = ['13F-HR', '13F-HR/A']
        submission_type, archives = web.get_archive_links(cik, *forms)

        # The parser looks for the most recent holdings
        holdings_statement = web.get_holding_info(archives[0])

        # With the complete submission, the parser cuts down unnecessary info
        accepted_date, submission_type, holdings_xml = report13fhr.get_13f_xml(
            holdings_statement[0])

        # With all the holdings statements, the parser converts the xml
        # into a more useable form
        current_13fhr = report13fhr.get_13f_holdings(cik, accepted_date,
                                                     submission_type,
                                                     holdings_xml)

        self.assertEqual(current_13fhr.cik, '0001166559')
        self.assertEqual(current_13fhr.submission_type, '13F-HR')

        # With the holdings extracted, the parser prints them into a neatly
        # formatted tab-separated report for Mary
        report = io.StringIO(current_13fhr.generate_report())

        ## Mary inspects the report to make sure she has the correct info
        reader = csv.DictReader(report, delimiter='\t')
        for row in reader:
            self.assertIsInstance(int(row['value'].replace(',', '')), int)
            self.assertIsInstance(int(row['shares'].replace(',', '')), int)
Exemplo n.º 9
0
def generate_nq_report(cik, forms, archives):
    holdings_statement = web.get_holding_info(archives[0])
    current_nq         = reportnq.get_nq_report(holdings_statement[0])
    reportnames        = current_nq.generate_report()

    return reportnames