Asynchronous Covariance (Hayashi–Yoshida)

The module timeseries_utils::nonsync_covariance implements the Hayashi–Yoshida estimator of the integrated covariance between two asynchronously sampled processes \(X\) and \(Y\) observed at distinct, non-overlapping observation grids \(\{t^X_i\}\) and \(\{t^Y_j\}\).

Estimator

Let \(I_i = (t^X_{i-1}, t^X_i]\) and \(J_j = (t^Y_{j-1}, t^Y_j]\). The Hayashi–Yoshida estimator is

\[\widehat{\langle X, Y\rangle}_{[0,T]} \;=\; \sum_{i, j}\, \big(X_{t^X_i} - X_{t^X_{i-1}}\big)\, \big(Y_{t^Y_j} - Y_{t^Y_{j-1}}\big)\, \mathbf{1}\!\big[I_i \cap J_j \neq \emptyset\big].\]

It is consistent under non-synchronicity and avoids the Epps effect that plagues naive grid interpolation.

Implementation

  • A two-pointer scan in \(O(n_X + n_Y)\) collects all overlapping pairs.

  • For matrices of size \(d \times d\) with large per-asset sample counts, off-diagonal entries are computed in parallel with Rayon.

API

pub fn hayashi_yoshida_covariance(
    t1: &[f64], v1: &[f64],
    t2: &[f64], v2: &[f64],
) -> Result<f64>;

pub fn hayashi_yoshida_matrix(
    series: &[(Vec<f64>, Vec<f64>)],
) -> Result<Vec<Vec<f64>>>;