init
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import os
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime
|
||||
import pandas as pd
|
||||
import plotly.graph_objects as go
|
||||
from plotly import subplots
|
||||
|
||||
from BS import BS
|
||||
from BuySellChecker import BuySellChecker
|
||||
|
||||
class Simulation:
|
||||
|
||||
bs = None
|
||||
buySellChecker = None
|
||||
def __init__(self):
|
||||
self.bs = BS()
|
||||
self.buySellChecker = BuySellChecker()
|
||||
#self.connect()
|
||||
return
|
||||
|
||||
@@ -50,7 +50,7 @@ class Simulation:
|
||||
bsLine['sell'] = [-1 for i in range(size)]
|
||||
|
||||
for i in range(6, size-5):
|
||||
buy, weight, sell = self.bs.getPriceAndWeight1(data, i)
|
||||
buy, weight, sell = self.buySellChecker.getPriceAndWeight1(data, i)
|
||||
bsLine['buy'][i] = buy
|
||||
bsLine['weight'][i] = weight
|
||||
bsLine['sell'][i] = sell
|
||||
@@ -97,6 +97,7 @@ class Simulation:
|
||||
avg5 = go.Scatter(x=data['Date'], y=data["avg5"], name="avg5", line_color='#000000')
|
||||
|
||||
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=data['Date'], y=data["fast_k"], mode='lines', name='fast_k')
|
||||
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')
|
||||
@@ -105,6 +106,7 @@ class Simulation:
|
||||
|
||||
#candle_data = [candle_stick, bolinger_upper, bolinger_lower, buy_check, sell_check, avg1, avg2, avg5, avg10, avg20, avg30, avg40, avg50, avg60]
|
||||
candle_data = [candle_stick, bolinger_upper, bolinger_lower, avg5, buy_check, sell_check]
|
||||
volume_data = [volume_line]
|
||||
stochastic_data = [slow_k_line, slow_d_line]
|
||||
rsi_data = [rsi_line, rsis_line]
|
||||
|
||||
@@ -115,13 +117,15 @@ class Simulation:
|
||||
fig.show()
|
||||
"""
|
||||
|
||||
fig = subplots.make_subplots(rows=3, cols=1, subplot_titles=('캔들', "스토캐스틱", "RSI"))
|
||||
fig = subplots.make_subplots(rows=4, cols=1, subplot_titles=('캔들', "거래량", "스토캐스틱", "RSI"))
|
||||
for trace in candle_data:
|
||||
fig.append_trace(trace, 1, 1)
|
||||
for trace in stochastic_data:
|
||||
for trace in volume_data:
|
||||
fig.append_trace(trace, 2, 1)
|
||||
for trace in rsi_data:
|
||||
for trace in stochastic_data:
|
||||
fig.append_trace(trace, 3, 1)
|
||||
for trace in rsi_data:
|
||||
fig.append_trace(trace, 4, 1)
|
||||
#fig.update_xaxes(nticks=5)
|
||||
#fig.update_layout(height=1800, title=stock_code + "_" + given_day, xaxis_rangeslider_visible=False)
|
||||
fig.update_layout(height=1800, title=stock_code + "_" + given_day)
|
||||
@@ -142,7 +146,7 @@ class Simulation:
|
||||
self.getCSV("./data/"+stock_code+"_"+given_day+".csv", given_day, result)
|
||||
|
||||
# 분석을 통해서 볼린저밴드 상/하단을 계산한다.
|
||||
data = self.bs.analyze(result)
|
||||
data = self.buySellChecker.analyze(result)
|
||||
|
||||
# 사야 할 시점과 팔아야 할 시점을 체크한다.
|
||||
bsLine = self.checkTransaction(data)
|
||||
|
||||
Reference in New Issue
Block a user