Exemplo n.º 1
0
def update_db(callback=None, start=None):
	"""db script to iterate over all operating companies in our database, and update them with 
	the day's historical data."""
	ut = Utils()
	dba = Accessor()
	all_companies = ut.get_company_list()
	start = start if start else ut.yesterday()

	dba.connect()

	for symbol in all_companies:
		try:
			new_row = ut.get_historical_summary(symbol, start=start, end=ut.today())
			if callback:
				new_row = callback(new_row)
			dba.write(symbol, new_row)
			print "updated {}".format(symbol)
		except:
			print "failed on {}".format(symbol)


	dba.close()