def main():
	tday = datetime.today()
	t_now = datetime.now()

	df = read_cmitem("OSPG Config.SINGAPORE.RateChart")

	tmr = datetime.today()+timedelta(days=1)
	dstr = tmr.strftime("%Y%m%d")

	df_official = calcOfficial(df, tday)
	#stop at 7am Asia time to restart and roll official
	while True:
		if t_now < datetime.strptime(dstr+"8", "%Y%m%d%H"):
			logger.info("started")
			dfreport = concat([df['Quote'], calcLIVE(df), df_official],axis=1)
			dfreport["Change"] = dfreport["LIVE"] - dfreport["OFFICIAL"]
			dfreport["Change"] = dfreport["Change"]

			#sending email
			ts = datetime.strftime(datetime.now(), "%d/%m/%Y %H:%M:%S")
			sender="*****@*****.**"
			to = ['*****@*****.**','*****@*****.**','*****@*****.**']
			#to = ['*****@*****.**']
			cc=['*****@*****.**']
			html = reporthtml(dfreport, ts)
			open(r"D:\log.html", "w").write(html)
			sendemail(html, sender, to, cc, "PriceChangeSnapshot", ts, [])
		else:
			tday = datetime.today()
			if tday.weekday()!=5 or tday.weekday()!=6:
				tmr = datetime.today()+timedelta(days=1)
				dstr = tmr.strftime("%Y%m%d")
				df_official = calcOfficial(df, tday)

		#loop
		time.sleep(15*60)
		t_now = datetime.now()
Ejemplo n.º 2
0
	tday = datetime.today()
	t_now = datetime.now()

	df = read_cmitem("OSPG Config.SINGAPORE.RateChart2")

	tmr = datetime.today()+timedelta(days=1)
	dstr = tmr.strftime("%Y%m%d")

	df_official = calcOfficial(df, tday)
	#stop at 7am Asia time to restart and roll official
	while t_now < datetime.strptime(dstr+"7", "%Y%m%d%H"):
		print(t_now)
		dfreport = concat([df['Quote'], calcLIVE(df), df_official],axis=1)
		dfreport["Change"] = dfreport["LIVE"] - dfreport["OFFICIAL"]
		dfreport["Change"] = dfreport["Change"]

		#sending email
		ts = datetime.strftime(datetime.now(), "%d/%m/%Y %H:%M:%S")
		sender="*****@*****.**"
		#to = ['*****@*****.**','*****@*****.**','*****@*****.**']
		to = ['*****@*****.**']
		cc=['*****@*****.**']
		html = reporthtml(dfreport, ts)
		open(r"D:\log.html", "w").write(html)
		sendemail(html, sender, to, cc, "PriceChangeSnapshot", ts, [])


		#loop
		time.sleep(15*60)
		t_now = datetime.now()