Exemplo n.º 1
0
    def find_company_by_name(self, name):
        """
        Requests EDGAR for a company by name and obtains it's CIK number
        :param name: Company name
        :return: None.
        """
        if not "".__eq__(name):
            edgar = Edgar()

            try:
                company_cik = edgar.get_cik_by_company_name(name=name.upper())
                print("{0}:{1}".format(name.upper(), company_cik))
            except Exception as e:
                print("Error: ", e)
        else:
            print("No name provided (-n|-N options)")
Exemplo n.º 2
0
    def find_company_by_names_fuzzy(self, names):
        """
        Requests EDGAR for a company by name pattern to obtain a list of potentials
        :param names: A pattern for a name
        :return: None. Prints list of possible matches
        """
        if len(names) != 0:
            edgar = Edgar()
            for n in names:
                if not "".__eq__(n):
                    possible_companies = edgar.find_company_name(n)
                    for pc in possible_companies:
                        cik = edgar.get_cik_by_company_name(pc)
                        # Provide more details to help choose the right one
                        if self.aconfig['args'].edgar_company_names_fuzzy_detail:

                            print("\nName/CIK: {0}:{1}".format(pc, cik))
                            cik_feed = self.aconfig['args'].endpoint + \
                                       "/cgi-bin/browse-edgar?action=getcompany&CIK=" + \
                                       cik + "&output=atom"
                            try:
                                response = requests.get(cik_feed)
                                od = xmltodict.parse(response.content)
                                state_inc = od['feed']['company-info']['state-of-incorporation']
                                state_loc = od['feed']['company-info']['state-location']
                                print("{0:>10} : {1}/{2}".format("State Incorporated/State Located", state_inc, state_loc))

                                print("{0:>5}".format("Addresses:"))
                                for k, addresses in od['feed']['company-info']['addresses'].items():
                                    for addr in addresses:
                                        print()
                                        for k, v in addr.items():
                                            print("{0:>10} {1}".format(k,v))

                            except requests.ConnectionError as ce:
                                print("Error fetching atom feed: ", ce)
                            except xml.parsers.expat.ExpatError as xe:
                                print("Error fetching atom feed: ", xe)
                            print("---")
                        else:
                            print("{0}:{1}".format(pc, cik))

                else:
                    print("Skipping empty name")
        else:
            print("No names provided (-N option)")