init
This commit is contained in:
@@ -352,23 +352,32 @@ class BuySellChecker:
|
||||
else:
|
||||
buy, buy_weight = self.getBuyPriceAndWeight_122630(last_index, data)
|
||||
sell, sell_weight = self.getSellPriceAndWeight(last_index, data)
|
||||
if data.index[last_index].strftime('%H:%M:%S') > datetime.strptime(datetime.today().strftime("%Y-%m-%d 15:10:00"), "%Y-%m-%d %H:%M:%S").strftime('%H:%M:%S'):
|
||||
buy, buy_weight = -1, -1
|
||||
|
||||
if sell > 0 and 'last_buy' in bsLine[stock_code]:
|
||||
if bsLine[stock_code]['last'] == 'buy':
|
||||
if sell - bsLine[stock_code]['last_buy'] < 0.007:
|
||||
sell, weight = -1, -1
|
||||
if sell > 0:
|
||||
if 'last_buy' in bsLine[stock_code]:
|
||||
if bsLine[stock_code]['last'] == 'buy':
|
||||
if sell - bsLine[stock_code]['last_buy'] < 0.007:
|
||||
sell, weight = -1, -1
|
||||
else:
|
||||
sell, weight = -1, -1
|
||||
if 'last' in bsLine[stock_code] and bsLine[stock_code]['last'] != 'buy':
|
||||
sell, weight = -1, -1
|
||||
|
||||
bsLine[stock_code]['buy'] = [buy]
|
||||
bsLine[stock_code]['buy_weight'] = [buy_weight]
|
||||
bsLine[stock_code]['sell'] = [sell]
|
||||
bsLine[stock_code]['sell_weight'] = [sell_weight]
|
||||
bsLine[stock_code]['buy'][last_index] = buy
|
||||
bsLine[stock_code]['buy_weight'][last_index] = buy_weight
|
||||
bsLine[stock_code]['sell'][last_index] = sell
|
||||
bsLine[stock_code]['sell_weight'][last_index] = sell_weight
|
||||
|
||||
if buy > 0:
|
||||
bsLine[stock_code]['last'] = 'buy'
|
||||
bsLine[stock_code]['last_buy'] = buy
|
||||
bsLine[stock_code]['buy_count'] += 1
|
||||
if sell > 0:
|
||||
bsLine[stock_code]['last'] = 'sell'
|
||||
bsLine[stock_code]['last_buy'] = -1
|
||||
bsLine[stock_code]['buy_count'] = 0
|
||||
|
||||
else:
|
||||
# Type=False, 시뮬레이션 적용
|
||||
@@ -399,11 +408,6 @@ class BuySellChecker:
|
||||
sell, weight = -1, -1
|
||||
if 'last' in bsLine[stock_code] and bsLine[stock_code]['last'] != 'buy':
|
||||
sell, weight = -1, -1
|
||||
#if data.index[last_index].strftime('%H:%M:%S') > datetime.strptime(datetime.today().strftime("%Y-%m-%d 15:10:00"), "%Y-%m-%d %H:%M:%S").strftime('%H:%M:%S'):
|
||||
# if 'last' in bsLine[stock_code] and bsLine[stock_code]['last'] == 'buy':
|
||||
# sell, weight = data['close'][last_index], -1
|
||||
# bsLine[stock_code]['last'] = ''
|
||||
# bsLine[stock_code]['last_buy'] = -1
|
||||
|
||||
bsLine[stock_code]['buy'][last_index] = buy
|
||||
bsLine[stock_code]['buy_weight'][last_index] = buy_weight
|
||||
|
||||
29
hts/HTS.py
29
hts/HTS.py
@@ -463,7 +463,7 @@ class HTS:
|
||||
|
||||
return data
|
||||
|
||||
def insertStockData(self, stocks, this_day):
|
||||
def insertStockData(self, stock_code, 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)")
|
||||
@@ -472,23 +472,21 @@ class HTS:
|
||||
create_key = "CREATE INDEX IF NOT EXISTS hts_idx on hts(CODE, ymd, hms) "
|
||||
self.cursor.execute(create_key)
|
||||
|
||||
for stock in stocks:
|
||||
items = self.getStockInfo(stock_code, this_day.strftime('%Y%m%d'))
|
||||
|
||||
items = self.getStockInfo(stock["stock_code"], this_day.strftime('%Y%m%d'))
|
||||
for item in items:
|
||||
ymd = item[0]
|
||||
hms = item[1]
|
||||
open = item[2]
|
||||
high = item[3]
|
||||
low = item[4]
|
||||
close = item[5]
|
||||
volume = item[6]
|
||||
|
||||
for item in items:
|
||||
ymd = item[0]
|
||||
hms = item[1]
|
||||
open = item[2]
|
||||
high = item[3]
|
||||
low = item[4]
|
||||
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["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()
|
||||
self.conn.commit()
|
||||
return
|
||||
|
||||
|
||||
@@ -793,6 +791,7 @@ class HTS:
|
||||
"disparity_avg20": -1,
|
||||
"disparity_avg60": -1,
|
||||
"disparity_avg120": -1,
|
||||
"disparity_avg200": -1,
|
||||
"bolingerband_upper": -1,
|
||||
"bolingerband_lower": -1,
|
||||
"bolingerband_middle": -1,
|
||||
|
||||
Reference in New Issue
Block a user