# Why does a name error appear? adv_fml_lopez de prado. python 3.7 colab

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.

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.