1 Star 0 Fork 16

小鹏/traderStock-gui

forked from macroan/traderStock-gui 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
boll.py 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
macroan 提交于 2017-05-18 15:33 . 加入美股的下载更新
#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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/xiaopengshijie/traderStock-gui.git
git@gitee.com:xiaopengshijie/traderStock-gui.git
xiaopengshijie
traderStock-gui
traderStock-gui
master

搜索帮助