これはグループオーナーが手書きしたオープンソースのATR関数で,TALIB機能を使わないPANDAS版を書いてください.
def ATR (記録,期間=14):
if len (レコード) == 0:
返信 []
記録に
R = Std._zeros(len(records))
m = 0.0
n = 0.0
for i in xrange(0, len(records)):
TR = 0
if i == 0:
TR = records[i]['High'] - records[i]['Low']
else:
TR = max(records[i]['High'] - records[i]['Low'], abs(records[i]['High'] - records[i - 1]['Close']), abs(records[i - 1]['Close'] - records[i]['Low']))
m += TR
if i < period:
n = m / (i + 1)
else:
n = (((period - 1) * n) + TR) / period
R[i] = n
return R
小草速度は同じです