init
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
|
||||
from stock.analysis.MovingAverage import MovingAverage
|
||||
|
||||
class Common:
|
||||
|
||||
# 상향
|
||||
@@ -586,4 +588,52 @@ class Common:
|
||||
for c in range(1, 4):
|
||||
if stock['close'][c] < stock['bolingerband_lower'][c]:
|
||||
return True
|
||||
return False
|
||||
return False
|
||||
|
||||
# OBV (최저점에서 누적 거래량) 체크
|
||||
def check_obv(self, stock):
|
||||
lowest_index = -1
|
||||
p_price = 99999999999999
|
||||
size = len(stock['close'])
|
||||
for i in range(size):
|
||||
if stock['low'][i] < p_price:
|
||||
p_price = stock['low'][i]
|
||||
lowest_index = i
|
||||
|
||||
if lowest_index > 600:
|
||||
lowest_index = 600
|
||||
|
||||
obv = 0
|
||||
obvs = []
|
||||
for i in range(lowest_index, -1, -1):
|
||||
if stock['open'][i] < stock['close'][i]:
|
||||
obv += stock['volume'][i]
|
||||
elif stock['close'][i] < stock['open'][i]:
|
||||
obv -= stock['volume'][i]
|
||||
|
||||
obvs.append(obv)
|
||||
|
||||
q_5 = MovingAverage(5)
|
||||
q_20 = MovingAverage(20)
|
||||
q_60 = MovingAverage(60)
|
||||
|
||||
if len(obvs) > 60:
|
||||
for i in range(len(obvs)):
|
||||
q_5.enqueue(obvs[i])
|
||||
q_20.enqueue(obvs[i])
|
||||
q_60.enqueue(obvs[i])
|
||||
|
||||
stock['obv5'].append( q_5.avg() )
|
||||
stock['obv20'].append( q_20.avg() )
|
||||
stock['obv60'].append( q_60.avg() )
|
||||
lowest_index -= 1
|
||||
|
||||
stock['obv5'] = list(reversed(stock['obv5']))
|
||||
stock['obv20'] = list(reversed(stock['obv20']))
|
||||
stock['obv60'] = list(reversed(stock['obv60']))
|
||||
|
||||
obvs = list(reversed(obvs))
|
||||
if len(obvs) > 60 and obv > 0:
|
||||
return obv
|
||||
|
||||
return -1
|
||||
|
||||
Reference in New Issue
Block a user