technical_indicators.py 文件源码

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

项目:pytrade-me 作者: arshpreetsingh 项目源码 文件源码
def moving_average(x, n, type='simple'):
    """
    compute an n period moving average.

    type is 'simple' | 'exponential'

    """
    x = np.asarray(x)
    if type == 'simple':
        weights = np.ones(n)
    else:
        weights = np.exp(np.linspace(-1., 0., n))

    weights /= weights.sum()

    a = np.convolve(x, weights, mode='full')[:len(x)]
    a[:n] = a[n]
    return a
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号