This commit is contained in:
dosangyoon
2022-07-29 16:45:50 +09:00
parent e339b2015a
commit afdddc8e61
1035 changed files with 47 additions and 393221 deletions

View File

@@ -520,7 +520,7 @@ class HTS:
outFp.close()
return
def getCSV(self, fileName, given_day, result):
def getCSV(self, fileName, result):
with open(fileName, 'r', encoding='utf-8') as infp:
reader = csv.reader(infp)
next(reader)
@@ -534,8 +534,6 @@ class HTS:
close = rows[5] # hts.종가
vol = rows[6] # hts.거래량
start_time = datetime.strptime(given_day + " 090000", '%Y%m%d %H%M%S')
temp = datetime.strptime(str(days) + " " + str(time).zfill(4) + "00", '%Y%m%d %H%M%S')
#if temp < start_time:
# continue
@@ -548,6 +546,32 @@ class HTS:
result["vol"].append(int(vol))
return
def getDBData(self, stock_code, lastday, result):
tableName = 'hts'
conn = sqlite3.connect(os.path.join(self.RESOURCE_PATH, "hts.db"))
cursor = conn.cursor()
cursor.execute('SELECT ymd, hms, open, high, low, close, vol FROM ' + tableName + ' WHERE CODE=? and ymd=? order by ymd, hms', (stock_code, lastday,))
db_result = cursor.fetchall()
for rows in db_result:
ymd = rows[0] # hts.날짜
hms = rows[1] # hts.시간
open = rows[2] # hts.시가
high = rows[3] # hts.고가
low = rows[4] # hts.저가
close = rows[5] # hts.종가
vol = rows[6] # hts.거래량
temp = datetime.strptime(str(ymd) + " " + str(hms).zfill(4) + "00", '%Y%m%d %H%M%S')
result["time"].append(temp)
result["open"].append(int(open))
result["close"].append(int(close))
result["high"].append(int(high))
result["low"].append(int(low))
result["vol"].append(int(vol))
return
# 주식 현재가 조회
def getRealTime(self, stock_code, lastday, today):
result = {"check": set(),
@@ -558,8 +582,9 @@ class HTS:
"low": [],
"vol": []}
last_stock_filename = os.path.join(self.RESOURCE_PATH, "hts", stock_code + "_" + lastday + ".csv")
self.getCSV(last_stock_filename, today, result)
#last_stock_filename = os.path.join(self.RESOURCE_PATH, "hts", stock_code + "_" + lastday + ".csv")
#self.getCSV(last_stock_filename, result)
self.getDBData(stock_code, lastday, result)
int_given_day = int(today)
objCpCybos = win32com.client.Dispatch("CpUtil.CpCybos")