求教帖,基于boll轨实时的监控该怎么编写代码

Author: , Created: 2019-10-18 18:20:54, Updated:

监控实时价格位于boll轨的什么位置代码应该怎么编写


More

bk_fund currentPrice设置为当前tick.Last的价格,可以获得实时的价格处于boll的位置

bk_fund def boll_locateB_bandWidth(closeArr, currentPrice=None, time_period=20, critical_std=2.5, ma_type=0): """ locateB: (最新价 - 下轨)/ (上轨 - 下轨) bandWidth: 带宽指标, (上轨 - 下轨) / 中轨 1.locateB描述了市场的最新价在布林带中所处的位置, locateB > 1, 说明价格在上轨之上; locateB < 0, 说明价格在下轨之下; locateB = 0.5, 价格处于中轨 2.locateB在进行交易决策时,是非常有用的工具 3.带宽指标以相对的概念,描述了布林线宽度的变化 4.带宽可以用于识别布林线的收敛性 5.带宽可以用于识别市场趋势的开始和结束 """ closeArr = np.array(closeArr) upperband, middleband, lowerband = talib.BBANDS(closeArr, timeperiod=time_period, nbdevup=critical_std, nbdevdn=critical_std, matype=ma_type) lastClose = closeArr[-1] lastUpper = upperband[-2] lastMiddle = middleband[-2] lastLower = lowerband[-2] bandWidth = (lastUpper - lastLower) / lastMiddle diff_middle = middleband[-1] - middleband[-time_period] # 计算locateB的值 if currentPrice is None: locateB = (lastClose - lastLower) / (lastUpper - lastLower) return round(locateB,3), round(bandWidth, 3), round(diff_middle,3) else: locateB = (currentPrice - lastLower) / (lastUpper - lastLower) return round(locateB,3), round(bandWidth, 3), round(diff_middle,3)

小草 这个还是比较简单的,学习一下基础,和画图类库很容易 https://www.fmz.com/bbs-topic/4158