相关疑难解决方法(0)

使用Python编写指数移动平均值

我想对数据帧的三列进行计算df.为了做到这一点,我想在三列表中运行资产(加密货币)列表的价格,以便在有足够的数据后计算它们的指数移动平均值.

def calculateAllEMA(self,values_array):
    df = pd.DataFrame(values_array, columns=['BTC', 'ETH', 'DASH'])
    column_by_search = ["BTC", "ETH", "DASH"]
    print(df)
    for i,column in enumerate(column_by_search):
        ema=[]
        # over and over for each day that follows day 23 to get the full range of EMA
        for j in range(0, len(column)-24):
            # Add the closing prices for the first 22 days together and divide them by 22.
            EMA_yesterday = column.iloc[1+j:22+j].mean()
            k = float(2)/(22+1)
            # getting the first EMA day by taking the following day’s (day 23) …
Run Code Online (Sandbox Code Playgroud)

python math finance python-3.x pandas

3
推荐指数
2
解决办法
6117
查看次数

标签 统计

finance ×1

math ×1

pandas ×1

python ×1

python-3.x ×1