This commit is contained in:
dsyoon
2023-10-12 23:14:19 +09:00
parent bef7240941
commit 65fbc7dc87
3 changed files with 11 additions and 11 deletions

View File

@@ -112,7 +112,7 @@ class HTS_etf(HTS):
return result
def buyRealTime(self, today, stock_code, analyzed_day=1000):
def buyRealTime(self, today, stock_code, stock_name, analyzed_day=1000):
MAX_PRICE = 20000
print("START...")
@@ -181,8 +181,8 @@ class HTS_etf(HTS):
print("TIMECHECK: %s, code: %s, buy: %d, sell: %d, avg5: %.2f, avg30: %.2f, open: %d, high: %d, low: %d, slow_k: %.2f" %
(str(THIS_TIME), stock_code, bs_buy_price, bs_sell_price, data["avg5"][0], data["avg30"][0], data["open"][0], data["high"][0], data["low"][0], data["slow_k"][0]))
if THIS_TIME.strftime("%M") == "00" or THIS_TIME.strftime("%M") == "05":
self.slackBot.post_live_to_slack(stock_code)
if int(THIS_TIME.strftime("%M")) % 9 == 0:
self.slackBot.post_live_to_slack(stock_code, stock_name)
time.sleep(60)
THIS_TIME = datetime.now()
@@ -202,14 +202,14 @@ if __name__ == "__main__":
RESOURCE_PATH = os.path.join(PROJECT_HOME, "resources")
# KODEX 인버스 * 2
stock_code = "252670"
stock_code = "122630"
stock_name = "KODEX 레버리지"
hts = HTS_etf(RESOURCE_PATH)
hts.connect2DB("hts.db")
today_str = today.strftime('%Y%m%d')
hts.buyRealTime(today_str, stock_code, analyzed_day=1000)
hts.buyRealTime(today_str, stock_code, stock_name, analyzed_day=1000)
db_filename = os.path.join(RESOURCE_PATH, "hts.db")
hts.insertStockData(today, stock_code, stock_name)

View File

@@ -113,7 +113,7 @@ class HTS_etf(HTS):
return result
def buyRealTime(self, today, stock_code, analyzed_day=1000):
def buyRealTime(self, today, stock_code, stock_name, analyzed_day=1000):
MAX_PRICE = 10000
print("START...")
@@ -182,8 +182,8 @@ class HTS_etf(HTS):
print("TIMECHECK: %s, code: %s, buy: %d, sell: %d, avg5: %.2f, avg30: %.2f, open: %d, high: %d, low: %d, slow_k: %.2f" %
(str(THIS_TIME), stock_code, bs_buy_price, bs_sell_price, data["avg5"][0], data["avg30"][0], data["open"][0], data["high"][0], data["low"][0], data["slow_k"][0]))
if THIS_TIME.strftime("%M") == "00" or THIS_TIME.strftime("%M") == "05":
self.slackBot.post_live_to_slack(stock_code)
if int(THIS_TIME.strftime("%M")) % 10 == 0:
self.slackBot.post_live_to_slack(stock_code, stock_name)
time.sleep(60)
THIS_TIME = datetime.now()
@@ -210,7 +210,7 @@ if __name__ == "__main__":
hts.connect2DB("hts.db")
today_str = today.strftime('%Y%m%d')
hts.buyRealTime(today_str, stock_code, analyzed_day=1000)
hts.buyRealTime(today_str, stock_code, stock_name, analyzed_day=1000)
db_filename = os.path.join(RESOURCE_PATH, "hts.db")
hts.insertStockData(today, stock_code, stock_name)

View File

@@ -20,10 +20,10 @@ class SlackBot:
return
def post_live_to_slack(self, stock_code):
def post_live_to_slack(self, stock_code, stock_name):
try:
this_time = datetime.now()
text = "ALIVE (" + this_time.strftime('%Y-%m-%d %H:%M:%S') + ") " + stock_code
text = "ALIVE (" + this_time.strftime('%Y-%m-%d %H:%M:%S') + ") " + stock_code + "(" + stock_name +")"
result = self.client.chat_postMessage(
channel=self.CHANNEL_ID,
text=text