def get_bbands(sorted_data):
close,high,low,ma5,ma10,ma20 = get_case_data(sorted_data)
upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
#??%b???????????
operator = ''
# score = 0
index_b = (close[-1]-lowerband[-1]) / (upperband[-1]-lowerband[-1])
# print "%b is : " + str(index_b)
if index_b > 1:
operator += 'S%'
# score -= 10
elif index_b <= 0 :
operator += 'B%'
# score += 10
#??????????????
up = upperband[-1] - upperband[-2]
down = lowerband[-2] -lowerband[-1]
if up > 0 and down > 0:
if up > down:
operator += 'BO'
elif up < down:
operator += 'SO'
if ma5[-1] > ma10[-1] and ma10[-1] > ma20[-1]:
if upperband[-1] < upperband[-2]:
operator += 'S!'
return (operator,index_b)
#initial the date
评论列表
文章目录