This commit is contained in:
dsyoon
2023-02-03 21:46:17 +09:00
parent d27610fe67
commit 9a2fc96e42
3 changed files with 54 additions and 12 deletions

View File

@@ -476,7 +476,7 @@ class HTS:
return data
def insertStockData(self, today, stocks):
def insertStockData(self, stocks, this_day):
# 테이블 생성
self.cursor.execute("CREATE TABLE IF NOT EXISTS hts (CODE text, NAME text, ymd text, hms text, close REAL, open REAL, high REAL, low REAL, volume REAL, label INTEGER DEFAULT 0)")
@@ -486,9 +486,9 @@ class HTS:
self.cursor.execute(create_key)
for stock in stocks:
items = self.getStockInfo(stock["stock_code"], today)
idx = 0
items = self.getStockInfo(stock["stock_code"], this_day.strftime('%Y%m%d'))
for item in items:
ymd = item[0]
hms = item[1]
@@ -498,14 +498,10 @@ class HTS:
close = item[5]
volume = item[6]
idx += 1
self.cursor.execute('DELETE FROM hts WHERE CODE=? and ymd=? and hms=?', (stock["stock_code"], ymd, hms,))
self.cursor.execute("INSERT INTO hts (CODE, NAME, ymd, hms, close, open, high, low, volume) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)", (stock["stock_code"], stock["stock_name"], ymd, hms, close, open, high, low, volume))
self.conn.commit()
print("insert...", stock["stock_code"], stock["stock_name"], today)
return