I have been trying to learn quant related things on my own. I recently picked up a book called "Advances in Financial Machine Learning" by Marcos Lopez De Prado. I am having difficulty understanding some of the concepts in the book. I will explain whats written in the book followed my interpretation. Please let me know if I am right or wrong.

From textbook:

Consider a sequence of ticks {($p_t,v_t$)}$_{t=1,..,T}$, where $p_t$ is the price associated with t and $v_t$ is the volume associated with tick t. The so-called tick rule defines a sequence {$b_t$}$_{t=1,...,T}$ where

$b_t=\begin{cases}b_{t-1}, & \text{if}\ \Delta p_t = 0 \\ \frac{|\Delta p_t|}{\Delta p_t} ,& \text{if} \Delta p_t \neq 0 \end{cases}---(1)$

with $b_t\in${-1,1}, and the boundary condition $b_0$ is set to match the terminal value $b_T$ from the immediately preceding bar. The idea behind tick imbalance bars (TIBs) is to sample bars whenever tick imbalances exceed our expectations. We wish to determine the tick index, T, such that the accumulation of signed ticks (signed according to the tick rule) exceeds a given threshold. Next, let us discuss the procedure to determine T.

First we define the tick imbalance at time T as

$\theta_T = \sum_{t = 1}^{T}b_t---(2)$

Second, we compute the expected value of $\theta_T$ at the beginning of the bar,

$E_o[T] = E_0[T](P[b_t = 1]-P[b_t = -1]---(3)$,

where $E_0[T]$ is expected size of the tick bar,

$P[b_t=1]$ is the unconditional probability that a tick is classified as a buy,

$P[b_t = -1]$ is unconditional probability that a tick is classified as a sell.

Since $P[b_t = 1] + P[b_t = -1] = 1$, then $E_0[\theta_T] = E_0[T](2P[b_t = 1] - 1)$. In practice we can estimate $E_0[T]$ as an exponentially weighted moving average of T values from prior bars, and ($2P[b_t = 1] - 1$) as an exponentially weighted moving average of $b_t$ values from prior bars.

Third, we deine a tick imbalance bar (TIB) as a $T^*$ - contiguous subset of ticks such that the following condition is met:

$T^* = \underset{T}{Argmin} (|\theta_T| \geq E_0[T]|2P[b_t = 1] - 1) ---(4)$


  1. My understanding is that first we create $b_t$ matrix. Then we use equation (3) to understand the size of number of ticks in a bar (correct?)

  2. $E_0[T]$ is exponentially weighted average of T, how do we calculate the first $E_0[T]$ when we dont have record of any previous T?

  3. Similar to question 2, ($2P[b_t = 1] - 1$) how is the first weighted average of $b_t$ prior bar is cacluated?

I am trying to learn this on my own, I apologize in advance if I had made any mistakes or broke the community rules. If you can suggest me a place to learn these all, I would really appreciate it


1 Answer 1


There is an open source hedge fund project which is implementing the ideas contained in the book and which has a github where you can see their code implementation of tick bars. Personally I always find it extremely enlightening to see code rather than mathematical symbolism, and maybe this will be the same for you. On the linked pages there are also links to discussion pages etc. which you might also find useful.

  • $\begingroup$ thanks for your answer. I saw their code. Since I am not familiar with Python, it was difficult for be to understand. $\endgroup$ Commented Mar 24, 2019 at 13:35

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.