indicator.py 文件源码

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

项目:trading-stock-thailand 作者: adminho 项目源码 文件源码
def get_myRatio(df_price, periods=20):
    # Middle Band = 20-day simple moving average (SMA)
    #df_middle_band = pd.rolling_mean(df_price, window=periods)
    df_middle_band = df_price.rolling(center=False, window=periods).mean()  

    # 20-day standard deviation of price
    """ Pandas uses the unbiased estimator (N-1 in the denominator), 
    whereas Numpy by default does not.
    To make them behave the same, pass ddof=1 to numpy.std()."""    
    #df_std = pd.rolling_std(df_price, window=periods)
    df_std = df_price.rolling(center=False, window=periods).std()

    return (df_price - df_middle_band)/(df_std * 2)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号