This commit is contained in:
dsyoon
2023-10-16 16:50:15 +09:00
parent fadbff0780
commit 420b1a40f1
5 changed files with 12 additions and 13 deletions

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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}")