init
This commit is contained in:
@@ -1066,9 +1066,9 @@ if __name__ == "__main__":
|
||||
stockFileName = os.path.join(RESOURCE_PATH, 'stock.db')
|
||||
analyzer = AnalyzerSqlite(stockFileName)
|
||||
|
||||
analyzer.analyzeDaily()
|
||||
analyzer.analyzeGrouping("weekly")
|
||||
analyzer.analyzeGrouping("monthly")
|
||||
#analyzer.analyzeDaily()
|
||||
#analyzer.analyzeGrouping("weekly")
|
||||
#analyzer.analyzeGrouping("monthly")
|
||||
|
||||
# HTML 출력
|
||||
outPath = os.path.join(PROJECT_HOME, "resources", "analysis")
|
||||
|
||||
@@ -574,65 +574,42 @@ class Common:
|
||||
|
||||
def check_optimal_buy_timeing(self, stock):
|
||||
|
||||
if stock['slow_k'][0] is None:
|
||||
return False
|
||||
min_macd = min(stock['macd']) / 2
|
||||
|
||||
max_vol_5 = max(stock['volume'][0: 4])
|
||||
max_vol_30 = max(stock['volume'][4: 24])
|
||||
if max_vol_30 < max_vol_5:
|
||||
if stock['open'][1] < stock['close'][1] and stock['volume'][1] < stock['volume'][0]:
|
||||
# if stock['open'][i - 1] < stock['close'][i - 1] and stock['volume'][i - 1] < stock['volume'][i]:
|
||||
# 매수전략 #1: 깊은 하락
|
||||
if (stock['macd'][0] < min_macd) and (stock['macdo'][1] <= 0 and 0 < stock['macdo'][0]):
|
||||
if stock['close'][0] < stock['avg200'][0]:
|
||||
weight = 0.5
|
||||
buy = stock['close'][0]
|
||||
type = 'method1'
|
||||
|
||||
# 1) 스토캐스틱 과매도
|
||||
slow_k_buy = False
|
||||
for idx in range(0, 10):
|
||||
if stock['slow_k'][idx] < 20:
|
||||
slow_k_buy = True
|
||||
break
|
||||
# 매수전략 #2: RSI 과매도 이후 골든크로스
|
||||
if (stock['macd'][1] < stock['macds'][1] and stock['macds'][0] < stock['macd'][0]):
|
||||
canBuy = False
|
||||
for c in range(1, 11):
|
||||
if stock['rsi'][0 - c] < 10:
|
||||
canBuy = True
|
||||
break
|
||||
if canBuy:
|
||||
weight = 3
|
||||
buy = stock['close'][0]
|
||||
type = 'method2'
|
||||
|
||||
# 2) macd 교차 신호
|
||||
macd_buy = False
|
||||
if slow_k_buy:
|
||||
for idx in range(0, 10):
|
||||
if stock['macd'][idx+1] < 0 and stock['macds'][idx+1] < 0 and stock['macd'][idx] < 0 and stock['macds'][idx] < 0:
|
||||
if stock['macd'][idx+1] < stock['macds'][idx+1] and stock['macd'][idx] > stock['macds'][idx]:
|
||||
macd_buy = True
|
||||
break
|
||||
|
||||
# 3) RSI 지수가 50위로 올라갈 때
|
||||
if macd_buy:
|
||||
if stock['rsi'][1] < 40 and stock['rsi'][0] > 40:
|
||||
return True
|
||||
|
||||
|
||||
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
|
||||
# 매수전략 #3: 다이버전스
|
||||
if (stock['macd'][1] < stock['macds'][1] and stock['macds'][0] < stock['macd'][0]):
|
||||
canBuy = False
|
||||
index = 0
|
||||
for c in range(1, 41):
|
||||
if stock['macd'][0 - c - 1] < stock['macds'][0 - c - 1] and stock['macds'][0 - c] < stock['macd'][0 - c]:
|
||||
canBuy = True
|
||||
index = c
|
||||
break
|
||||
if canBuy and stock['rsi'][0 - index] < 30:
|
||||
if (stock['macd'][0 - index] < stock['macd'][0] and
|
||||
min(stock['open'][0], stock['close'][0]) < min(stock['open'][0 - index], stock['close'][0 - index])):
|
||||
weight = 2
|
||||
buy = stock['close'][0]
|
||||
type = 'method3'
|
||||
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user