init
This commit is contained in:
@@ -78,20 +78,20 @@ class HTS_Stocks (HTS):
|
||||
print ("START...")
|
||||
THIS_TIME = datetime.now()
|
||||
|
||||
today_stock = self.get_today_stock()
|
||||
|
||||
while datetime.strptime(today + " 070000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 153100", '%Y%m%d %H%M%S'):
|
||||
|
||||
# 1515 까지만 매수를 시도한다.
|
||||
if datetime.strptime(today + " 080000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 151500", '%Y%m%d %H%M%S'):
|
||||
|
||||
today_stock = self.get_today_stock()
|
||||
if len(today_stock) < 1:
|
||||
self.sellStocks()
|
||||
time.sleep(600)
|
||||
continue
|
||||
|
||||
buy_stock = []
|
||||
for idx, stock_code in enumerate(today_stock):
|
||||
for idx, stock in enumerate(today_stock):
|
||||
stock_code = stock['code']
|
||||
filename = stock['filename']
|
||||
|
||||
time.sleep(0.1)
|
||||
|
||||
@@ -120,15 +120,12 @@ class HTS_Stocks (HTS):
|
||||
# bot에 메시지를 보냄
|
||||
self.bot.sendMsg('BUY {} {} ({})'.format(stock_code, bs_buy_price, buy_count))
|
||||
|
||||
buy_stock.append( stock_code )
|
||||
arr = os.path.splitext(filename)
|
||||
os.rename(filename, arr[0]+'.[BUY]'+arr[1])
|
||||
|
||||
# 로그 출력
|
||||
print("BUY", THIS_TIME.strftime('%Y%m%d %H%M%S'), orderNum, stock_code, '', bs_buy_price, buy_count)
|
||||
|
||||
# 매수 후 제거
|
||||
for stock_code in buy_stock:
|
||||
today_stock.remove(stock_code)
|
||||
|
||||
if int(THIS_TIME.strftime("%M")) in (10, 40):
|
||||
vm = psutil.virtual_memory()
|
||||
vm_item = dict()
|
||||
@@ -147,8 +144,9 @@ class HTS_Stocks (HTS):
|
||||
return
|
||||
|
||||
def get_today_stock(self):
|
||||
today_stock = set()
|
||||
file_list = os.listdir(os.path.join(self.RESOURCE_PATH, 'analysis', '종목선택'))
|
||||
today_stock = []
|
||||
path = os.path.join(self.RESOURCE_PATH, 'analysis', '종목선택')
|
||||
file_list = os.listdir(path)
|
||||
for filename in file_list:
|
||||
# '20240130_2_daily_최적_타이밍_후보__1162_넥스틸_092790.html'
|
||||
#pattern = '([0-9]+)_[1-9]_daily_최적_타이밍_후보__[0-9]+_([ㄱ-ㅎ가-힣a-zA-Z0-9]+)_([0-9]+)\.html'
|
||||
@@ -159,9 +157,10 @@ class HTS_Stocks (HTS):
|
||||
|
||||
date_str = datetime.strptime(info.group(1), "%Y%m%d").strftime("%Y%m%d")
|
||||
if date_str == datetime.today().strftime("%Y%m%d") or date_str == (datetime.today() - timedelta(days=1)).strftime("%Y%m%d"):
|
||||
today_stock.add(info.group(2))
|
||||
stock = {'code': info.group(2), 'filename': os.path.join(path, filename)}
|
||||
today_stock.append(stock)
|
||||
|
||||
return list(today_stock)
|
||||
return today_stock
|
||||
|
||||
if __name__ == "__main__":
|
||||
today = datetime.today()
|
||||
|
||||
Reference in New Issue
Block a user