def screen(self, stock_dct):
     price = stock_dct[self.target_name].price
     code = stock_dct[self.target_name].code
     lower, upper = self.lower, self.upper
     if price < lower or price > upper:
         self.last_alert = time_str()
         send_mail(self.target_name + "(" + code + ") " + str(price))
         print("<<ALERT!!>>", self.target_name + " " + code + " " + str(price))
Exemple #2
0
 def screen(self):
     price = self.get_stock_price()
     if price < self.price_crit[0] or price > self.price_crit[1]:
         alert_date = time.localtime().tm_mday, time.localtime(
         ).tm_mon, time.localtime().tm_year
         if alert_date != self.alert_date:
             send_mail(self.name + "(" + self.code + ") " + str(price))
             print("<<ALERT!!>>",
                   self.name + " " + self.code + " " + str(price))
             self.alert_date = alert_date
Exemple #3
0
                        screen_dct[company_name].alert_date = None
                else:
                    screen_dct[company_name] = Company(company_name,
                                                       company_code,
                                                       (lower, upper))
    return screen_lst


# %%
# 장 닫히면 스크린 중지. 시작버튼 눌러야 다시 시작
company_dict = {}
screen_list = []
while True:
    if market_open():
        print("Market Open. Start Monitor")
        send_mail("Market Open. Start Monitor")
    while market_open():
        print(f"=================({time_str()})=================")
        screen_list = update_screen(company_dict)
        for company_name in screen_list:
            company_dict[company_name].screen()
        time.sleep(3 * 60)
    print("Market Closed\t", time_str())
    keep_running = input("Run Monitor?(y/n): ")
    print()
    if keep_running == "y":
        print("Start Monitor...")
        continue
    else:
        print("Program Terminated")
        break
 def screen(self, lower, upper):
     if self.price < lower or self.price > upper:
         send_mail(self.name+"("+self.code+") "+str(self.price))
         print("<<ALERT!!>>", self.name+" "+self.code+" "+str(self.price))