This is a buy/sell imbalance indicator making use of the Bulk Volume Classifier as described by proposed by Easley, López de Prado and O'Hara [2013]. The bulk classification approach makes use of the return probability distribution to classify unlabeled volume as buyer or seller originated.
The cdf of the volatility normalized return of each bar indicates whether the return is towards the middle (0.5), left (0.0) or right (1.0) of the distribution. For strong upward (downward) moves, we expect a cdf value approaching 1.0 (0.0). We can calculate the signed volume for each bar as:
To get an overall sense of signed buy/sell imbalance momentum we use a hawkes process. Hawkes processes model the intensity of events and are applicable for events which tend to cluster in a self-exciting manner. The form of the Hawkes process we use is:
where N(i) indicates the # or magnitude of events at time t_i and κ is the decay factor. In the case of BVC, since is a 0 centered process, our mean μ(t) is 0 and N(i) is the signed buy-sell change in volume for a particular period.
As for the volatilty σ(t), for the purposes of this implementation, simply computing a rolling standard deviation over a window. Other implementations may wish to use volume weighted standard deviation or other estimators of volatility.
Putting this together the indicator is implemented as:
This implementation of the BVC signal requires a market data source that includes volume. The data frame should contain:
- timestamp { a column named, one of: 'stamp', 'time', 'date', 'datetime' }
- price { a column named either: 'price' or 'close' }
- volume or (buyvolume and sellvolume)
Below are some examples of the same (intra-day) data series, parameterized with different decays.
obj = HawkesBVC(30,0.1)
obj.eval (df)
obj.plot()
obj = HawkesBVC(30,0.05)
obj.eval (df)
obj.plot(title="variation with kappa = 0.05")