indicators.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:Machine_Learning_Trading_System 作者: historycapital 项目源码 文件源码
def bollinger_band_indicator(price, syms = ['AAPL'], lookback = 21):



    sma = sma_indicator(price)
    #price = compute_prices()

    ###calculate bolling bands(21 day) over the entire period
    rolling_std = price.rolling(window = lookback, min_periods = lookback).std()
    #rolling_std = pd.rolling_std(price, window = lookback, min_periods = lookback)
    top_band = sma + (2 * rolling_std)
    bottom_band = sma - (2 * rolling_std)

    bbp = (price - bottom_band) / (top_band - bottom_band)
    bbp = bbp.fillna(method = 'bfill')

    return bbp,top_band, bottom_band

###Calculate relative strength, then RSI
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号