def __recountRsi(self):
"""??K??RSI"""
if self.inputRsiLen <= 0: return
# 1?lineBar?????????
if len(self.lineBar) < self.inputRsiLen+2:
self.debugCtaLog(u'?????,??Bar?????{0}???RSI???{1}'.
format(len(self.lineBar), self.inputRsiLen+2))
return
# 3?inputRsiLen(????????????
listClose=[x.close for x in self.lineBar[-self.inputRsiLen - 2:]]
barRsi = ta.RSI(numpy.array(listClose, dtype=float), self.inputRsiLen)[-1]
barRsi = round(float(barRsi), 3)
l = len(self.lineRsi)
if l > self.inputRsiLen*8:
del self.lineRsi[0]
self.lineRsi.append(barRsi)
if l > 3:
# ?
if self.lineRsi[-1] < self.lineRsi[-2] and self.lineRsi[-3] < self.lineRsi[-2]:
t={}
t["Type"] = u'T'
t["RSI"] = self.lineRsi[-2]
t["Close"] = self.lineBar[-2].close
if len(self.lineRsiTop) > self.inputRsiLen:
del self.lineRsiTop[0]
self.lineRsiTop.append( t )
self.lastRsiTopButtom = self.lineRsiTop[-1]
# ?
elif self.lineRsi[-1] > self.lineRsi[-2] and self.lineRsi[-3] > self.lineRsi[-2]:
b={}
b["Type"] = u'B'
b["RSI"] = self.lineRsi[-2]
b["Close"] = self.lineBar[-2].close
if len(self.lineRsiButtom) > self.inputRsiLen:
del self.lineRsiButtom[0]
self.lineRsiButtom.append(b)
self.lastRsiTopButtom = self.lineRsiButtom[-1]
评论列表
文章目录