This commit is contained in:
dsyoon
2023-12-12 01:37:57 +09:00
parent fbfab6d236
commit 3102d2352b
6 changed files with 63 additions and 85 deletions

View File

@@ -6,7 +6,6 @@ from hts.HTS import HTS
from hts.OrderType import OrderType
from hts.OrderChecker import OrderChecker
from stock.util.LabelChecker import LabelChecker
from stock.util.TelegramBot import TelegramBot
from stock.analysis.StockStatus import StockStatus
@@ -46,7 +45,6 @@ class HTS_etf(HTS):
self.stock_code = stock_code
self.stock_name = stock_name
self.orderChecker = OrderChecker(self.RESOURCE_PATH, self.stock_code)
self.labelChecker = LabelChecker(RESOURCE_PATH)
self.bot = TelegramBot()
self.stockStatus = StockStatus(RESOURCE_PATH)
@@ -56,12 +54,18 @@ class HTS_etf(HTS):
self.macd = MACD()
self.ichimokuCloud = IchimokuCloud()
self.buySellChecker = BuySellChecker()
self.buySellChecker = BuySellChecker(self.RESOURCE_PATH, self.stock_code)
return
def getBallance(self):
return
def getBallance(self, stock_code):
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):
check = False
@@ -119,7 +123,7 @@ class HTS_etf(HTS):
close = result["close"]
high = result["high"]
low = result["low"]
volume = result["vol"]
volume = result["volume"]
if "volume_down" in result:
volume_down = result["volume_down"]
@@ -208,7 +212,7 @@ class HTS_etf(HTS):
upper.append(upper_df.values[i][0])
lower.append(lower_df.values[i][0])
point_temp = result["time"]
point_temp = result["ymd"]
STOCK = []
if "volume_up" in result and "volume_updown_diff" in result:
for i in range(len(open)):
@@ -297,23 +301,23 @@ class HTS_etf(HTS):
def makeTickData(self, data, mins=30):
result = {"check": set(),
"time": [],
"ymd": [],
"open": [],
"close": [],
"high": [],
"low": [],
"vol": [],
"volume": [],
"label": []}
for i in range(mins, len(data['time']) + 1):
result["check"].add(data['time'][i - 1])
result["time"].append(data['time'][i - 1])
for i in range(mins, len(data['ymd']) + 1):
result["check"].add(data['ymd'][i - 1])
result["ymd"].append(data['ymd'][i - 1])
result["open"].append(data['open'][i - mins])
result["close"].append(data['close'][i - 1])
result["high"].append(max(data['high'][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
@@ -380,11 +384,11 @@ class HTS_etf(HTS):
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'):
if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 090100", '%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 + " 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))
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)
@@ -405,9 +409,9 @@ class HTS_etf(HTS):
continue
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)
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)
@@ -447,14 +451,9 @@ class HTS_etf(HTS):
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)
THIS_TIME = datetime.now()
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
return True