init
This commit is contained in:
47
HTS_etf.py
47
HTS_etf.py
@@ -6,7 +6,6 @@ from hts.HTS import HTS
|
|||||||
from hts.OrderType import OrderType
|
from hts.OrderType import OrderType
|
||||||
|
|
||||||
from hts.OrderChecker import OrderChecker
|
from hts.OrderChecker import OrderChecker
|
||||||
from stock.util.LabelChecker import LabelChecker
|
|
||||||
from stock.util.TelegramBot import TelegramBot
|
from stock.util.TelegramBot import TelegramBot
|
||||||
from stock.analysis.StockStatus import StockStatus
|
from stock.analysis.StockStatus import StockStatus
|
||||||
|
|
||||||
@@ -46,7 +45,6 @@ class HTS_etf(HTS):
|
|||||||
self.stock_code = stock_code
|
self.stock_code = stock_code
|
||||||
self.stock_name = stock_name
|
self.stock_name = stock_name
|
||||||
self.orderChecker = OrderChecker(self.RESOURCE_PATH, self.stock_code)
|
self.orderChecker = OrderChecker(self.RESOURCE_PATH, self.stock_code)
|
||||||
self.labelChecker = LabelChecker(RESOURCE_PATH)
|
|
||||||
self.bot = TelegramBot()
|
self.bot = TelegramBot()
|
||||||
self.stockStatus = StockStatus(RESOURCE_PATH)
|
self.stockStatus = StockStatus(RESOURCE_PATH)
|
||||||
|
|
||||||
@@ -56,12 +54,18 @@ class HTS_etf(HTS):
|
|||||||
self.macd = MACD()
|
self.macd = MACD()
|
||||||
self.ichimokuCloud = IchimokuCloud()
|
self.ichimokuCloud = IchimokuCloud()
|
||||||
|
|
||||||
self.buySellChecker = BuySellChecker()
|
self.buySellChecker = BuySellChecker(self.RESOURCE_PATH, self.stock_code)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def getBallance(self):
|
def getBallance(self, stock_code):
|
||||||
return
|
jangoDic = self.requstJango()
|
||||||
|
if jangoDic and len(jangoDic.keys()) > 0:
|
||||||
|
for code in jangoDic:
|
||||||
|
if stock_code is not None:
|
||||||
|
if code == "A" + stock_code:
|
||||||
|
return jangoDic[code]['장부가']
|
||||||
|
return 0
|
||||||
|
|
||||||
def sellStocks(self, stock_code=None, bs_sell_price=None):
|
def sellStocks(self, stock_code=None, bs_sell_price=None):
|
||||||
check = False
|
check = False
|
||||||
@@ -119,7 +123,7 @@ class HTS_etf(HTS):
|
|||||||
close = result["close"]
|
close = result["close"]
|
||||||
high = result["high"]
|
high = result["high"]
|
||||||
low = result["low"]
|
low = result["low"]
|
||||||
volume = result["vol"]
|
volume = result["volume"]
|
||||||
|
|
||||||
if "volume_down" in result:
|
if "volume_down" in result:
|
||||||
volume_down = result["volume_down"]
|
volume_down = result["volume_down"]
|
||||||
@@ -208,7 +212,7 @@ class HTS_etf(HTS):
|
|||||||
upper.append(upper_df.values[i][0])
|
upper.append(upper_df.values[i][0])
|
||||||
lower.append(lower_df.values[i][0])
|
lower.append(lower_df.values[i][0])
|
||||||
|
|
||||||
point_temp = result["time"]
|
point_temp = result["ymd"]
|
||||||
STOCK = []
|
STOCK = []
|
||||||
if "volume_up" in result and "volume_updown_diff" in result:
|
if "volume_up" in result and "volume_updown_diff" in result:
|
||||||
for i in range(len(open)):
|
for i in range(len(open)):
|
||||||
@@ -297,23 +301,23 @@ class HTS_etf(HTS):
|
|||||||
|
|
||||||
def makeTickData(self, data, mins=30):
|
def makeTickData(self, data, mins=30):
|
||||||
result = {"check": set(),
|
result = {"check": set(),
|
||||||
"time": [],
|
"ymd": [],
|
||||||
"open": [],
|
"open": [],
|
||||||
"close": [],
|
"close": [],
|
||||||
"high": [],
|
"high": [],
|
||||||
"low": [],
|
"low": [],
|
||||||
"vol": [],
|
"volume": [],
|
||||||
"label": []}
|
"label": []}
|
||||||
|
|
||||||
for i in range(mins, len(data['time']) + 1):
|
for i in range(mins, len(data['ymd']) + 1):
|
||||||
result["check"].add(data['time'][i - 1])
|
result["check"].add(data['ymd'][i - 1])
|
||||||
result["time"].append(data['time'][i - 1])
|
result["ymd"].append(data['ymd'][i - 1])
|
||||||
|
|
||||||
result["open"].append(data['open'][i - mins])
|
result["open"].append(data['open'][i - mins])
|
||||||
result["close"].append(data['close'][i - 1])
|
result["close"].append(data['close'][i - 1])
|
||||||
result["high"].append(max(data['high'][i - mins: i]))
|
result["high"].append(max(data['high'][i - mins: i]))
|
||||||
result["low"].append(min(data['low'][i - mins: i]))
|
result["low"].append(min(data['low'][i - mins: i]))
|
||||||
result["vol"].append(sum(data['vol'][i - mins: i]))
|
result["volume"].append(sum(data['volume'][i - mins: i]))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -380,11 +384,11 @@ class HTS_etf(HTS):
|
|||||||
|
|
||||||
LAST_DATA = self.getLastData(self.stock_code, today)
|
LAST_DATA = self.getLastData(self.stock_code, today)
|
||||||
|
|
||||||
while datetime.strptime(today + " 063000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 153100",'%Y%m%d %H%M%S'):
|
while datetime.strptime(today + " 000000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 153100",'%Y%m%d %H%M%S'):
|
||||||
if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 090100", '%Y%m%d %H%M%S'):
|
if datetime.strptime(today + " 000000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 090100", '%Y%m%d %H%M%S'):
|
||||||
self.bot.sendMsg("START... {} ({}) SLOW_K: {}".format(self.stock_code, self.stock_name, MAX_PRICE))
|
self.bot.sendMsg("START... {} ({}) SLOW_K: {}".format(self.stock_code, self.stock_name, MAX_PRICE))
|
||||||
|
|
||||||
if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 151500", '%Y%m%d %H%M%S'):
|
if datetime.strptime(today + " 000000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 151500", '%Y%m%d %H%M%S'):
|
||||||
|
|
||||||
# 매도를 체크한다.
|
# 매도를 체크한다.
|
||||||
check = self.sellStocks(self.stock_code)
|
check = self.sellStocks(self.stock_code)
|
||||||
@@ -405,9 +409,9 @@ class HTS_etf(HTS):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
result_tic_m1 = self.makeTickData1(result_m1, mins=1)
|
result_tic_m1 = self.makeTickData1(result_m1, mins=1)
|
||||||
data = self.buySellChecker.analyze(result_tic_m1)
|
data = self.analyze(result_tic_m1)
|
||||||
result_tic_m30 = self.makeTickData2(result_tic_m1, mins=30)
|
result_tic_m30 = self.makeTickData2(result_tic_m1, mins=30)
|
||||||
data_signal = self.buySellChecker.analyze(result_tic_m30)
|
data_signal = self.analyze(result_tic_m30)
|
||||||
|
|
||||||
#data.drop(data.index[:len(data) - analyzed_day], inplace=True)
|
#data.drop(data.index[:len(data) - analyzed_day], inplace=True)
|
||||||
|
|
||||||
@@ -447,14 +451,9 @@ class HTS_etf(HTS):
|
|||||||
|
|
||||||
|
|
||||||
if (int(THIS_TIME.strftime("%M")) % 50 == 0 or int(THIS_TIME.strftime("%M")) % 20 == 0):
|
if (int(THIS_TIME.strftime("%M")) % 50 == 0 or int(THIS_TIME.strftime("%M")) % 20 == 0):
|
||||||
self.bot.alarm_live(self.stock_code, self.stock_name, data["close"][len(data["close"])-1], data["macd"][len(data["macd"])-1])
|
self.bot.alarm_live(self.stock_code, self.stock_name)
|
||||||
|
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
THIS_TIME = datetime.now()
|
THIS_TIME = datetime.now()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def updteTodayStock(self, stock_code, today_str):
|
|
||||||
bsLine, data = self.labelChecker.makeCandidate(stock_code, today_str)
|
|
||||||
self.labelChecker.updateLabel(stock_code, bsLine, data, today_str)
|
|
||||||
return
|
|
||||||
|
|||||||
@@ -10,21 +10,8 @@ class BuySellChecker():
|
|||||||
PATTERNS = None
|
PATTERNS = None
|
||||||
RESOURCE_PATH = None
|
RESOURCE_PATH = None
|
||||||
|
|
||||||
def __init__(self, RESOURCE_PATH, ticker):
|
def __init__(self, RESOURCE_PATH, s):
|
||||||
self.RESOURCE_PATH = RESOURCE_PATH
|
self.RESOURCE_PATH = RESOURCE_PATH
|
||||||
self.readBuyPattern(RESOURCE_PATH, ticker)
|
|
||||||
return
|
|
||||||
|
|
||||||
def readBuyPattern(self, RESOURCE_PATH, ticker):
|
|
||||||
with open(os.path.join(RESOURCE_PATH, "buy_pattern_data.json"), 'r') as f:
|
|
||||||
PATTERNS = json.load(f)
|
|
||||||
|
|
||||||
self.PATTERNS = {'min_max': [], 'stndardization': []}
|
|
||||||
for key in PATTERNS:
|
|
||||||
for min_max in PATTERNS[key]['min_max']:
|
|
||||||
self.PATTERNS['min_max'].append(min_max)
|
|
||||||
for stndardization in PATTERNS[key]['stndardization']:
|
|
||||||
self.PATTERNS['stndardization'].append(stndardization)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def nearDisparity(self, data, i):
|
def nearDisparity(self, data, i):
|
||||||
|
|||||||
71
hts/HTS.py
71
hts/HTS.py
@@ -120,7 +120,7 @@ class HTS:
|
|||||||
# 현재가 정보 조회
|
# 현재가 정보 조회
|
||||||
code = self.objStockMst.GetHeaderValue(0) # 종목코드
|
code = self.objStockMst.GetHeaderValue(0) # 종목코드
|
||||||
name = self.objStockMst.GetHeaderValue(1) # 종목명
|
name = self.objStockMst.GetHeaderValue(1) # 종목명
|
||||||
time = self.objStockMst.GetHeaderValue(4) # 시간
|
ymd = self.objStockMst.GetHeaderValue(4) # 시간
|
||||||
cprice = self.objStockMst.GetHeaderValue(11) # 종가
|
cprice = self.objStockMst.GetHeaderValue(11) # 종가
|
||||||
diff = self.objStockMst.GetHeaderValue(12) # 대비
|
diff = self.objStockMst.GetHeaderValue(12) # 대비
|
||||||
open = self.objStockMst.GetHeaderValue(13) # 시가
|
open = self.objStockMst.GetHeaderValue(13) # 시가
|
||||||
@@ -150,7 +150,7 @@ class HTS:
|
|||||||
print("예상체결가 대비", exDiff)
|
print("예상체결가 대비", exDiff)
|
||||||
print("예상체결수량", exVol)
|
print("예상체결수량", exVol)
|
||||||
"""
|
"""
|
||||||
result = {'code': code, 'name': name, 'time': time, 'close': cprice, 'diff': diff, 'open': open, 'high': high,
|
result = {'code': code, 'name': name, 'ymd': ymd, 'close': cprice, 'diff': diff, 'open': open, 'high': high,
|
||||||
'low': low, 'offer': offer, 'bid': bid, 'vol': vol, 'vol_value': vol_value,
|
'low': low, 'offer': offer, 'bid': bid, 'vol': vol, 'vol_value': vol_value,
|
||||||
'exFlag': exFlag, 'exPrice': exPrice, 'exDiff': exDiff, 'exVol': exVol}
|
'exFlag': exFlag, 'exPrice': exPrice, 'exDiff': exDiff, 'exVol': exVol}
|
||||||
|
|
||||||
@@ -422,13 +422,13 @@ class HTS:
|
|||||||
outfp.write("%s,%s,%s,%s,%s,%s,%s\n" % ("날짜", "시간", "시가", "고가", "저가", "종가", "거래량"))
|
outfp.write("%s,%s,%s,%s,%s,%s,%s\n" % ("날짜", "시간", "시가", "고가", "저가", "종가", "거래량"))
|
||||||
for i in range(size - 1, -1, -1):
|
for i in range(size - 1, -1, -1):
|
||||||
day = objStockChart.GetDataValue(0, i)
|
day = objStockChart.GetDataValue(0, i)
|
||||||
time = objStockChart.GetDataValue(1, i)
|
ymd = objStockChart.GetDataValue(1, i)
|
||||||
start = objStockChart.GetDataValue(2, i)
|
start = objStockChart.GetDataValue(2, i)
|
||||||
high = objStockChart.GetDataValue(3, i)
|
high = objStockChart.GetDataValue(3, i)
|
||||||
low = objStockChart.GetDataValue(4, i)
|
low = objStockChart.GetDataValue(4, i)
|
||||||
close = objStockChart.GetDataValue(5, i)
|
close = objStockChart.GetDataValue(5, i)
|
||||||
vol = objStockChart.GetDataValue(6, i)
|
vol = objStockChart.GetDataValue(6, i)
|
||||||
outfp.write("%d,%s,%d,%d,%d,%d,%d\n" % (day, str(time).zfill(4), start, high, low, close, vol))
|
outfp.write("%d,%s,%d,%d,%d,%d,%d\n" % (day, str(ymd).zfill(4), start, high, low, close, vol))
|
||||||
outfp.close()
|
outfp.close()
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -459,14 +459,14 @@ class HTS:
|
|||||||
data = []
|
data = []
|
||||||
for i in range(size - 1, -1, -1):
|
for i in range(size - 1, -1, -1):
|
||||||
day = objStockChart.GetDataValue(0, i)
|
day = objStockChart.GetDataValue(0, i)
|
||||||
time = objStockChart.GetDataValue(1, i)
|
ymd = objStockChart.GetDataValue(1, i)
|
||||||
start = objStockChart.GetDataValue(2, i)
|
start = objStockChart.GetDataValue(2, i)
|
||||||
high = objStockChart.GetDataValue(3, i)
|
high = objStockChart.GetDataValue(3, i)
|
||||||
low = objStockChart.GetDataValue(4, i)
|
low = objStockChart.GetDataValue(4, i)
|
||||||
close = objStockChart.GetDataValue(5, i)
|
close = objStockChart.GetDataValue(5, i)
|
||||||
vol = objStockChart.GetDataValue(6, i)
|
vol = objStockChart.GetDataValue(6, i)
|
||||||
|
|
||||||
data.append([day, str(time).zfill(4), start, high, low, close, vol])
|
data.append([day, str(ymd).zfill(4), start, high, low, close, vol])
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@@ -503,10 +503,10 @@ class HTS:
|
|||||||
|
|
||||||
outFp = open(day+".csv", mode="w", encoding="UTF-8")
|
outFp = open(day+".csv", mode="w", encoding="UTF-8")
|
||||||
outFp.write("날짜,시간,시가,고가,저가,종가,거래량\n")
|
outFp.write("날짜,시간,시가,고가,저가,종가,거래량\n")
|
||||||
for i in range(len(result["time"])):
|
for i in range(len(result["ymd"])):
|
||||||
outFp.write("%s,%s,%s,%s,%s,%s,%s\n"%(
|
outFp.write("%s,%s,%s,%s,%s,%s,%s\n"%(
|
||||||
result["time"][i].strftime('%Y%m%d'),
|
result["ymd"][i].strftime('%Y%m%d'),
|
||||||
result["time"][i].strftime('%H%M'),
|
result["ymd"][i].strftime('%H%M'),
|
||||||
result["open"][i],
|
result["open"][i],
|
||||||
result["high"][i],
|
result["high"][i],
|
||||||
result["low"][i],
|
result["low"][i],
|
||||||
@@ -522,23 +522,23 @@ class HTS:
|
|||||||
|
|
||||||
for rows in reader:
|
for rows in reader:
|
||||||
days = rows[0] # hts.날짜
|
days = rows[0] # hts.날짜
|
||||||
time = rows[1] # hts.시간
|
ymd = rows[1] # hts.시간
|
||||||
open_v = rows[2] # hts.시가
|
open_v = rows[2] # hts.시가
|
||||||
high = rows[3] # hts.고가
|
high = rows[3] # hts.고가
|
||||||
low = rows[4] # hts.저가
|
low = rows[4] # hts.저가
|
||||||
close = rows[5] # hts.종가
|
close = rows[5] # hts.종가
|
||||||
vol = rows[6] # hts.거래량
|
vol = rows[6] # hts.거래량
|
||||||
|
|
||||||
temp = datetime.strptime(str(days) + " " + str(time).zfill(4) + "00", '%Y%m%d %H%M%S')
|
temp = datetime.strptime(str(days) + " " + str(ymd).zfill(4) + "00", '%Y%m%d %H%M%S')
|
||||||
#if temp < start_time:
|
#if temp < start_time:
|
||||||
# continue
|
# continue
|
||||||
|
|
||||||
result["time"].append(temp)
|
result["ymd"].append(temp)
|
||||||
result["open"].append(int(open_v))
|
result["open"].append(int(open_v))
|
||||||
result["close"].append(int(close))
|
result["close"].append(int(close))
|
||||||
result["high"].append(int(high))
|
result["high"].append(int(high))
|
||||||
result["low"].append(int(low))
|
result["low"].append(int(low))
|
||||||
result["vol"].append(int(vol))
|
result["volume"].append(int(volume))
|
||||||
return
|
return
|
||||||
|
|
||||||
def updateLabel(self, stock_code, bsLine, data, ymd):
|
def updateLabel(self, stock_code, bsLine, data, ymd):
|
||||||
@@ -599,17 +599,17 @@ class HTS:
|
|||||||
high = rows[3] # hts.고가
|
high = rows[3] # hts.고가
|
||||||
low = rows[4] # hts.저가
|
low = rows[4] # hts.저가
|
||||||
close = rows[5] # hts.종가
|
close = rows[5] # hts.종가
|
||||||
vol = rows[6] # hts.거래량
|
volume = rows[6] # hts.거래량
|
||||||
label = 0 if rows[7] is None else rows[7] # hts.매매구분
|
label = 0 if rows[7] is None else rows[7] # hts.매매구분
|
||||||
|
|
||||||
temp = datetime.strptime(str(ymd) + " " + str(hms).zfill(4) + "00", '%Y%m%d %H%M%S')
|
temp = datetime.strptime(str(ymd) + " " + str(hms).zfill(4) + "00", '%Y%m%d %H%M%S')
|
||||||
|
|
||||||
result["time"].append(temp)
|
result["ymd"].append(temp)
|
||||||
result["open"].append(int(open))
|
result["open"].append(int(open))
|
||||||
result["close"].append(int(close))
|
result["close"].append(int(close))
|
||||||
result["high"].append(int(high))
|
result["high"].append(int(high))
|
||||||
result["low"].append(int(low))
|
result["low"].append(int(low))
|
||||||
result["vol"].append(int(vol))
|
result["volume"].append(int(volume))
|
||||||
result["label"].append(int(label))
|
result["label"].append(int(label))
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -622,14 +622,14 @@ class HTS:
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def getLastData(self, stock_code, today, n=3):
|
def getLastData(self, stock_code, today, n=7):
|
||||||
result = {"check": set(),
|
result = {"check": set(),
|
||||||
"time": [],
|
"ymd": [],
|
||||||
"open": [],
|
"open": [],
|
||||||
"close": [],
|
"close": [],
|
||||||
"high": [],
|
"high": [],
|
||||||
"low": [],
|
"low": [],
|
||||||
"vol": [],
|
"volume": [],
|
||||||
"label": []}
|
"label": []}
|
||||||
|
|
||||||
days = []
|
days = []
|
||||||
@@ -652,7 +652,7 @@ class HTS:
|
|||||||
if LAST_DATA is not None:
|
if LAST_DATA is not None:
|
||||||
result = copy.deepcopy(LAST_DATA)
|
result = copy.deepcopy(LAST_DATA)
|
||||||
else:
|
else:
|
||||||
result = {"check": set(), "time": [], "open": [], "close": [], "high": [], "low": [], "vol": [], "label": []}
|
result = {"check": set(), "ymd": [], "open": [], "close": [], "high": [], "low": [], "volume": [], "label": []}
|
||||||
|
|
||||||
#### real time에서 아직 저장된 것이 없기 때문에 result는 아무것도 채워지지 않는다.
|
#### real time에서 아직 저장된 것이 없기 때문에 result는 아무것도 채워지지 않는다.
|
||||||
self.getDBData(stock_code, today, result)
|
self.getDBData(stock_code, today, result)
|
||||||
@@ -689,35 +689,35 @@ class HTS:
|
|||||||
|
|
||||||
if int_day < int_given_day:
|
if int_day < int_given_day:
|
||||||
continue
|
continue
|
||||||
time = datetime.strptime(str(int_day)+" "+str(int_time).zfill(4)+"00", '%Y%m%d %H%M%S')
|
ymd = datetime.strptime(str(int_day)+" "+str(int_time).zfill(4)+"00", '%Y%m%d %H%M%S')
|
||||||
if time < start_time:
|
if ymd < start_time:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
open = objStockChart.GetDataValue(2, i)
|
open = objStockChart.GetDataValue(2, i)
|
||||||
close = objStockChart.GetDataValue(5, i)
|
close = objStockChart.GetDataValue(5, i)
|
||||||
high = objStockChart.GetDataValue(3, i)
|
high = objStockChart.GetDataValue(3, i)
|
||||||
low = objStockChart.GetDataValue(4, i)
|
low = objStockChart.GetDataValue(4, i)
|
||||||
vol = objStockChart.GetDataValue(6, i)
|
volume = objStockChart.GetDataValue(6, i)
|
||||||
|
|
||||||
if len(result["check"]) == 0:
|
if len(result["check"]) == 0:
|
||||||
result["check"].add(start_time)
|
result["check"].add(start_time)
|
||||||
result["time"].append(start_time)
|
result["ymd"].append(start_time)
|
||||||
result["open"].append(open)
|
result["open"].append(open)
|
||||||
result["close"].append(open)
|
result["close"].append(open)
|
||||||
result["high"].append(open)
|
result["high"].append(open)
|
||||||
result["low"].append(open)
|
result["low"].append(open)
|
||||||
result["vol"].append(0)
|
result["volume"].append(0)
|
||||||
result["label"].append(0)
|
result["label"].append(0)
|
||||||
|
|
||||||
if time not in result["check"]:
|
if ymd not in result["check"]:
|
||||||
result["check"].add(time)
|
result["check"].add(ymd)
|
||||||
result["time"].append(time)
|
result["ymd"].append(ymd)
|
||||||
|
|
||||||
result["open"].append(open)
|
result["open"].append(open)
|
||||||
result["close"].append(close)
|
result["close"].append(close)
|
||||||
result["high"].append(high)
|
result["high"].append(high)
|
||||||
result["low"].append(low)
|
result["low"].append(low)
|
||||||
result["vol"].append(vol)
|
result["volume"].append(volume)
|
||||||
result["label"].append(0)
|
result["label"].append(0)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@@ -757,8 +757,8 @@ class HTS:
|
|||||||
int_day = objStockChart.GetDataValue(0, i)
|
int_day = objStockChart.GetDataValue(0, i)
|
||||||
int_time = objStockChart.GetDataValue(1, i)
|
int_time = objStockChart.GetDataValue(1, i)
|
||||||
# ymd: '2022.03.29'
|
# ymd: '2022.03.29'
|
||||||
# time = datetime.strptime(str(int_day)+" "+str(int_time).zfill(4)+"00", '%Y%m%d %H%M%S')
|
# ymd = datetime.strptime(str(int_day)+" "+str(int_time).zfill(4)+"00", '%Y%m%d %H%M%S')
|
||||||
# time_str = time.strftime('%Y.%m.%d')
|
# time_str = ymd.strftime('%Y.%m.%d')
|
||||||
today_str = today[0:4] + "." + today[4:6] + "." + today[6:8]
|
today_str = today[0:4] + "." + today[4:6] + "." + today[6:8]
|
||||||
|
|
||||||
if i == 0:
|
if i == 0:
|
||||||
@@ -823,7 +823,7 @@ class HTS:
|
|||||||
return
|
return
|
||||||
|
|
||||||
def getClosePrice_realtime(self, stock_code, today):
|
def getClosePrice_realtime(self, stock_code, today):
|
||||||
result = {"open": [], "close": [], "high": [], "low": [], "vol": []}
|
result = {'ymd': [], "open": [], "close": [], "high": [], "low": [], "volume": []}
|
||||||
|
|
||||||
int_given_day = int(today)
|
int_given_day = int(today)
|
||||||
objCpCybos = win32com.client.Dispatch("CpUtil.CpCybos")
|
objCpCybos = win32com.client.Dispatch("CpUtil.CpCybos")
|
||||||
@@ -853,18 +853,19 @@ class HTS:
|
|||||||
int_day = objStockChart.GetDataValue(0, i)
|
int_day = objStockChart.GetDataValue(0, i)
|
||||||
int_time = objStockChart.GetDataValue(1, i)
|
int_time = objStockChart.GetDataValue(1, i)
|
||||||
|
|
||||||
time = datetime.strptime(str(int_day)+" "+str(int_time).zfill(4)+"00", '%Y%m%d %H%M%S')
|
ymd = datetime.strptime(str(int_day)+" "+str(int_time).zfill(4)+"00", '%Y%m%d %H%M%S')
|
||||||
|
|
||||||
open = objStockChart.GetDataValue(2, i)
|
open = objStockChart.GetDataValue(2, i)
|
||||||
close = objStockChart.GetDataValue(5, i)
|
close = objStockChart.GetDataValue(5, i)
|
||||||
high = objStockChart.GetDataValue(3, i)
|
high = objStockChart.GetDataValue(3, i)
|
||||||
low = objStockChart.GetDataValue(4, i)
|
low = objStockChart.GetDataValue(4, i)
|
||||||
vol = objStockChart.GetDataValue(6, i)
|
volume = objStockChart.GetDataValue(6, i)
|
||||||
|
|
||||||
|
result["ymd"].append(open)
|
||||||
result["open"].append(open)
|
result["open"].append(open)
|
||||||
result["close"].append(close)
|
result["close"].append(close)
|
||||||
result["high"].append(high)
|
result["high"].append(high)
|
||||||
result["low"].append(low)
|
result["low"].append(low)
|
||||||
result["vol"].append(vol)
|
result["volume"].append(volume)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@@ -25,9 +25,6 @@ from stock.analysis.MACD import MACD
|
|||||||
from stock.analysis.Envelope import Envelope
|
from stock.analysis.Envelope import Envelope
|
||||||
from stock.analysis.MovingAverage import MovingAverage
|
from stock.analysis.MovingAverage import MovingAverage
|
||||||
|
|
||||||
from hts.BuySellChecker import BuySellChecker
|
|
||||||
|
|
||||||
|
|
||||||
class AnalyzerSqlite:
|
class AnalyzerSqlite:
|
||||||
stochastic = None
|
stochastic = None
|
||||||
bolingerBand = None
|
bolingerBand = None
|
||||||
@@ -45,8 +42,6 @@ class AnalyzerSqlite:
|
|||||||
|
|
||||||
moving_avg = None
|
moving_avg = None
|
||||||
|
|
||||||
buySellChecker = None
|
|
||||||
|
|
||||||
def __init__(self, stockFileName=None):
|
def __init__(self, stockFileName=None):
|
||||||
self.common = Common()
|
self.common = Common()
|
||||||
|
|
||||||
@@ -57,8 +52,6 @@ class AnalyzerSqlite:
|
|||||||
self.macd = MACD()
|
self.macd = MACD()
|
||||||
self.envelope = Envelope()
|
self.envelope = Envelope()
|
||||||
|
|
||||||
self.buySellChecker = BuySellChecker()
|
|
||||||
|
|
||||||
if stockFileName is not None:
|
if stockFileName is not None:
|
||||||
self.stockFileName = stockFileName
|
self.stockFileName = stockFileName
|
||||||
self.topCompany = self.getTopCompany(stockFileName, 2000)
|
self.topCompany = self.getTopCompany(stockFileName, 2000)
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ from sklearn.linear_model import LinearRegression
|
|||||||
from sklearn.preprocessing import StandardScaler, MinMaxScaler
|
from sklearn.preprocessing import StandardScaler, MinMaxScaler
|
||||||
|
|
||||||
from hts.HTS import HTS
|
from hts.HTS import HTS
|
||||||
from hts.BuySellChecker import BuySellChecker
|
|
||||||
from stock.analysis.AnalyzerSqlite import AnalyzerSqlite
|
from stock.analysis.AnalyzerSqlite import AnalyzerSqlite
|
||||||
|
|
||||||
class StockStatus (HTS):
|
class StockStatus (HTS):
|
||||||
@@ -29,7 +28,6 @@ class StockStatus (HTS):
|
|||||||
self.dbFileName = "stock.db"
|
self.dbFileName = "stock.db"
|
||||||
|
|
||||||
self.analyzerSqlite = AnalyzerSqlite(os.path.join(self.RESOURCE_PATH, self.dbFileName))
|
self.analyzerSqlite = AnalyzerSqlite(os.path.join(self.RESOURCE_PATH, self.dbFileName))
|
||||||
self.buySellChecker = BuySellChecker()
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class LabelChecker (HTS):
|
|||||||
|
|
||||||
def __init__(self, RESOURCE_PATH):
|
def __init__(self, RESOURCE_PATH):
|
||||||
super().__init__(RESOURCE_PATH)
|
super().__init__(RESOURCE_PATH)
|
||||||
self.buySellChecker = BuySellChecker()
|
self.buySellChecker = BuySellChecker(RESOURCE_PATH)
|
||||||
self.stock2Vector = Stock2Vector(RESOURCE_PATH)
|
self.stock2Vector = Stock2Vector(RESOURCE_PATH)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user