This commit is contained in:
dsyoon
2022-09-12 21:04:10 +09:00
parent 833271e699
commit 9c556f07d9
3 changed files with 68 additions and 44 deletions

View File

@@ -93,9 +93,9 @@ class Simulation (HTS):
changeLine = go.Scatter(x=data['date'], y=data["changeLine"], name='changeLine', line_color='#14A200')
baseLine = go.Scatter(x=data['date'], y=data["baseLine"], name='baseLine', line_color='#CF6E0D')
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')
volume_line = go.Scatter(x=data['date'], y=data["volume"], mode='lines', name='volume')
#fast_k_line = go.Scatter(x=hts['date'], y=hts["fast_k"], mode='lines', name='fast_k')
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', showlegend=False)
#volume_line = go.Scatter(x=data['date'], y=data["volume"], mode='lines', name='volume')
volume_line = go.Bar(x=data['date'], y=data["volume"], marker_color='red', name='volume')
disparity_avg5 = go.Scatter(x=data['date'], y=data["disparity_avg5"], name="disparity_avg5", line_color='#8F8203')
disparity_avg10 = go.Scatter(x=data['date'], y=data["disparity_avg10"], name="disparity_avg10", line_color='#089B5B')
@@ -103,15 +103,16 @@ class Simulation (HTS):
disparity_avg60 = go.Scatter(x=data['date'], y=data["disparity_avg60"], name="disparity_avg60", line_color='#1469F4')
disparity_avg120 = go.Scatter(x=data['date'], y=data["disparity_avg120"], name="disparity_avg120", line_color='#000000')
macd_line = go.Scatter(x=data['date'], y=data["macd"], mode='lines', name='macd')
macd_s_line = go.Scatter(x=data['date'], y=data["macds"], mode='lines', name='macds')
macd_o_line = go.Scatter(x=data['date'], y=data["macdo"], mode='lines', name='macdo')
macd_line = go.Scatter(x=data['date'], y=data["macd"], line=dict(color='red', width=2), name='macd')
macd_s_line = go.Scatter(x=data['date'], y=data["macds"], line=dict(dash='dashdot', color='black', width=2), name='macds')
macd_o_line = go.Bar(x=data['date'], y=data["macdo"], marker_color='purple', name='macdo')
slow_k_line = go.Scatter(x=data['date'], y=data["slow_k"], mode='lines', name='slow_k')
slow_d_line = go.Scatter(x=data['date'], y=data["slow_d"], mode='lines', name='slow_d')
# fast_k_line = go.Scatter(x=hts['date'], y=hts["fast_k"], mode='lines', name='fast_k')
slow_k_line = go.Scatter(x=data['date'], y=data["slow_k"], line=dict(color='red', width=2), name='slow_k')
slow_d_line = go.Scatter(x=data['date'], y=data["slow_d"], line=dict(dash='dashdot', color='black', width=2), name='slow_d')
rsi_line = go.Scatter(x=data['date'], y=data["rsi"], mode='lines', name='rsi')
rsis_line = go.Scatter(x=data['date'], y=data["rsis"], mode='lines', name='rsis')
rsi_line = go.Scatter(x=data['date'], y=data["rsi"], line=dict(color='red', width=2), name='rsi')
rsis_line = go.Scatter(x=data['date'], y=data["rsis"], line=dict(dash='dashdot', color='black', width=2), name='rsis')
candle_data = [candle_stick, upper, lower, avg3, avg6, avg9, avg12, avg20, buy_check, sell_check, laggingSpan, changeLine, baseLine]
volume_data = [volume_line]
@@ -127,21 +128,26 @@ class Simulation (HTS):
fig.show()
"""
fig = subplots.make_subplots(rows=6, cols=1,
subplot_titles=('캔들', "거래량", "이격도", "MACD", "스토캐스틱", "RSI"),
row_heights=[1200, 500, 500, 500, 500, 500])
for trace in candle_data:
fig.append_trace(trace, 1, 1)
for trace in volume_data:
fig.append_trace(trace, 2, 1)
for trace in disparity_data:
fig.append_trace(trace, 3, 1)
fig = subplots.make_subplots(
rows=6, cols=1,
subplot_titles=("MACD", "스토캐스틱", "RSI", "거래량", "이격도", '캔들'),
#specs=[[{}], [{}], [{}], [{}], [{}], [{}]],
shared_xaxes=True, horizontal_spacing=0.03, vertical_spacing=0.01,
row_heights=[200, 200, 200, 200, 200, 700]
)
for trace in macd_data:
fig.append_trace(trace, 4, 1)
fig.append_trace(trace, 1, 1)
for trace in stochastic_data:
fig.append_trace(trace, 5, 1)
fig.append_trace(trace, 2, 1)
for trace in rsi_data:
fig.append_trace(trace, 3, 1)
for trace in volume_data:
fig.append_trace(trace, 4, 1)
for trace in disparity_data:
fig.append_trace(trace, 5, 1)
for trace in candle_data:
fig.append_trace(trace, 6, 1)
#fig.update_xaxes(nticks=5)
#fig.update_layout(height=1800, title=stock_code + "_" + given_day, xaxis_rangeslider_visible=False)
@@ -150,7 +156,8 @@ class Simulation (HTS):
buy_count = len(df.loc[df["buy"] > 0])
sell_count = len(df.loc[df["sell"] > 0])
fig.update_layout(height=5000, title=stock_code + "_" + given_day + "_" + str(buy_count)+","+str(sell_count))
fig.update_layout(height=1700, title=stock_code + "_" + given_day + "_" + str(buy_count)+","+str(sell_count))
#fig.update_layout(title=stock_code + "_" + given_day + "_" + str(buy_count) + "," + str(sell_count))
fig.show()
return