technicalanalysis.py 文件源码

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

项目:CandleStick 作者: victorgau 项目源码 文件源码
def MA(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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号