This commit is contained in:
dsyoon
2023-11-08 23:06:08 +09:00
parent 9dbb0c4247
commit 5ec0d59072
7 changed files with 283 additions and 216 deletions

View File

@@ -290,9 +290,8 @@ if __name__ == "__main__":
PROJECT_HOME = os.getcwd() PROJECT_HOME = os.getcwd()
RESOURCE_PATH = os.path.join(PROJECT_HOME, "resources") RESOURCE_PATH = os.path.join(PROJECT_HOME, "resources")
day_list = ['20231016', '20231017', '20231018', '20231019', '20231020', #day_list = ['20231016', '20231017', '20231018', '20231019', '20231020', '20231023', '20231024', '20231025', '20231026', '20231027', '20231030', '20231031', '20231101', '20231102']
'20231023', '20231024', '20231025', '20231026', '20231027', day_list = ['20231102']
'20231030', '20231031', '20231101', '20231102']
# to check bying # to check bying
stock = {'code': '252670', 'name': 'KODEX 200선물인버스2X', 'ymd': day_list} stock = {'code': '252670', 'name': 'KODEX 200선물인버스2X', 'ymd': day_list}

View File

@@ -7,53 +7,78 @@ class BuySellChecker_122630 (BuySellChecker):
return return
def getBuyPriceAndWeight(self, stock_code, i, data, INFO): def getBuyPriceAndWeight(self, stock_code, i, data, INFO):
buy, weight = -1, -1 buy, weight, type = -1, -1, ""
C_MIN_AVG_5_200 = max(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i], data['disparity_avg200'][i]) - min(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i], data['disparity_avg200'][i]) """
C_MIN_AVG_5_60 = max(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i]) - min(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i]) #매수전략 #0: 기준선 위에서 골든크로스
if (0 < data['macd'][i] and 0 < data['macds'][i]):
MIN_AVG_5_200 = 0.002 if (data['macd'][i-1] < data['macds'][i-1] and data['macds'][i] < data['macd'][i]):
MIN_AVG_5_60 = 0.002 canBuy = False
DIFF_200_5 = 0.001 for c in range(1, 11):
if data['macd'][i - c] < 0:
if (abs(data['disparity_avg200'][i] - data['disparity_avg5'][i]) < DIFF_200_5 and C_MIN_AVG_5_200 < MIN_AVG_5_200 and C_MIN_AVG_5_60 < MIN_AVG_5_60): canBuy = True
if data['avg200'][i] < data['avg5'][i]: break
if 180 < i: if canBuy:
valid = True
for c in range(5, 181):
if data['avg200'][-c] < data['avg200'][-c]:
valid = False
break
if valid:
if max(data['volume'].tolist()[i-10:i]) < data['volume'][i]:
buy = data['close'][i]
weight = 1
if data['open'][i-2] < data['close'][i-2] and data['open'][i-1] < data['close'][i-1] and data['open'][i] < data['close'][i]:
buy = data['close'][i]
weight = 1
if data['macd'][i-1] < -1000:
if -1000 < data['macd'][i]:
buy = data['close'][i]
weight = 1 weight = 1
buy = data['close'][i]
type = 'method0'
"""
# 매수전략 #1: 깊은 하락
if (data['macd'][i]<-1000) and (data['macdo'][i-1] <= 0 and 0 < data['macdo'][i]):
if data['close'][i] < data['avg200'][i]:
weight = 0.5
buy = data['close'][i]
type = 'method1'
# 매수전략 #2: RSI 과매도 이후 골든크로스
if (data['macd'][i - 1] < data['macds'][i - 1] and data['macds'][i] < data['macd'][i]):
canBuy = False
for c in range(1, 11):
if data['rsi'][i-c] < 10:
canBuy = True
break
if canBuy:
weight = 3
buy = data['close'][i]
type = 'method2'
# 매수전략 #3: 다이버전스
if (data['macd'][i - 1] < data['macds'][i - 1] and data['macds'][i] < data['macd'][i]):
canBuy = False
index = 0
for c in range(1, 41):
if data['macd'][i-c-1] < data['macds'][i-c-1] and data['macds'][i-c] < data['macd'][i-c]:
canBuy = True
index = c
break
if canBuy and data['rsi'][i-index] < 30:
if (data['macd'][i-index] < data['macd'][i] and
min(data['open'][i], data['close'][i]) < min(data['open'][i-index], data['close'][i-index])):
weight = 2
buy = data['close'][i]
type = 'method3'
return buy, weight return buy, weight
def checkTransaction(self, stock_code, data, INFO, isRealTime=True): def getSellPriceAndWeight(self, stock_code, i, data, INFO):
sell, weight = -1, -1 sell, weight, type = -1, -1, ""
if data['close'][i] < INFO['LIMIT_PRICE'] < data['close'][i-1]: # 매수전략 #1: 높은 상승
sell = data['close'][i] if (350 < data['macd'][i] or 300 < data['macds'][i]) and (0 < data['macdo'][i-1] and data['macdo'][i] <= 0):
weight = 1
if (650 < data['macd'][i]) and (0 < data['macdo'][i-1] and data['macdo'][i] <= 0):
#if data['macds'][i-1] < data['macd'][i-1] and data['macd'][i] < data['macds'][i]: #if data['macds'][i-1] < data['macd'][i-1] and data['macd'][i] < data['macds'][i]:
weight = 1 weight = 1
sell = data['close'][i] sell = data['close'][i]
type = 'method1'
if data['close'][i] < INFO['LIMIT_PRICE']: # 매수전략 #2: RSI 과매수에서 데드크로스
weight = 1 if (data['macds'][i - 1] < data['macd'][i - 1] and data['macd'][i] < data['macds'][i]):
sell = data['close'][i] if 80 < data['rsi'][i]:
weight = 1
sell = data['close'][i]
type = 'method2'
return sell, weight return sell, weight

View File

@@ -7,57 +7,81 @@ class BuySellChecker_233740 (BuySellChecker):
return return
def getBuyPriceAndWeight(self, stock_code, i, data, INFO): def getBuyPriceAndWeight(self, stock_code, i, data, INFO):
buy, weight = -1, -1 buy, weight, type = -1, -1, ""
C_MIN_AVG_5_200 = max(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i], data['disparity_avg200'][i]) - min(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i], data['disparity_avg200'][i]) """
C_MIN_AVG_5_60 = max(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i]) - min(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i]) #매수전략 #0: 기준선 위에서 골든크로스
if (0 < data['macd'][i] and 0 < data['macds'][i]):
MIN_AVG_5_200 = 0.002 if (data['macd'][i-1] < data['macds'][i-1] and data['macds'][i] < data['macd'][i]):
MIN_AVG_5_60 = 0.002 canBuy = False
DIFF_200_5 = 0.001 for c in range(1, 11):
if data['macd'][i - c] < 0:
if (abs(data['disparity_avg200'][i] - data['disparity_avg5'][i]) < DIFF_200_5 and C_MIN_AVG_5_200 < MIN_AVG_5_200 and C_MIN_AVG_5_60 < MIN_AVG_5_60): canBuy = True
if data['avg200'][i] < data['avg5'][i]: break
if 180 < i: if canBuy:
valid = True
for c in range(5, 181):
if data['avg200'][-c] < data['avg200'][-c]:
valid = False
break
if valid:
if max(data['volume'].tolist()[i-10:i]) < data['volume'][i]:
buy = data['close'][i]
weight = 1
if data['open'][i-2] < data['close'][i-2] and data['open'][i-1] < data['close'][i-1] and data['open'][i] < data['close'][i]:
buy = data['close'][i]
weight = 1
if data['macd'][i-1] < -1000:
if -1000 < data['macd'][i]:
buy = data['close'][i]
weight = 1 weight = 1
buy = data['close'][i]
type = 'method0'
"""
# 매수전략 #1: 깊은 하락
if (data['macd'][i]<-1000) and (data['macdo'][i-1] <= 0 and 0 < data['macdo'][i]):
if data['close'][i] < data['avg200'][i]:
weight = 0.5
buy = data['close'][i]
type = 'method1'
# 매수전략 #2: RSI 과매도 이후 골든크로스
if (data['macd'][i - 1] < data['macds'][i - 1] and data['macds'][i] < data['macd'][i]):
canBuy = False
for c in range(1, 11):
if data['rsi'][i-c] < 10:
canBuy = True
break
if canBuy:
weight = 3
buy = data['close'][i]
type = 'method2'
# 매수전략 #3: 다이버전스
if (data['macd'][i - 1] < data['macds'][i - 1] and data['macds'][i] < data['macd'][i]):
canBuy = False
index = 0
for c in range(1, 41):
if data['macd'][i-c-1] < data['macds'][i-c-1] and data['macds'][i-c] < data['macd'][i-c]:
canBuy = True
index = c
break
if canBuy and data['rsi'][i-index] < 30:
if (data['macd'][i-index] < data['macd'][i] and
min(data['open'][i], data['close'][i]) < min(data['open'][i-index], data['close'][i-index])):
weight = 2
buy = data['close'][i]
type = 'method3'
return buy, weight return buy, weight
def getSellPriceAndWeight(self, stock_code, i, data, INFO): def getSellPriceAndWeight(self, stock_code, i, data, INFO):
sell, weight = -1, -1 sell, weight, type = -1, -1, ""
if data['close'][i] < INFO['LIMIT_PRICE'] < data['close'][i-1]: # 매수전략 #1: 높은 상승
sell = data['close'][i] if (650 < data['macd'][i] or 600 < data['macds'][i]) and (0 < data['macdo'][i-1] and data['macdo'][i] <= 0):
weight = 1
if (650 < data['macd'][i]) and (0 < data['macdo'][i-1] and data['macdo'][i] <= 0):
#if data['macds'][i-1] < data['macd'][i-1] and data['macd'][i] < data['macds'][i]: #if data['macds'][i-1] < data['macd'][i-1] and data['macd'][i] < data['macds'][i]:
weight = 1 weight = 1
sell = data['close'][i] sell = data['close'][i]
type = 'method1'
if data['close'][i] < INFO['LIMIT_PRICE']: # 매수전략 #2: RSI 과매수에서 데드크로스
weight = 1 if (data['macds'][i - 1] < data['macd'][i - 1] and data['macd'][i] < data['macds'][i]):
sell = data['close'][i] if 80 < data['rsi'][i]:
weight = 1
sell = data['close'][i]
type = 'method2'
return sell, weight return sell, weight
def checkTransaction(self, stock_code, data, INFO, isRealTime=True): def checkTransaction(self, stock_code, data, INFO, isRealTime=True):
# 어제 오늘 데이터로 분석 # 어제 오늘 데이터로 분석
bsLine = {} bsLine = {}

View File

@@ -7,57 +7,81 @@ class BuySellChecker_251340 (BuySellChecker):
return return
def getBuyPriceAndWeight(self, stock_code, i, data, INFO): def getBuyPriceAndWeight(self, stock_code, i, data, INFO):
buy, weight = -1, -1 buy, weight, type = -1, -1, ""
C_MIN_AVG_5_200 = max(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i], data['disparity_avg200'][i]) - min(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i], data['disparity_avg200'][i]) """
C_MIN_AVG_5_60 = max(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i]) - min(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i]) #매수전략 #0: 기준선 위에서 골든크로스
if (0 < data['macd'][i] and 0 < data['macds'][i]):
MIN_AVG_5_200 = 0.002 if (data['macd'][i-1] < data['macds'][i-1] and data['macds'][i] < data['macd'][i]):
MIN_AVG_5_60 = 0.002 canBuy = False
DIFF_200_5 = 0.001 for c in range(1, 11):
if data['macd'][i - c] < 0:
if (abs(data['disparity_avg200'][i] - data['disparity_avg5'][i]) < DIFF_200_5 and C_MIN_AVG_5_200 < MIN_AVG_5_200 and C_MIN_AVG_5_60 < MIN_AVG_5_60): canBuy = True
if data['avg200'][i] < data['avg5'][i]: break
if 180 < i: if canBuy:
valid = True
for c in range(5, 181):
if data['avg200'][-c] < data['avg200'][-c]:
valid = False
break
if valid:
if max(data['volume'].tolist()[i-10:i]) < data['volume'][i]:
buy = data['close'][i]
weight = 1
if data['open'][i-2] < data['close'][i-2] and data['open'][i-1] < data['close'][i-1] and data['open'][i] < data['close'][i]:
buy = data['close'][i]
weight = 1
if data['macd'][i-1] < -1000:
if -1000 < data['macd'][i]:
buy = data['close'][i]
weight = 1 weight = 1
buy = data['close'][i]
type = 'method0'
"""
# 매수전략 #1: 깊은 하락
if (data['macd'][i]<-1000) and (data['macdo'][i-1] <= 0 and 0 < data['macdo'][i]):
if data['close'][i] < data['avg200'][i]:
weight = 0.5
buy = data['close'][i]
type = 'method1'
# 매수전략 #2: RSI 과매도 이후 골든크로스
if (data['macd'][i - 1] < data['macds'][i - 1] and data['macds'][i] < data['macd'][i]):
canBuy = False
for c in range(1, 11):
if data['rsi'][i-c] < 10:
canBuy = True
break
if canBuy:
weight = 3
buy = data['close'][i]
type = 'method2'
# 매수전략 #3: 다이버전스
if (data['macd'][i - 1] < data['macds'][i - 1] and data['macds'][i] < data['macd'][i]):
canBuy = False
index = 0
for c in range(1, 41):
if data['macd'][i-c-1] < data['macds'][i-c-1] and data['macds'][i-c] < data['macd'][i-c]:
canBuy = True
index = c
break
if canBuy and data['rsi'][i-index] < 30:
if (data['macd'][i-index] < data['macd'][i] and
min(data['open'][i], data['close'][i]) < min(data['open'][i-index], data['close'][i-index])):
weight = 2
buy = data['close'][i]
type = 'method3'
return buy, weight return buy, weight
def getSellPriceAndWeight(self, stock_code, i, data, INFO): def getSellPriceAndWeight(self, stock_code, i, data, INFO):
sell, weight = -1, -1 sell, weight, type = -1, -1, ""
if data['close'][i] < INFO['LIMIT_PRICE'] < data['close'][i-1]: # 매수전략 #1: 높은 상승
sell = data['close'][i] if (650 < data['macd'][i] or 600 < data['macds'][i]) and (0 < data['macdo'][i-1] and data['macdo'][i] <= 0):
weight = 1
if (650 < data['macd'][i]) and (0 < data['macdo'][i-1] and data['macdo'][i] <= 0):
#if data['macds'][i-1] < data['macd'][i-1] and data['macd'][i] < data['macds'][i]: #if data['macds'][i-1] < data['macd'][i-1] and data['macd'][i] < data['macds'][i]:
weight = 1 weight = 1
sell = data['close'][i] sell = data['close'][i]
type = 'method1'
if data['close'][i] < INFO['LIMIT_PRICE']: # 매수전략 #2: RSI 과매수에서 데드크로스
weight = 1 if (data['macds'][i - 1] < data['macd'][i - 1] and data['macd'][i] < data['macds'][i]):
sell = data['close'][i] if 80 < data['rsi'][i]:
weight = 1
sell = data['close'][i]
type = 'method2'
return sell, weight return sell, weight
def checkTransaction(self, stock_code, data, INFO, isRealTime=True): def checkTransaction(self, stock_code, data, INFO, isRealTime=True):
# 어제 오늘 데이터로 분석 # 어제 오늘 데이터로 분석
bsLine = {} bsLine = {}

View File

@@ -5,64 +5,82 @@ class BuySellChecker_252670 (BuySellChecker):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
return return
def getBuyPriceAndWeight(self, stock_code, i, data, INFO): def getBuyPriceAndWeight(self, stock_code, i, data, INFO):
buy, weight = -1, -1 buy, weight, type = -1, -1, ""
C_MIN_AVG_5_200 = max(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i], data['disparity_avg200'][i]) - min(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i], data['disparity_avg200'][i]) """
C_MIN_AVG_5_60 = max(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i]) - min(data['disparity_avg5'][i], data['disparity_avg20'][i], data['disparity_avg60'][i]) #매수전략 #0: 기준선 위에서 골든크로스
C_DIFF_AVG_200_5 = abs(data['disparity_avg200'][i] - data['disparity_avg5'][i]) if (0 < data['macd'][i] and 0 < data['macds'][i]):
if (data['macd'][i-1] < data['macds'][i-1] and data['macds'][i] < data['macd'][i]):
canBuy = False
for c in range(1, 11):
if data['macd'][i - c] < 0:
canBuy = True
break
if canBuy:
weight = 1
buy = data['close'][i]
type = 'method0'
"""
if 0.004 < C_MIN_AVG_5_60 < 0.005 and 0.007 < C_MIN_AVG_5_200 < 0.008 and 0.007 < C_DIFF_AVG_200_5 < 0.008: # 매수전략 #1: 깊은 하락
buy = data['close'][i] if (data['macd'][i]<-1000) and (data['macdo'][i-1] <= 0 and 0 < data['macdo'][i]):
weight = 1 if data['close'][i] < data['avg200'][i]:
if 0.023 < C_MIN_AVG_5_60 < 0.024 and 0.026 < C_MIN_AVG_5_200 < 0.027 and 0.026 < C_DIFF_AVG_200_5 < 0.027: weight = 0.5
buy = data['close'][i] buy = data['close'][i]
weight = 1 type = 'method1'
if 0.013 < C_MIN_AVG_5_60 < 0.014 and 0.013 < C_MIN_AVG_5_200 < 0.014 and 0.013 < C_DIFF_AVG_200_5 < 0.014:
buy = data['close'][i]
weight = 1
if 0.004 < C_MIN_AVG_5_60 < 0.005 and 0.005 < C_MIN_AVG_5_200 < 0.006 and 0.0008 < C_DIFF_AVG_200_5 < 0.001:
buy = data['close'][i]
weight = 1
if 0.001 < C_MIN_AVG_5_60 < 0.0015 and 0.0055 < C_MIN_AVG_5_200 < 0.006 and 0.0055 < C_DIFF_AVG_200_5 < 0.006:
buy = data['close'][i]
weight = 1
if 0.001 < C_MIN_AVG_5_60 < 0.0015 and 0.0015 < C_MIN_AVG_5_200 < 0.002 and 0.0015 < C_DIFF_AVG_200_5 < 0.002:
buy = data['close'][i]
weight = 1
if 0.009 < C_MIN_AVG_5_60 < 0.0095 and 0.01 < C_MIN_AVG_5_200 < 0.012 and 0.01 < C_DIFF_AVG_200_5 < 0.012:
buy = data['close'][i]
weight = 1
if 0.002 < C_MIN_AVG_5_60 < 0.0023 and 0.0062 < C_MIN_AVG_5_200 < 0.0068 and 0.0062 < C_DIFF_AVG_200_5 < 0.0068:
buy = data['close'][i]
weight = 1
if 0.008 < C_MIN_AVG_5_60 < 0.0085 and 0.008 < C_MIN_AVG_5_200 < 0.0085 and 0.0075 < C_DIFF_AVG_200_5 < 0.008:
buy = data['close'][i]
weight = 1
# 매수전략 #2: RSI 과매도 이후 골든크로스
if (data['macd'][i - 1] < data['macds'][i - 1] and data['macds'][i] < data['macd'][i]):
canBuy = False
for c in range(1, 11):
if data['rsi'][i-c] < 10:
canBuy = True
break
if canBuy:
weight = 3
buy = data['close'][i]
type = 'method2'
# 매수전략 #3: 다이버전스
if (data['macd'][i - 1] < data['macds'][i - 1] and data['macds'][i] < data['macd'][i]):
canBuy = False
index = 0
for c in range(1, 41):
if data['macd'][i-c-1] < data['macds'][i-c-1] and data['macds'][i-c] < data['macd'][i-c]:
canBuy = True
index = c
break
if canBuy and data['rsi'][i-index] < 30:
if (data['macd'][i-index] < data['macd'][i] and
min(data['open'][i], data['close'][i]) < min(data['open'][i-index], data['close'][i-index])):
weight = 2
buy = data['close'][i]
type = 'method3'
return buy, weight return buy, weight
def getSellPriceAndWeight(self, stock_code, i, data, INFO): def getSellPriceAndWeight(self, stock_code, i, data, INFO):
sell, weight = -1, -1 sell, weight, type = -1, -1, ""
if data['close'][i] < INFO['LIMIT_PRICE'] < data['close'][i-1]: # 매수전략 #1: 높은 상승
sell = data['close'][i] if (650 < data['macd'][i] or 600 < data['macds'][i]) and (0 < data['macdo'][i-1] and data['macdo'][i] <= 0):
weight = 1
if (5 < data['macd'][i]) and (0 < data['macdo'][i-1] and data['macdo'][i] <= 0):
#if data['macds'][i-1] < data['macd'][i-1] and data['macd'][i] < data['macds'][i]: #if data['macds'][i-1] < data['macd'][i-1] and data['macd'][i] < data['macds'][i]:
weight = 1 weight = 1
sell = data['close'][i] sell = data['close'][i]
type = 'method1'
if data['close'][i] < INFO['LIMIT_PRICE']: # 매수전략 #2: RSI 과매수에서 데드크로스
weight = 1 if (data['macds'][i - 1] < data['macd'][i - 1] and data['macd'][i] < data['macds'][i]):
sell = data['close'][i] if 80 < data['rsi'][i]:
weight = 1
sell = data['close'][i]
type = 'method2'
return sell, weight return sell, weight
def checkTransaction(self, stock_code, data, INFO, isRealTime=True): def checkTransaction(self, stock_code, data, INFO, isRealTime=True):
# 어제 오늘 데이터로 분석 # 어제 오늘 데이터로 분석
bsLine = {} bsLine = {}

View File

@@ -1066,9 +1066,9 @@ if __name__ == "__main__":
stockFileName = os.path.join(RESOURCE_PATH, 'stock.db') stockFileName = os.path.join(RESOURCE_PATH, 'stock.db')
analyzer = AnalyzerSqlite(stockFileName) analyzer = AnalyzerSqlite(stockFileName)
analyzer.analyzeDaily() #analyzer.analyzeDaily()
analyzer.analyzeGrouping("weekly") #analyzer.analyzeGrouping("weekly")
analyzer.analyzeGrouping("monthly") #analyzer.analyzeGrouping("monthly")
# HTML 출력 # HTML 출력
outPath = os.path.join(PROJECT_HOME, "resources", "analysis") outPath = os.path.join(PROJECT_HOME, "resources", "analysis")

View File

@@ -574,65 +574,42 @@ class Common:
def check_optimal_buy_timeing(self, stock): def check_optimal_buy_timeing(self, stock):
if stock['slow_k'][0] is None: min_macd = min(stock['macd']) / 2
return False
max_vol_5 = max(stock['volume'][0: 4]) # 매수전략 #1: 깊은 하락
max_vol_30 = max(stock['volume'][4: 24]) if (stock['macd'][0] < min_macd) and (stock['macdo'][1] <= 0 and 0 < stock['macdo'][0]):
if max_vol_30 < max_vol_5: if stock['close'][0] < stock['avg200'][0]:
if stock['open'][1] < stock['close'][1] and stock['volume'][1] < stock['volume'][0]: weight = 0.5
# if stock['open'][i - 1] < stock['close'][i - 1] and stock['volume'][i - 1] < stock['volume'][i]: buy = stock['close'][0]
type = 'method1'
# 1) 스토캐스틱 과매도 # 매수전략 #2: RSI 과매도 이후 골든크로스
slow_k_buy = False if (stock['macd'][1] < stock['macds'][1] and stock['macds'][0] < stock['macd'][0]):
for idx in range(0, 10): canBuy = False
if stock['slow_k'][idx] < 20: for c in range(1, 11):
slow_k_buy = True if stock['rsi'][0 - c] < 10:
break canBuy = True
break
if canBuy:
weight = 3
buy = stock['close'][0]
type = 'method2'
# 2) macd 교차 신호 # 매수전략 #3: 다이버전스
macd_buy = False if (stock['macd'][1] < stock['macds'][1] and stock['macds'][0] < stock['macd'][0]):
if slow_k_buy: canBuy = False
for idx in range(0, 10): index = 0
if stock['macd'][idx+1] < 0 and stock['macds'][idx+1] < 0 and stock['macd'][idx] < 0 and stock['macds'][idx] < 0: for c in range(1, 41):
if stock['macd'][idx+1] < stock['macds'][idx+1] and stock['macd'][idx] > stock['macds'][idx]: if stock['macd'][0 - c - 1] < stock['macds'][0 - c - 1] and stock['macds'][0 - c] < stock['macd'][0 - c]:
macd_buy = True canBuy = True
break index = c
break
# 3) RSI 지수가 50위로 올라갈 때 if canBuy and stock['rsi'][0 - index] < 30:
if macd_buy: if (stock['macd'][0 - index] < stock['macd'][0] and
if stock['rsi'][1] < 40 and stock['rsi'][0] > 40: min(stock['open'][0], stock['close'][0]) < min(stock['open'][0 - index], stock['close'][0 - index])):
return True weight = 2
buy = stock['close'][0]
type = 'method3'
if stock['close'][0] < stock['avg200'][0] and stock['open'][0] < stock['close'][0] and max(stock['avg5'][0], stock['avg20'][0], stock['avg200'][0]) < stock['avg60'][0]:
if stock['open'][0] < min(stock['close'][0], stock['avg5'][0], stock['avg20'][0], stock['avg60'][0], stock['avg120'][0]):
if max(stock['volume'][:10]) * 4 < stock['volume'][0]:
if stock['open'][0] < (stock['upper'][0] + stock['lower'][0]) / 2:
return True
if stock['avg200'][0] < stock['avg5'][0] and stock['avg200'][0] < stock['avg20'][0] and stock['avg200'][0] < stock['avg60'][0]:
if stock['open'][0] < stock['close'][0]:
if max(stock['volume'][:10]) * 3 < stock['volume'][0]:
if max(stock['disparity_avg5'][0], stock['disparity_avg20'][0], stock['disparity_avg60'][0]) - min(stock['disparity_avg5'][0], stock['disparity_avg20'][0], stock['disparity_avg60'][0]) < 0.003:
return True
if stock['open'][1] < stock['close'][1] and stock['open'][0] < stock['close'][0]:
if stock['volume'][1] * 10 < stock['volume'][0]:
if stock['upper'][0] < stock['close'][0]:
if max(stock['disparity_avg5'][0], stock['disparity_avg20'][0], stock['disparity_avg60'][0]) - min(stock['disparity_avg5'][0], stock['disparity_avg20'][0], stock['disparity_avg60'][0]) < 0.005:
if max(stock['disparity_avg5'][0], stock['disparity_avg20'][0], stock['disparity_avg60'][0], stock['disparity_avg200'][0]) - min(stock['disparity_avg5'][0], stock['disparity_avg20'][0], stock['disparity_avg60'][0], stock['disparity_avg200'][0]) < 0.006:
if stock['avg200'][0] < min(stock['open'][0], stock['close'][0], stock['avg5'][0], stock['avg20'][0], stock['avg60'][0]):
return True
check = False
for c in range(10):
if stock['close'][c+1] < stock['close'][c+2] < stock['close'][c+3] < stock['close'][c+4] < stock['close'][c+5] < stock['close'][c+6]:
if stock['close'][c+1] < stock['lower'][c+1] and stock['close'][c+2] < stock['lower'][c+2] and stock['close'][c+3] < stock['lower'][c+3] and stock['close'][c+4] < stock['lower'][c+4] and stock['close'][c+5] < stock['lower'][c+5] and stock['close'][c+6] < stock['lower'][c+6]:
check = True
break
if check and stock['close'][0] < stock['lower'][0]:
return True
return False return False