-2
$\begingroup$
def getTEvents(gRaw, h):
    tEvents, sPos, sNeg = [], 0, 0
    diff = np.log(gRaw).diff().dropna()
    for i in tqdm(diff.index[1:]):
        try:
            pos, neg = float(sPos+diff.loc[i]), float(sNeg+diff.loc[i])
        except Exception as e:
            print (e)
            print (sPos+diff.loc[i], type(sPos+diff.loc[i]))
            print(sNeg+diff.loc[i], type(sNeg+diff.loc[i]))
            break
        sPos, sNeg=max(0., pos), min(0., neg)
        if sNeg<-h:
            sNeg=0;tEvents.append(i)
        elif sPos>h:
            sPos=0;tEvents.append(i)
    return pd.DatetimeIndex(tEvents)       

getTEvents(df0['Close'], 10000) #

Name Error: tdqm not defined

I don't understand what tdqm is either and where the cusum is done.

$\endgroup$

1 Answer 1

4
$\begingroup$

tqdm is a simple package for progress bars in Python. I am not familiar with the code you have copy pasted but most likely you haven't installed tqdm on your machine. You can find more documentation here (a quick google search would have revealed this as well). To fix your issue, you can run pip install tqdm in cmd and then import the package in your Python script via from tqdm import tqdm.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.