init
This commit is contained in:
56
hts/BS.py
56
hts/BS.py
@@ -16,6 +16,58 @@ class BS:
|
||||
|
||||
return
|
||||
|
||||
def getPriceAndWeight(self, data, i):
|
||||
buy, weight, sell = -1, -1, -1
|
||||
|
||||
# sell 분석
|
||||
if (data["High"][i] - data["Close"][i]) / 2 + data["Close"][i] > data["upper"][i]:
|
||||
sell = data["High"][i]
|
||||
if i > 300:
|
||||
if data["High"][i] > data["upper"][i]:
|
||||
sell = data["High"][i]
|
||||
|
||||
# buy 분석
|
||||
if data["slow_k"][i] <= 36:
|
||||
if data["Low"][i] < data["lower"][i]:
|
||||
buy = data["Low"][i]
|
||||
if data["slow_k"][i] <= 25:
|
||||
if data["slow_k"][i - 1] < data["slow_d"][i - 1] and data["slow_d"][i] < data["slow_k"][i]:
|
||||
buy = data["Low"][i]
|
||||
|
||||
if i < 40:
|
||||
if data["slow_k"][i] < 25:
|
||||
buy = data["Low"][i]
|
||||
|
||||
# weight 분석
|
||||
# rsi가 rsis 위로 올라오며 15 이하일 경우 10배로 주문함 (14:30 이전)
|
||||
if data["rsi"][i] < 15 and data["rsis"][i] < 15 and data["rsi"][i - 1] < data["rsis"][i - 1] and data["rsis"][i] < data["rsi"][i]:
|
||||
buy = data["Low"][i]
|
||||
weight = 4
|
||||
|
||||
if data["slow_k"][i] == 1:
|
||||
weight = 4 # 8
|
||||
elif data["slow_k"][i] in (2, 3):
|
||||
weight = 3.5 # 7
|
||||
elif data["slow_k"][i] in (4, 5, 6):
|
||||
weight = 3 # 6
|
||||
elif data["slow_k"][i] in (7, 8, 9, 10):
|
||||
weight = 2.5 # 5
|
||||
elif data["slow_k"][i] in (11, 12, 13, 14, 15):
|
||||
weight = 2 # 4
|
||||
elif data["slow_k"][i] in (16, 17, 18, 19, 20, 21):
|
||||
weight = 1.5 # 3
|
||||
elif data["slow_k"][i] in (22, 23, 24, 25, 26, 27, 28):
|
||||
weight = 1 # 2
|
||||
elif data["slow_k"][i] in (29, 30, 31, 32, 33, 34, 35, 36):
|
||||
weight = 1
|
||||
if data["rsi"][i] < 10:
|
||||
weight = 3 # 8
|
||||
|
||||
if i <= 20:
|
||||
weight = 1
|
||||
|
||||
return buy, weight, sell
|
||||
|
||||
def checkStatus(self, STOCK, last_index):
|
||||
status = set()
|
||||
|
||||
@@ -235,7 +287,9 @@ class BS:
|
||||
|
||||
# stochastic 계산
|
||||
stochastic_df = self.stochastic.apply(pd.DataFrame(STOCK))
|
||||
stochastic_df = stochastic_df.fillna(100)
|
||||
stochastic_df['fast_k'] = stochastic_df['fast_k'].fillna(float(stochastic_df['fast_k'].iloc[9]))
|
||||
stochastic_df['slow_k'] = stochastic_df['slow_k'].fillna(float(stochastic_df['slow_k'].iloc[14]))
|
||||
stochastic_df['slow_d'] = stochastic_df['slow_d'].fillna(float(stochastic_df['slow_d'].iloc[19]))
|
||||
fast_k = stochastic_df['fast_k'].values.tolist()
|
||||
slow_k = stochastic_df['slow_k'].values.tolist()
|
||||
slow_d = stochastic_df['slow_d'].values.tolist()
|
||||
|
||||
Reference in New Issue
Block a user