refresh_time

hf.refresh_time(tick_series_list)[source]

The all-refresh time scheme of Barndorff-Nielsen et al. (2011). If this function is applied to two assets at a time, it becomes the pairwise-refresh time. The function is accelerated via JIT compilation with Numba.

Parameters
tick_series_listlist of pd.Series

Each pd.Series contains tick prices of one asset with datetime index.

Returns
outpd.DataFrame

Synchronized previous ticks according to the refresh-time scheme.

Notes

Multivariate estimators require synchronization of the time series. This can be achieved via a grid. A grid is a subset of \([0, T]\) and it is defined as \begin{equation} \mathcal{V}=\left\{v_{0}, v_{1}, \ldots, v_{\tilde{n}}\right\}\subset[0, T] \end{equation} with \(v_{0}=0\) and \(v_{\tilde{n}}=T,\) where \(\tilde{n}\) is the sampling frequency, i.e., the number of grid intervals. Two prominent ways to specify the grid are (i) a regular grid, where \(v_{m}-v_{m-1}=\Delta v, \text{ for } m=1, \ldots, \tilde{n}\), and (ii) a grid based on ‘refresh times’ of Barndorff et al. (2011), where the grid spacing is dependent on the observation times. If more than two assets are considered, refresh times can be further classified into ‘all-refresh-times’ and ‘pairwise-refresh times’. Estimators based on pairwise-refresh times use the data more efficiently but the integrated covariance matrix estimate might not be positive definite. The pairwise-refresh time \(\mathcal{V}_p=\left\{v_{0}, v_{1}, \ldots, v_{\tilde{n}}\right\}\) can be obtained by setting \(v_{0}=0,\) and \begin{equation} v_{m}=\max \left\{\min \left\{t^{(k)}_i \in t^{(k)}: t^{(k)}_i > v_{m-1}\right\},\min \left\{t^{(l)}_i \in t^{(l)}: t^{(l)}_i > v_{m-1}\right\}\right\} \end{equation} where \(\tilde{n}\) is the total number of refresh times in the interval \((0,1].\) This scheme is illustrated in the figure. The procedure has to be repeated for every asset pair. In contrast, the all-refresh time scheme uses a single grid for all assets, which is determined based on the trade time of the slowest asset of each grid interval. Hence, the spacing of grid elements can be much wider. This implies that estimators based on the latter scheme may discard a large proportion of the data, especially if there is a very slowly trading asset. In any case, there has to be at least one observation time of each asset between any two grid elements. With that condition in mind, the ‘previous tick time’ of asset \(j\) is defined as \begin{equation} \tau^{(j)}_m=\max \left\{ t^{(j)}_i \in t^{(j)}: t^{(j)}_i \leq v_{m}\right\} \end{equation} The following diagram illustrates the scheme for two assets, \(k\) and \(l\).

\draw
(0,1.75) -- (11,1.75)
(0,-0.75) -- (11,-0.75)
(0,1.5) -- (0,2)
(1.9,1.5) -- (1.9,2)
(3.5,1.5) -- (3.5,2)
(5,1.5) -- (5,2)
(6.5,1.5) -- (6.5,2)
(8,1.5) -- (8,2)
(10.8,1.5) -- (10.8,2)
(0,-0.5) -- (0,-1)
(1.9,-0.5) -- (1.9,-1)
(5.7,-0.5) -- (5.7,-1)
(10.3,-0.5) -- (10.3,-1);
\draw[dashed,gray]
(0,3.75) -- (0,-2.75) node[below] {$\nu_0=0$}
(1.9,3.75) -- (1.9,-2.75) node[below] {$\nu_1$}
(5.7,3.75) -- (5.7,-2.75) node[below] {$\nu_2$}
(9.5,3.75) -- (9.5,-2.75) node[below] {$t_{3}^{(l)}=
\tau_{3}^{(l)}=\nu_3 = T$};
\draw[dashed] (11,1.75) -- (12,1.75)
      (11,-0.75) -- (12,-0.75);
\draw[very thick] (9.5,-1.4) -- (9.5,0.25)
      (9.5,0.8) -- (9.5,2.4);
\draw
(0,1) node{$t_{0}^{(k)} = \tau_{0}^{(k)}$}
(1.9,1) node{$t_{1}^{(k)} = \tau_{1}^{(k)}$}
(3.5,1) node{$t_{2}^{(k)} $}
(5,1) node{$t_{3}^{(k)} = \tau_{2}^{(k)}$}
(6.5,1) node{$t_{4}^{(k)}$}
(8,1) node{$t_{5}^{(k)}= \tau_{3}^{(k)}$}
(11,1) node{$t_{6}^{(k)}$}
(9.5,0.5) node{\textbf{$T$}}
(0,0) node{$t_{0}^{(l)} = \tau_{0}^{(l)}$}
(1.9,0) node{$t_{1}^{(l)} = \tau_{1}^{(l)}$}
(5.7,0) node{$t_{2}^{(l)}= \tau_{2}^{(l)}$}
(10.3,0) node{$t_{4}^{(l)}$};
\draw
(0,1.75) node[left,xshift=-0pt]{$X^{(k)}$}
(0,-0.75) node[left,xshift=-0pt]{$X^{(l)}$};
\draw[decorate,decoration={brace,amplitude=12pt}]
(0,2)--(1.9,2) node[midway, above,yshift=10pt,]
{$ \Delta X_{\tau^{(k)}_1}^{(k)}$};
\draw[decorate,decoration={brace,amplitude=12pt}]
(1.9,2)--(5,2) node[midway, above,yshift=10pt,]
{$ \Delta X_{\tau^{(k)}_2}^{(k)}$};
\draw[decorate,decoration={brace,amplitude=12pt}]
(5,2)--(8,2) node[midway, above,yshift=10pt,]
{$ \Delta X_{\tau^{(k)}_3}^{(k)}$};
\draw[decorate,decoration={brace,amplitude=12pt}]
(9.5,-1)--(5.7,-1) node[midway, below,yshift=-10pt,]
{$ \Delta X_{\tau^{(l)}_3}^{(l)}$};
\draw[decorate,decoration={brace,amplitude=12pt}]
(5.7,-1)--(1.9,-1) node[midway, below,yshift=-10pt,]
{$ \Delta X_{\tau^{(l)}_2}^{(l)}$};
\draw[decorate,decoration={brace,amplitude=12pt}]
(1.9,-1)--(0,-1) node[midway, below,yshift=-10pt,]
{$ \Delta X_{\tau^{(l)}_1}^{(l)}$};

References

Barndorff-Nielsen, O. E., Hansen, P. R., Lunde, A. and Shephard, N. (2011). Multivariate realised kernels: consistent positive semi-definite estimators of the covariation of equity prices with noise and non-synchronous trading, Journal of Econometrics 162(2): 149–169.

Examples

>>> np.random.seed(0)
>>> n = 20
>>> returns = np.random.multivariate_normal([0, 0], [[1,0.5],[0.5,1]], n)/n**0.5
>>> prices = np.exp(returns.cumsum(axis=0))
>>> # sample n/2 (non-synchronous) observations of each tick series
>>> series_a = pd.Series(prices[:, 0]).sample(int(n/2)).sort_index().rename('a')
>>> series_b = pd.Series(prices[:, 1]).sample(int(n/2)).sort_index().rename('b')
>>> previous_ticks = refresh_time([series_a, series_b])
>>> np.round(previous_ticks.values,4)
array([[0.34  , 0.4309],
       [0.2317, 0.4313],
       [0.1744, 0.4109],
       [0.1336, 0.3007],
       [0.1383, 0.4537],
       [0.1292, 0.1665],
       [0.0936, 0.162 ]])