def main(): """ :return: """ file_processor = FileProcessor("") db_stock_data = StockData(config['postgresql']['host'], config['postgresql']['database']) # get stock symbols from data file # pharma_stocks = file_processor.read_file("lookup_data/pharma_stocks") fortune_500_0_stocks = file_processor.read_file("lookup_data/fortune_500_0") s_p_500_data = pd.read_csv("lookup_data/s_p_500.csv", delimiter=',') s_p_500_data_stocks = s_p_500_data['stock'].tolist() stock_data_list = [] dt_utc_now = datetime.utcnow() stocks = s_p_500_data_stocks + fortune_500_0_stocks invalid_data = [] print('getting data from yahoo . . .') for stock in stocks: stock_data = get_stock_info(stock, dt_utc_now) if stock_data: stock_data_list.append(stock_data) else: invalid_data.append(stock) file_processor.save_file('data/fortune_500_0.json',str(stock_data_list)) print('adding to database . . .') for stock_data in stock_data_list: try: db_stock_data.insert_stock_data(stock_data) except Exception as ex: # todo log exception invalid_data.append(stock_data.name) continue print('invalid_data:') print(invalid_data) # ['AET', 'APC', 'ANDV', 'BHGE', 'BBT', 'BF.B', 'CA', 'CSRA', 'DWDP', 'DPS', 'EVHC', # 'ESRX', 'GGP', 'HCP', 'LLL', 'LUK', 'KORS', 'MON', 'NFX', 'PX', 'RHT', 'COL', # 'SCG', 'SYMC', 'TWX', 'TMK', 'TSS', 'WYN', 'XL'] # ['AET', 'APC', 'ANDV', 'BHGE', 'BBT', 'BF.B', 'CA', 'CSRA', 'DWDP', 'DPS', 'EVHC', # 'ESRX', 'GGP', 'HRS', 'HCP', 'LLL', 'KORS', 'MON', 'NFX', 'PX', 'RHT', 'COL', 'SCG', # 'TWX', 'TMK', 'TSS', 'WYN', 'XL', 'BRK.B', 'GD', 'JEC', 'LUK', 'MCK', 'CRM', # 'STI', 'SYMC', 'VIAB', 'MCK', 'CRM'] print('total records added: {0}'.format(len(stock_data_list)))
def non_keywords_list(): return FileProcessor.read_file('./key_words/non_keywords.jenk').split(" ")
def get_question_keywords(): return ast.literal_eval(FileProcessor.read_file('./key_words/keywords.jenk'))
def get_funny_response(): return random.choice(FileProcessor.read_file('./key_words/responses.jenk').split('|'))