This commit is contained in:
dsyoon
2023-10-12 22:59:30 +09:00
parent 4cd5487e6a
commit 9c6ab45d87
4 changed files with 55 additions and 53 deletions

View File

@@ -463,7 +463,7 @@ class HTS:
return data
def insertStockData(self, stock, this_day):
def insertStockData(self, this_day, stock_code, stock_name=''):
# 테이블 생성
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)")
@@ -472,7 +472,7 @@ class HTS:
create_key = "CREATE INDEX IF NOT EXISTS hts_idx on hts(CODE, ymd, hms) "
self.cursor.execute(create_key)
items = self.getStockInfo(stock["stock_code"], this_day.strftime('%Y%m%d'))
items = self.getStockInfo(stock_code, this_day.strftime('%Y%m%d'))
for item in items:
ymd = item[0]
@@ -483,8 +483,8 @@ class HTS:
close = item[5]
volume = item[6]
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.cursor.execute('DELETE FROM hts WHERE CODE=? and ymd=? and hms=?', (stock_code, ymd, hms,))
self.cursor.execute("INSERT INTO hts (CODE, NAME, ymd, hms, close, open, high, low, volume) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)", (stock_code, stock_name, ymd, hms, close, open, high, low, volume))
self.conn.commit()
return