__init__.py 文件源码

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

项目:Informed-Finance-Canary 作者: Darthone 项目源码 文件源码
def calculate_trix(self, window=15):
        """ Triple Exponential Moving Average Smooth the insignificant movements 
                TR(t) / TR(t-1) where 
                TR(t) = EMA(EMA(EMA(Price(t)))) over n days period
        """
        self.set_max_win(window)
        #ignore produced warnings for now #TODO
        ema = pd.ewma(self.df['Adj_Close'], span=window, min_periods=window-1)
        ema = pd.ewma(ema, span=window, min_periods=window-1)
        ema = pd.ewma(ema, span=window, min_periods=window-1)

        roc_l = [0]  
        for i in range(1, len(self.df.index) - 1):  
            roc_l.append((ema[i + 1] - ema[i]) / ema[i])  

        name = "trix_%s" % (window)
        self.df[name] = pd.Series(roc_l)
        return name
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号