def __init__(self, destination_collection, db='advisor', source_collection='companies'): self.db = db self.destination_collection = destination_collection self.source_collection = source_collection self.source_connection = connect(self.db, self.source_collection) self.destination_connection = connect(self.db, self.destination_collection) self.companies = [company for company in list(self.source_connection.find({}))]
def __init__(self, source_collection, destination_collection, save_path): self.source_connection = connect('advisor', source_collection) self.destination_connection = connect('advisor', destination_collection) self.syms = list( set([ report['symbol'] for report in list(self.source_connection.find({})) ])) self.reports = [ report for report in list(self.source_connection.find({})) ] # get last report available for each company self.newest_company_reports = [ report for report in self.reports if report['_id'].split('_')[1] == str(0) ] self.rankings = [] self.save_path = save_path
def __init__(self, company): print('Updating', company) # selected company self.ticker = company[0] self.company_name = company[1] # db connection self.db = 'advisor' self.collection = 'news' self.connection = connect(self.db, self.collection) # downalod time span self.today = datetime.datetime.today self.history_start = datetime.datetime(2020, 9, 27)
def __init__(self, collection, db='advisor'): self.db = db self.collection = collection self.connection = connect(self.db, self.collection) self.companies = [ company for company in list(self.connection.find({})) ] self.updates_done = [] self.update_frequencies = { 'financial_statement': 'quarter', 'financial_ratio': 'annual', 'enterprise_value': 'quarter', 'key_metrics': 'quarter', 'financial_growth': 'quarter', 'rating': 'daily', 'discounted_cash_flow': 'daily' }
def add_new_syms(self): companies = connect(self.db, self.collection) # avoid duplicates (companies already in the database are not added again) already_inserted = [ company['_id'] for company in list(companies.find({})) ] self.new_syms = [ symbol for symbol in self.new_syms if symbol not in already_inserted ] for sym in self.new_syms: profile = self.get_company_profile(sym) obj_id = companies.insert({ '_id': profile['symbol'], 'profile': profile['profile'] })