代码拉取完成,页面将自动刷新
同步操作将从 macroan/traderStock-gui 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#coding=utf-8
class Boll:
__instance = None
def __init__(self):
pass
@classmethod
def getInstance(cls):
if(cls.__instance == None):
cls.__instance = Boll()
return cls.__instance
#计算boll
def set_boll_data(self, df, type=1):
if df is None or df.shape[0] <= 0:
return None
n = 20
multiple = 2
df2 = df.copy()
#计算布林带的中轨线,上轨线,下轨线
#df2['boll_tp'] = (df['high'] + df['low'] + df['close'])/3
#df2['boll_sd'] = df2['boll_tp'].rolling(window=n, center=False).std()
#df['boll_mid'] = df2['boll_tp'].rolling(window=n, center=False).mean()
#df['boll_up'] = df['boll_mid'] + df2['boll_sd'] * multiple
#df['boll_down'] = df['boll_mid'] - df2['boll_sd'] * multiple
#计算布林带的中轨线,上轨线,下轨线
df['boll_mid'] = df['close'].rolling(window=n, center=False).mean()
df2['boll_sd'] = df['close'].rolling(window=n, center=False).std()
df['boll_up'] = df['boll_mid'] + df2['boll_sd'] * multiple
df['boll_down'] = df['boll_mid'] - df2['boll_sd'] * multiple
return df
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。