diff --git a/HTS_etf_122630.py b/HTS_etf_122630.py index 4ddb0f4..9647c68 100644 --- a/HTS_etf_122630.py +++ b/HTS_etf_122630.py @@ -193,10 +193,10 @@ class HTS_etf(HTS): # 로그 출력 print("TIMECHECK: %s, code: %s, buy: %d, sell: %d, open: %d, high: %d, low: %d, macd: %.2f" % - (str(THIS_TIME), self.stock_code, bs_buy_price, bs_sell_price, data["open"][0], data["high"][0], data["low"][0], data["macd"][0])) + (str(THIS_TIME), self.stock_code, bs_buy_price, bs_sell_price, data["close"][len(data["close"])-1], data["high"][len(data["high"])-1], data["low"][len(data["low"])-1], data["macd"][len(data["macd"])-1])) if int(THIS_TIME.strftime("%M")) % 50 == 0: - self.slackBot.post_live_to_slack(self.stock_code, self.stock_name) + self.slackBot.post_live_to_slack(self.stock_code, self.stock_name, data["close"][len(data["close"])-1], data["macd"][len(data["macd"])-1]) time.sleep(60) THIS_TIME = datetime.now() diff --git a/HTS_etf_233740.py b/HTS_etf_233740.py index 3d07d76..63f286c 100644 --- a/HTS_etf_233740.py +++ b/HTS_etf_233740.py @@ -139,9 +139,9 @@ class HTS_etf(HTS): LAST_DATA = self.getLastData(self.stock_code, today) - while datetime.strptime(today + " 063000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 153100",'%Y%m%d %H%M%S'): + while datetime.strptime(today + " 063000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 223100",'%Y%m%d %H%M%S'): - if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 151500", '%Y%m%d %H%M%S'): + if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 221500", '%Y%m%d %H%M%S'): # 매도를 체크한다. self.sellStocks(self.stock_code) @@ -193,10 +193,10 @@ class HTS_etf(HTS): # 로그 출력 print("TIMECHECK: %s, code: %s, buy: %d, sell: %d, open: %d, high: %d, low: %d, macd: %.2f" % - (str(THIS_TIME), self.stock_code, bs_buy_price, bs_sell_price, data["open"][0], data["high"][0], data["low"][0], data["macd"][0])) + (str(THIS_TIME), self.stock_code, bs_buy_price, bs_sell_price, data["close"][len(data["close"])-1], data["high"][len(data["high"])-1], data["low"][len(data["low"])-1], data["macd"][len(data["macd"])-1])) if int(THIS_TIME.strftime("%M")) % 50 == 0: - self.slackBot.post_live_to_slack(self.stock_code, self.stock_name) + self.slackBot.post_live_to_slack(self.stock_code, self.stock_name, data["close"][len(data["close"])-1], data["macd"][len(data["macd"])-1]) time.sleep(60) THIS_TIME = datetime.now() diff --git a/HTS_etf_251340.py b/HTS_etf_251340.py index 048bce2..56ca0d5 100644 --- a/HTS_etf_251340.py +++ b/HTS_etf_251340.py @@ -193,10 +193,10 @@ class HTS_etf(HTS): # 로그 출력 print("TIMECHECK: %s, code: %s, buy: %d, sell: %d, open: %d, high: %d, low: %d, macd: %.2f" % - (str(THIS_TIME), self.stock_code, bs_buy_price, bs_sell_price, data["open"][0], data["high"][0], data["low"][0], data["macd"][0])) + (str(THIS_TIME), self.stock_code, bs_buy_price, bs_sell_price, data["close"][len(data["close"])-1], data["high"][len(data["high"])-1], data["low"][len(data["low"])-1], data["macd"][len(data["macd"])-1])) if int(THIS_TIME.strftime("%M")) % 50 == 0: - self.slackBot.post_live_to_slack(self.stock_code, self.stock_name) + self.slackBot.post_live_to_slack(self.stock_code, self.stock_name, data["close"][len(data["close"])-1], data["macd"][len(data["macd"])-1]) time.sleep(60) THIS_TIME = datetime.now() diff --git a/HTS_etf_252670.py b/HTS_etf_252670.py index f844402..d1d9bdb 100644 --- a/HTS_etf_252670.py +++ b/HTS_etf_252670.py @@ -194,10 +194,10 @@ class HTS_etf(HTS): # 로그 출력 print("TIMECHECK: %s, code: %s, buy: %d, sell: %d, open: %d, high: %d, low: %d, macd: %.2f" % - (str(THIS_TIME), self.stock_code, bs_buy_price, bs_sell_price, data["open"][0], data["high"][0], data["low"][0], data["macd"][0])) + (str(THIS_TIME), self.stock_code, bs_buy_price, bs_sell_price, data["close"][len(data["close"])-1], data["high"][len(data["high"])-1], data["low"][len(data["low"])-1], data["macd"][len(data["macd"])-1])) if int(THIS_TIME.strftime("%M")) % 50 == 0: - self.slackBot.post_live_to_slack(self.stock_code, self.stock_name) + self.slackBot.post_live_to_slack(self.stock_code, self.stock_name, data["close"][len(data["close"])-1], data["macd"][len(data["macd"])-1]) time.sleep(60) THIS_TIME = datetime.now() diff --git a/stock/util/SlackBot.py b/stock/util/SlackBot.py index 72c1659..58f06f7 100644 --- a/stock/util/SlackBot.py +++ b/stock/util/SlackBot.py @@ -20,15 +20,14 @@ class SlackBot: return - def post_live_to_slack(self, stock_code, stock_name): + def post_live_to_slack(self, stock_code, stock_name, close, macd): try: this_time = datetime.now() - text = "ALIVE (" + this_time.strftime('%Y-%m-%d %H:%M:%S') + ") " + stock_code + "(" + stock_name +")" + text = "ALIVE ({}, {}, {}, close: {}, macd: {:.2f}".format(this_time.strftime('%Y-%m-%d %H:%M:%S'), stock_code, stock_name, close, macd) result = self.client.chat_postMessage( channel=self.CHANNEL_ID, text=text ) - print(text) except SlackApiError as e: print(f"Error posting message: {e}")