我正在尝试使用 pandas 在 python 中制作阿隆指示器。然而我得到了错误的价值观......任何人都可以帮助指出我错在哪里......
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())
(down) 列的值应始终为正,并且 (since_low) 列的值应小于 14。
任何帮助将不胜感激..谢谢
https://dpaste.de/kJJW
Error
code
我也在寻找相同的指标然后发现了我修改的这段代码
def aroon(data, lb=25):
df = data.copy()
df['up'] = 100 * df.High.rolling(lb + 1).apply(lambda x: x.argmax()) / lb
df['dn'] = 100 * df.Low.rolling(lb + 1).apply(lambda x: x.argmin()) / lb
return df['up'], df['dn']
这是我的图片1
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)