Skip to content
All library documents

How Volume Bars Handle Trades That Exceed the Threshold

Article Quant Q&A · Author: koyamashinji

Summary

Volume bars group trade data according to a target amount of traded volume rather than a fixed time interval. The question compares a method that splits trades to reach the threshold exactly with implementations that keep each trade intact, asking how to handle trades that cross the target.

The answer describes the latter convention: accumulate whole trades until the threshold is met or exceeded, then close the bar. A trade larger than the threshold forms a bar by itself; subsequent trades begin a new bar. The rationale is that splitting one execution across bars can create multiple bars with the same timestamp, which can be awkward to display on a time axis. This explains the behavior of the cited libraries, but the brief discussion does not compare the statistical properties of alternative bar-building rules or establish that one convention is universally best. Researchers should check a library’s handling of oversized trades when reproducing volume-bar analyses.

Key ideas

  • Volume bars close when accumulated trade volume reaches or exceeds a target.
  • The described library convention keeps each trade whole rather than splitting it between bars.
  • A single trade larger than the threshold can form a bar on its own.
  • Keeping trades intact avoids creating multiple bars with the same timestamp from a split execution.

Tags

Full text
# Understanding Volume Bars Threshold


# Understanding Volume Bars Threshold












I have been reading Advances in Financial Machine Learning by Marcos López de Prado and came across different Bar types, and simulating Volume Bars from execution data myself.

My understanding of Volume Bars is that they are based on a given number of shares traded (volume). Each bar represents trades whose total volume is equal to the volume threshold. A new bar is created when the total volume of the current bar reaches the threshold.

But the output of existing libraries[*1] based on the said book contradicts my understanding. What am I missing here?

To be more specific...

... Suppose we have below raw trade data, and set the threshold to 5.

I expect the Volume Bars to be like the following ...

The libraries return the Volume Bars like this...

[*1] mlfinlab by Hudson and Thames Adv_Fin_ML_Exercises by BlackArbsCEO

## Answer by Bob Jansen (score 1)

https://quant.stackexchange.com/a/68086

The logic used by the library is to combine all trades equal or above the threshold and to never split one trade over two bars. So 6 becomes its own bar and 2 and 7 combine to be one bar.

I think this makes more sense than your approach. In the second table you show two bars with the same time. When using time on the x-axis there is no good way to even plot that as the bars will overlap.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.