如何使用Python pandas构建aroon指标

问题描述 投票:-2回答:1

我正在尝试使用pandas在python中制作aroon指标。但是我得到了错误的价值......任何人都可以帮我指出我哪里错了...

import pandas as pd
import Bitmex_OHLC
import numpy as np
import importlib

def aroon():
    importlib.reload(Bitmex_OHLC)
    df_aroon = Bitmex_OHLC.OHLC()
    df_aroon['14L_min'] = df_aroon['low'].rolling(window=14,min_periods=0).min()
    df_aroon['14H_max'] = df_aroon['high'].rolling(window=14,min_periods = 0).max()
    df_aroon['ind'] = range(0,len(df_aroon))
    # recent_high = df_aroon.iloc[-1]["25d High"]
    df_aroon['high_ind'] = df_aroon['ind'].where(df_aroon["14H_max"]==df_aroon['high']).fillna(method = 'ffill')
    df_aroon['low_ind'] = df_aroon['ind'].where(df_aroon["14L_min"] == df_aroon['low']).fillna(method = 'ffill')
    df_aroon['since_high'] = df_aroon['ind']-df_aroon['high_ind']
    df_aroon['since_low'] = df_aroon['ind'] - df_aroon['low_ind']
    df_aroon['up'] = (((14 - df_aroon['since_high'])/14) *100)
    df_aroon['down'] = (((14 - df_aroon['since_low']) / 14) * 100)
    return (df_aroon)

print(aroon().tail())

(向下)列的值应该始终为正,而(since_low)列应该小于14。

任何帮助将不胜感激.. Thanx

https://dpaste.de/kJJW Error enter image description here code enter image description here

python pandas finance quantitative-finance indicator
1个回答
1
投票

嗨,我是一个新手,希望使用quantopian有兴趣使用Aroon.Found这在我的搜索中。看起来比你的代码简单,并相信它使用ta-lib。 https://github.com/FreddieWitherden/ta/blob/master/ta.py

© www.soinside.com 2019 - 2024. All rights reserved.