This commit is contained in:
dosang.yoon
2022-08-02 18:45:04 +09:00
parent 621a8a3654
commit e8779ac425
7 changed files with 52 additions and 75 deletions

View File

@@ -1,13 +0,0 @@
2022-07-27 09:19:00,3060
2022-07-27 09:20:00,3070
2022-07-27 09:21:00,3070
2022-07-27 09:53:00,3075
2022-07-27 09:57:00,3075
2022-07-27 09:58:00,3075
2022-07-27 12:26:00,3090
2022-07-27 12:27:00,3090
2022-07-27 12:31:00,3090
2022-07-27 12:32:00,3090
2022-07-27 12:33:00,3090
2022-07-27 12:36:00,3090
2022-07-27 12:38:00,3090
1 2022-07-27 09:19:00 3060
2 2022-07-27 09:20:00 3070
3 2022-07-27 09:21:00 3070
4 2022-07-27 09:53:00 3075
5 2022-07-27 09:57:00 3075
6 2022-07-27 09:58:00 3075
7 2022-07-27 12:26:00 3090
8 2022-07-27 12:27:00 3090
9 2022-07-27 12:31:00 3090
10 2022-07-27 12:32:00 3090
11 2022-07-27 12:33:00 3090
12 2022-07-27 12:36:00 3090
13 2022-07-27 12:38:00 3090

View File

@@ -1,8 +0,0 @@
2022-07-27 09:05:00,3085
2022-07-27 09:06:00,3085
2022-07-27 09:08:00,3085
2022-07-27 09:34:00,3085
2022-07-27 10:29:00,3105
2022-07-27 10:30:00,3105
2022-07-27 13:07:00,3105
2022-07-27 13:24:00,3105
1 2022-07-27 09:05:00 3085
2 2022-07-27 09:06:00 3085
3 2022-07-27 09:08:00 3085
4 2022-07-27 09:34:00 3085
5 2022-07-27 10:29:00 3105
6 2022-07-27 10:30:00 3105
7 2022-07-27 13:07:00 3105
8 2022-07-27 13:24:00 3105

View File

@@ -1,14 +0,0 @@
2022-07-28 09:07:00,2975
2022-07-28 09:08:00,2985
2022-07-28 09:09:00,2995
2022-07-28 09:10:00,2995
2022-07-28 09:51:00,2995
2022-07-28 09:52:00,3000
2022-07-28 09:53:00,3000
2022-07-28 09:55:00,3000
2022-07-28 09:57:00,3000
2022-07-28 09:58:00,3005
2022-07-28 09:59:00,3005
2022-07-28 11:59:00,3005
2022-07-28 12:00:00,3010
2022-07-28 12:01:00,3010
1 2022-07-28 09:07:00 2975
2 2022-07-28 09:08:00 2985
3 2022-07-28 09:09:00 2995
4 2022-07-28 09:10:00 2995
5 2022-07-28 09:51:00 2995
6 2022-07-28 09:52:00 3000
7 2022-07-28 09:53:00 3000
8 2022-07-28 09:55:00 3000
9 2022-07-28 09:57:00 3000
10 2022-07-28 09:58:00 3005
11 2022-07-28 09:59:00 3005
12 2022-07-28 11:59:00 3005
13 2022-07-28 12:00:00 3010
14 2022-07-28 12:01:00 3010

View File

@@ -1,9 +0,0 @@
2022-07-28 09:32:00,3025
2022-07-28 10:23:00,3035
2022-07-28 10:37:00,3035
2022-07-28 10:38:00,3035
2022-07-28 10:41:00,3035
2022-07-28 10:44:00,3035
2022-07-28 10:46:00,3035
2022-07-28 12:24:00,3030
2022-07-28 14:27:00,3040
1 2022-07-28 09:32:00 3025
2 2022-07-28 10:23:00 3035
3 2022-07-28 10:37:00 3035
4 2022-07-28 10:38:00 3035
5 2022-07-28 10:41:00 3035
6 2022-07-28 10:44:00 3035
7 2022-07-28 10:46:00 3035
8 2022-07-28 12:24:00 3030
9 2022-07-28 14:27:00 3040

View File

@@ -1,8 +0,0 @@
2022-07-29 09:34:00,2945
2022-07-29 09:35:00,2945
2022-07-29 09:36:00,2945
2022-07-29 09:37:00,2945
2022-07-29 09:38:00,2950
2022-07-29 09:39:00,2950
2022-07-29 09:40:00,2950
2022-07-29 12:31:00,2990
1 2022-07-29 09:34:00 2945
2 2022-07-29 09:35:00 2945
3 2022-07-29 09:36:00 2945
4 2022-07-29 09:37:00 2945
5 2022-07-29 09:38:00 2950
6 2022-07-29 09:39:00 2950
7 2022-07-29 09:40:00 2950
8 2022-07-29 12:31:00 2990

View File

@@ -1,5 +0,0 @@
2022-07-29 10:07:00,2985
2022-07-29 10:49:00,2990
2022-07-29 12:53:00,3010
2022-07-29 14:15:00,3015
2022-07-29 14:16:00,3015
1 2022-07-29 10:07:00 2985
2 2022-07-29 10:49:00 2990
3 2022-07-29 12:53:00 3010
4 2022-07-29 14:15:00 3015
5 2022-07-29 14:16:00 3015

View File

@@ -8,6 +8,7 @@ from plotly import subplots
from hts.HTS import HTS
from hts.BuySellChecker import BuySellChecker
class LabelMaker (HTS):
buySellChecker = None
@@ -29,10 +30,10 @@ class LabelMaker (HTS):
for i in range(size-60):
min_price, min_price_c, max_price, max_price_c = 9999999, -1, 0, -1
for c in range(i, i+60):
if data["close"][c] > max_price:
max_price = data["close"][c]
if max(data["close"][c], data["close"][c]) > max_price:
max_price = max(data["close"][c], data["close"][c])
max_price_c = c
if data["close"][c] < min_price:
if min(data["close"][c], data["close"][c]) < min_price:
min_price = data["close"][c]
min_price_c = c
@@ -45,7 +46,51 @@ class LabelMaker (HTS):
return bsLine, data
def draw(self, stock_code, given_day, data, bsLine):
def draw_simple(self, stock_code, given_day, data, bsLine):
buy_line = bsLine['buy']
sell_line = bsLine['sell']
# 그래프 설정을 위한 변수를 생성한다.
data = data.astype({'open': 'int',
'high': 'int',
'low': 'int',
'close': 'int'
})
buy_colors = []
for i in range(len(buy_line)):
if buy_line[i] < 0:
buy_colors.append("#ffffff")
buy_line[i] = nan
else:
buy_colors.append("#ff00ff")
sell_colors = []
for i in range(len(sell_line)):
if sell_line[i] < 0:
sell_colors.append("#ffffff")
sell_line[i] = nan
else:
sell_colors.append("#00ced1")
# 그래프를 설정한다.
buy_check = go.Scatter(x=data['date'], y=buy_line, mode='markers', name="buy", marker=dict(size=14, color=buy_colors, line_width=0))
sell_check = go.Scatter(x=data['date'], y=sell_line, mode='markers', name="sell", marker=dict(size=14, color=sell_colors, line_width=0))
candle_stick = go.Candlestick(x=data['date'], open=data['open'], high=data['high'], low=data['low'], close=data['close'], increasing_line_color='red', decreasing_line_color='blue')
candle_data = [candle_stick, buy_check, sell_check]
df = pd.DataFrame(bsLine)
df = df.fillna(-1)
buy_count = len(df.loc[df["buy"] > 0])
sell_count = len(df.loc[df["sell"] > 0])
self.fig = go.FigureWidget(data=candle_data)
self.buy_data = self.fig.data[1]
self.fig.update_layout(height=1000, title=stock_code + "_" + given_day + "_" + str(buy_count) + "," + str(sell_count))
self.fig.show()
return
def draw_detail(self, stock_code, given_day, data, bsLine):
buy_line = bsLine['buy']
sell_line = bsLine['sell']
@@ -114,17 +159,6 @@ class LabelMaker (HTS):
stochastic_data = [slow_k_line, slow_d_line]
rsi_data = [rsi_line, rsis_line]
"""
fig = go.Figure(data=candle_data)
df = pd.DataFrame(bsLine)
df = df.fillna(-1)
buy_count = len(df.loc[df["buy"] > 0])
sell_count = len(df.loc[df["sell"] > 0])
fig.update_layout(height=1000, title=stock_code + "_" + given_day + "_" + str(buy_count)+","+str(sell_count))
fig.show()
"""
fig = subplots.make_subplots(rows=5, cols=1, subplot_titles=('캔들', "거래량", "MACD", "스토캐스틱", "RSI"))
for trace in candle_data:
fig.append_trace(trace, 1, 1)
@@ -147,7 +181,6 @@ class LabelMaker (HTS):
fig.update_layout(height=3000, title=stock_code + "_" + given_day + "_" + str(buy_count)+","+str(sell_count))
fig.show()
return
def writeLabelFile(self, bsLine, data, ymd):
@@ -174,7 +207,8 @@ class LabelMaker (HTS):
bsLine, data = self.checkTransaction(data)
self.writeLabelFile(bsLine, data, ymd)
self.draw(stock_code, ymd, data, bsLine)
self.draw_simple(stock_code, ymd, data, bsLine)
self.draw_detail(stock_code, ymd, data, bsLine)
return
if __name__ == "__main__":
@@ -186,4 +220,4 @@ if __name__ == "__main__":
stock_code = "252670"
#stock_code = "122630"
labelMaker.makeCandidate(stock_code, "20220727")
labelMaker.makeCandidate(stock_code, "20220802")