Summary
ImbalanceBarGenerator builds López de Prado–style volume imbalance bars: signed
volume (tick-rule sign on close) accumulates until its absolute value hits a threshold,
then the bar closes and the imbalance resets.
Update API
import rtta
ind = rtta.ImbalanceBarGenerator(threshold=10000.0)
result = ind.update(close, volume)
# result.bar_open, bar_close, bar_high, bar_low, bar_volume,
# result.direction, result.complete, result.bars
bar_volume is \(|I_t|\) (absolute cumulative signed volume). direction on completion
is the sign of the imbalance. Flat ticks (unchanged close) contribute sign \(0\).
Theory Of Operation
Imbalance bars close when buy and sell volume become sufficiently asymmetric, so bar frequency rises in one-sided markets and falls when flow is balanced. Sign uses the tick rule: uptick \(\Rightarrow +1\), downtick \(\Rightarrow -1\), flat \(\Rightarrow 0\). Unlike volume/dollar bars, overshoot is not split into multiple bars in one tick: a single completion resets imbalance to zero.
Recurrence
Let \(V^\star > 0\) be threshold. After the first tick (seed OHLC, \(I=0\)):
Update running \(H,L\) from \(c_t\). If \(|I_t| \ge V^\star\):
Otherwise \(\mathrm{complete}=0\), \(\mathrm{bar\_volume}=|I_t|\), direction \(0\).
Implementation Notes
The recurrence is implemented in src/rtta/indicator.cpp in
class ImbalanceBarGenerator. Result type is InformationBarResult.
