[Python]Choppiness index
8691 단어 색인talibstatistics파이썬Finance
I was looking for an indicator to identify sideways trend of a market and came across this index called "Choppiness index".I made it because the index was not in Ta-Lib, so please feel free to use it if you are interested.
Choppiness index 견적서 reference
htps //w w.ぃそ ft. 코 m / 테친 d / 조금 네 s
Talib
htps : // 기주 b. 코 m / mrjbq7 / 타 ぃ b
중요한 계산 부분 Important calculation part
tp의 기본 설정은 "14"인 것 같습니다 the basic setting of tp is "14"according to the webisite
ATR = ta.ATR(high,low,close, timeperiod=tp)
nmrt = np.log10(np.sum(ATR[i-tp:i])/(max(high[i-tp:i])-min(low[i-tp:i])))
dnmnt = np.log10(tp)
choppiness = 100*nmrt / dnmnt
Pandas DataFrame1 -> calculation -> pandas DataFrame2
choppiness.py
import talib as ta
import numpy as np
import pandas as pd
from collections import deque
def choppiness(tp,candlestick):
high = candlestick["high"]
low = candlestick["low"]
close = candlestick["close"]
ATR = ta.ATR(high,low,close, timeperiod=tp)
Timestamp = deque()
CP = deque()
for i in range(len(candlestick)):
if i < tp*2:
Timestamp.append(candlestick.index[i])
CP.append(0)
else:
nmrt = np.log10(np.sum(ATR[i-tp:i])/(max(high[i-tp:i])-min(low[i-tp:i])))
dnmnt = np.log10(tp)
Timestamp.append(candlestick.index[i])
CP.append(round(100*nmrt / dnmnt))
CP = pd.DataFrame({"CP" : CP}, index=Timestamp)
return CP
example of DataFrame1
example of DataFrame2
graph of the result above
틀린 부분이나 효율화할 수 있는 부분이 있으면 코멘트 받을 수 있는 다행입니다.
Please leave your comment if there is anything wrong or to make it more efficient
Reference
이 문제에 관하여([Python]Choppiness index), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/hoshitter1/items/d241cd2d13b72df9a204텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)