3
$\begingroup$

I would really appreciate if any of you can clarify the following questions. I have been struggling to understand it on my own.

  1. $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)

where $p_t$ = price associated with tick t

Question 1: My tick data have both bid and ask side by side. Based on this equation, am I supposed to do bid and ask separately? i.e $b_{bid}$ and $b_{ask}$?

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

T = tick index

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

$E_0$ is estimated by the exponentially weighted moving average of T values from previous bars.

$2P[b_t = 1] -1$ is calculated as an exponentially weighted moving average of $b_t$ values from prior bars.

Question 2: T value for equation 2 is derived from equation 3?

Question 3: My interpretation from equation 2 and 3 is that substitute values into T, calculate $\theta_T$ until it is greater than $E_0[T]|2P[b_t = 1] - 1$. Is this interpretation correct?

I really appreciate anyone's input in this matter. Learning these on my own is tough, but with your help, I should be able to achieve it.

$\endgroup$
2
$\begingroup$

Question 1. Actually, the assumption of trade data format is that you have timestamp, size and price (not bid/ask) of trade. Sometimes, trades(ticks) are included to Level 1 data (also called BBO) which assumes bid and ask information. However, bars are constructed on trades, not quotes.

Question 2. Yes, T value is derived from equation 3. The process is described in details below.

The whole process of imbalance bars calculation is not straightforward. First of all, you have to set 3 parameters:

  1. Initial guess for expected number of ticks in imbalance bars (๐ธ0[๐‘‡]). When you start to calculate imbalance bars, you don't have any bars at all, so you don't have any information about expected number of ticks inside of an imbalance bar. That is why you need an initial guess. This parameter doesn't significantly impact further imbalance bars, but still it is needed for the first bar calculation

  2. Number of bars to use for expected number of ticks in bars. When you accumulate imbalance bars you can define ๐ธ0[๐‘‡] as EWMA of number of ticks in previous bars that is why you need to set the window for EWMA calculation.

  3. Number of ticks to use for expected imbalance calculation. Expected tick imbalance (2๐‘ƒ[๐‘๐‘ก=1]โˆ’1) can be found by calculating EWMA from tick imbalances from previous trades/ticks. We need to set the window for EWMA.

The whole algorithm description:

  1. Set parameters
  2. On each trade calculate cumulative sum of tick imbalances (๐œƒ๐‘‡)
  3. Start accumulating ticks until number of tick imbalances reaches the window used to expected tick imbalance calculation.
  4. When number of tick imbalance reaches the EWMA window size - calculate expected tick imbalance (2๐‘ƒ[๐‘๐‘ก=1]โˆ’1)
  5. Check if |๐œƒ๐‘‡| โ‰ฅ ๐ธ0[๐‘‡] * (2๐‘ƒ[๐‘๐‘ก=1]โˆ’1)

  6. If True - it means that we have the first bar. Set ๐œƒ๐‘‡ to zero, set expected number of ticks(๐ธ0[๐‘‡]) to EWMA of array of number of ticks in previous bars. As we have only one bar available you call EWMA with you window setting on array of generated bars, don't worry you can call EWMA with window = 3 to an array with less than 3 elements.

  7. If False continue, until |๐œƒ๐‘‡|โ‰ฅ๐ธ0[๐‘‡]|2๐‘ƒ[๐‘๐‘ก=1]โˆ’1

I am contributor to https://github.com/hudson-and-thames/mlfinlab package where you can see the implementation of imbalance bars (dollar, tick, volume) described above

$\endgroup$
0
$\begingroup$

Question 1

As I read it from your formula $b_t = \pm 1$, depending on whether the price has risen or fallen since the last evaluated $b_{t-1}$. If the price is unchanged the indicator rolls over from the previous timestep.

I can see two cases, either you calculate your price with actual trade data, i.e. which trades have executed between the timestep and determine a suitable model for determining $p_t$, or you determine $p_t$ based on the depth of the market, i.e. bid and offer. In either case it seems that $b_t$ is some indicator based on price. It is how you choose to model price that matters. Here is a link on that aspect definition of mid price in literature.

$\endgroup$
  • $\begingroup$ thanks for answering question 1. My tickdata has both bid and ask for the same timestamp. Does that mean my $b_t$ is the collection of spread or the $b_t$ is separate for bid and ask? $\endgroup$ – boniface316 Mar 8 at 21:30
  • 1
    $\begingroup$ so to reiterate, $b_t$ is an indicator of your price. Your price, dependent upon on your model, may or may not be related to the bid/ask, you might ignore bid/ask and use last trade, or you might say it is average of bid/ask. This indicator model's description does not appear to suggest you should ever be calculating two indicators by considering bid/ask as two separate prices. At least, that's how I read it from your question. $\endgroup$ – Attack68 Mar 8 at 21:39
  • $\begingroup$ That makes sense! Thanks for clarifying this~ $\endgroup$ – boniface316 Mar 9 at 2:40

Your Answer

By clicking โ€œPost Your Answerโ€, you agree to our terms of service, privacy policy and cookie policy

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