Tag: quant

Volume Clock, Candles

Our previous post showed how a chrono-clock frequency can be translated into a volume-clock frequency. The aggregated High-Low price data looks very similar to a candle-stick chart.

The difference between the high and the low on each “candle” of the longest living contract doesn’t vary a lot between the two clocks.

The distribution is based on a month’s worth of streaming data. As we accumulate more data points, it is likely that the divergence between the Chrono-Clock and the Volume-Clock increases.

Volume Clock, picking an Interval

In our brief intro to the volume clock, we showed how you use a volume based aggregation to match the sampling frequency with information flow frequency. To further expand on that intuition, lets say that as a trader, you are used to watch the 5-minute chart. However, when markets turn volatile, you reach for the 1-minute or sometimes even the 30-second chart. Why is that?

In liquid futures markets like the NIFTY, volatility is associated with increased volume. A 5-minute window captures quite a wide range of volume.

While, on average, 10000 contracts get traded in a 5-minute interval, there are times when the market goes “berserk.” This is where the volume-clock begins to make sense. If you fix the volume at 10000, then your aggregation automatically tracks information flow without you having to zoom in and out.

Notice how the width of the window automatically expands and shrinks?

You can choose the volume interval to aggregate based on the current clock frequency that you use to trade.

Volume Clock, an Introduction

Typically, prices and volumes are charted based on time aggregations. The most common aggregation is the daily chart.

The daily chart shows the high/low/open/close and volume traded of a particular instrument. Intraday traders might prefer a more granular version of this. Maybe a minute chart does the trick for them.

Chrono-clocks are intuitive because that’s how we perceive events around us and have been trained to think.

However, time is not the only way to aggregate prices. If prices are information, then volume indicates the speed with which it arrives. You can divide the day into equal volume buckets (eg. in 5000 contract increments) and transform the time-series from chrono-time to event-based time.

In fact, working in volume time presents significant statistical advantages. First, this time transformation removes most intra-session seasonal effects; second, it allows a partial recovery of Normality and the IID assumption; third, sampling in a volume-clock metric addresses the problem of random and asynchronous transactions, which is a major concern when computing correlations on high-frequency data.

The Volume Clock: Insights into the High Frequency Paradigm (SSRN)

We know that trading turnover throughout the day is not constant. If you plot turnover over a trading day, it typically traces a ā€˜Uā€™ shaped plot. Even widely traded index futures like the NIFTY have “slow” and “fast” periods. A volume clock is one way to match the sampling frequency with information flow frequency.

When you aggregate by volume, each slice of time will have different lengths. For example, we streamed NIFTY futures over a couple of weeks and aggregated it by 2500, 5000 & 10000 lots traded. The y-axis is the width of the time-slice of each volume-tick.

The size of the volume bucket would depend on what one is trying to analyze. Here’s the 2500 lot bucket by itself:

“There are minutes where nothing happens; and there are seconds where minutes happen” – Lenin, the High Frequency Trader.

The Shifting Sands of Auto-Correlation

Autocorrelation represents the degree of similarity between a given time series and a lagged version of itself over successive time intervals. Our previous post on using run length encoding discussed how you can inspect the streakiness of returns. ACF allows you to inspect the relationship between day-0 and day-n returns.

Let’s have a look at the ACF of NIFTY and BANKNIFTY returns. Here is a plot of the ACFs of both real returns and up/down returns in 2015.

Zoom into the up/down ACF of NIFTY, see how day-0 direction correlates strongly to day-1, day-2 and day-3? Combine this with what we got from running an rle and you might just have a trend-following strategy.

Before we run off to make our millions, lets see how other years faired. Enter 2021.

While NIFTY’s day-0 direction correlates strongly to day-1, it is the inverse of day-2’s and day-3’s. Did it become mean-reversion-y? One implication of this give-up is that a trend model tuned to work well with 2015 data is unlikely to repeat its performance in 2021.

However, ACFs from 2015 through 2021 have day-1 correlations as always positive. What if you just bet that an up day will be followed by another up day and vice versa?

Euclid vs. Hamming Distance

Our previous post explored the differences between CAPM Beta and Hamming distance. Think of Beta as a linear regression between two time-series and Hamming distance as the number of days when the direction of returns differed. The usefulness of the Euclidian distance for non-reverting timeseries is somewhere between the two.

Extending the previous example using HDFC and keeping everything else the same, here’s what the Euclidian distance measure looks like.

Higher the distance, the farther apart their curves and worse the index hedge. Here’s the equity curve that can help map returns to distance.

Reproducing the Beta and Hamming Distance charts:

From a linear portfolio point-of-view, which of these series is more “predictable?” Is it possible to specify bands beyond which things “break?” And does using shorter look-backs help?