This commit is contained in:
dsyoon
2022-09-12 21:51:30 +09:00
parent 7efddaad41
commit 6be9112bdb
2 changed files with 98 additions and 22 deletions

View File

@@ -203,16 +203,28 @@ if __name__ == "__main__":
# to check bying
stock_codes = {
"252670": ['20220905']
"122630": [
'20220801', '20220802', '20220803', '20220804', '20220805',
'20220808', '20220809', '20220810', '20220811', '20220812',
'20220816', '20220817', '20220818', '20220819', '20220822',
'20220823', '20220824', '20220825', '20220826', '20220829',
'20220830', '20220831',
'20220901', '20220902', '20220905', '20220906', '20220907',
'20220908'
]
}
"""
"122630": ['20220801', '20220802', '20220803', '20220804', '20220805',
'20220808', '20220809', '20220810', '20220811', '20220812',
'20220816', '20220817', '20220818', '20220819',
'20220822', '20220823', '20220824', '20220825', '20220826', '20220829']
"252670": [
'20220801', '20220802', '20220803', '20220804', '20220805',
'20220808', '20220809', '20220810', '20220811', '20220812',
'20220816', '20220817', '20220818', '20220819', '20220822',
'20220823', '20220824', '20220825', '20220826', '20220829',
'20220830', '20220831',
'20220901', '20220902', '20220905', '20220906','20220907',
'20220908'
],
"""
method = "rule" # "rule", "ml", "answer"
for stock_code in stock_codes:
simulation = Simulation(RESOURCE_PATH)

View File

@@ -113,23 +113,16 @@ class BuySellChecker:
START_TIME_INDEX = c
break
if i > START_TIME_INDEX:
if START_TIME_INDEX + 10 < i < START_TIME_INDEX + 350:
# 매수 분석
if i > 381 + 70:
if data['macdo'][i-1] < data['macdo'][i] and data['macdo'][i] < -10:
buy = max(data["open"][i], data["close"][i])
weight = 1
type = 1
return buy, weight, type
else:
if data['macdo'][i - 1] < data['macdo'][i] and data['macdo'][i] < -10:
if -2 < data['macds'][381]:
buy = max(data["open"][i], data["close"][i])
weight = 1
type = 1
return buy, weight, type
if data['macd'][i] < -7:
buy = max(data["open"][i], data["close"][i])
weight = 1
type = 1
return buy, weight, type
"""
if data['changeLine'][i - 1] <= data['baseLine'][i - 1] and data['baseLine'][i] < data['changeLine'][i]:
changeLine_count = sum([1 if data['changeLine'][c] <= data['baseLine'][c] else 0 for c in range(i-30, i-10)])
if changeLine_count >= 15:
@@ -139,6 +132,7 @@ class BuySellChecker:
weight = 1
type = 1
return buy, weight, type
"""
"""
if i > 381 + 26:
@@ -176,6 +170,72 @@ class BuySellChecker:
return sell, weight, type
def getBuyPriceAndWeight_122630(self, data, i):
buy, weight, type = -1, -1, -1
START_TIME_INDEX = 0
for c in range(370, len(data.index)):
if data.index[c].strftime("%H:%M:%S") == "09:01:00":
START_TIME_INDEX = c
break
if START_TIME_INDEX + 10 < i < START_TIME_INDEX + 350:
# 매수 분석
if data['macd'][i] < -50:
buy = max(data["open"][i], data["close"][i])
weight = 1
type = 1
return buy, weight, type
"""
if data['changeLine'][i - 1] <= data['baseLine'][i - 1] and data['baseLine'][i] < data['changeLine'][i]:
changeLine_count = sum([1 if data['changeLine'][c] <= data['baseLine'][c] else 0 for c in range(i-30, i-10)])
if changeLine_count >= 15:
changeLine_count = sum([1 if data['changeLine'][c] <= data['baseLine'][c] else 0 for c in range(i-10, i)])
if changeLine_count >= 7:
buy = min(data["open"][i], data["close"][i])
weight = 1
type = 1
return buy, weight, type
"""
"""
if i > 381 + 26:
if data['laggingSpan'][i-1] < data['avg3'][i-1] and data['avg3'][i] < data['laggingSpan'][i]:
if self.checkUpDirection(data, i) == 1:
avg20_line = sum([1 if data['avg20'][c] < data['avg20'][c-1] else 0 for c in range(i - 10, i)])
if avg20_line < 10:
if data["macd"][i] < 0:
buy = min(data["open"][i], data["close"][i])
weight = 1
type = 1
return buy, weight, type
"""
return buy, weight, type
def getSellPriceAndWeight_122630(self, data, i):
sell, weight, type = -1, -1, -1
START_TIME_INDEX = 0
for c in range(370, len(data.index)):
if data.index[c].strftime("%H:%M:%S") == "09:01:00":
START_TIME_INDEX = c
break
if i > START_TIME_INDEX:
# 매도 분석
if data['changeLine'][i - 1] >= data['laggingSpan'][i - 1] and data['laggingSpan'][i] < data['changeLine'][i]:
changeLine_count = sum([1 if data['changeLine'][c] <= data['laggingSpan'][c] else 0 for c in range(i - 20, i)])
if changeLine_count >= 17:
sell = min(data["open"][i], data["close"][i])
weight = 1
type = 1
return sell, weight, type
return sell, weight, type
def analyze(self, result):
# 기본 캔들 정보
open = result["open"]
@@ -708,8 +768,12 @@ class BuySellChecker:
bsLine['sell_weight'] = [-1 for i in range(size)]
for i in range(size):
buy, buy_weight, buy_type = self.getBuyPriceAndWeight(data, i)
sell, sell_weight, sell_type = self.getSellPriceAndWeight(data, i)
if stock_code == "252670":
buy, buy_weight, buy_type = self.getBuyPriceAndWeight(data, i)
sell, sell_weight, sell_type = self.getSellPriceAndWeight(data, i)
else:
buy, buy_weight, buy_type = self.getBuyPriceAndWeight_122630(data, i)
sell, sell_weight, sell_type = self.getSellPriceAndWeight_122630(data, i)
if buy > -1 or self.BUY_COUNT == 1:
if buy == -1 or self.BUY_COUNT == 1: