Skip to content

Instantly share code, notes, and snippets.

View quant-views's full-sized avatar

Denny Joseph quant-views

View GitHub Profile
@quant-views
quant-views / Imbalance-bars-FINAL.py
Created March 30, 2022 07:32
Imbalance bars implementation based on the book Advances in Financial Machine Learning by Marcos Lopez de Prado
def delta(df):
a = np.diff(df['Price'])
a = np.insert(a, 0, 0)
df['Delta'] = a
return df
def labelling(df):
b = np.ones(len(df['Price']))
for i, delta in enumerate(df['Delta']):
if i > 0: