This repository provides software packages in Matlab, Python and R for implementing the statistical test developed in Multi-Horizon Test for Market Frictions, published in the Journal of Econometrics.
- Check whether intraday prices are relatively free of microstructure noise.
- Diagnose whether the underlying returns are uncorrelated.
- Detect persistent returns driven by large drifts or drift bursts.
- Outperforms modern variance ratio and portmanteau tests.
The key statistic is defined as
where
There are 3 folders in the directory:
- In the
./MATLABfolder, a function scriptminimac.mthat depends oncvs.mattable and a test scripttest.mare provided. - Similarly, each of
./Rand./Pythoncontains a corresponding function script that depends oncvs.csvtable and a test script/ipynb.
-
The callable function
stat=minimac(y,T)employs uniform syntax across mentioned languages, whereyis log price andTis sample period of your dataset (T=1/252 represents data covers 1 day's trading hours). -
summary_minimac(stat)returns formal output forstat=minimac(y,T)testing result (also callable in all mentioned languages). Note that the function is in independent script for MATLAB, while for R and Python, it is integrated in corresponding function script of minimac. -
Before calling
minimac(y,T), put function script (e.g.,minimac.m,summary_minimac.m) and critical value table (e.g.,cvs.mat) into your current directory. -
MATLAB:
% Import data data = readtable('../SPY_20141215_1s.csv'); % import your intraday data here y = log(data.PRICE); % Testing for Market Friction stat = minimac(y,1/252); summary_minimac(stat)
-
R:
# Load function of minimac source("minimac.R") # Import data data <- read.csv("../SPY_20141215_1s.csv") # import your data here y <- log(data$PRICE) # Testing for Market Friction stat <- minimac(y,1/252) summary_minimac(stat)
-
Python:
## Import modules from minimac import minimac, summary_minimac import pandas as pd import numpy as np ## Load data and run minimac data = pd.read_csv('../SPY_20141215_1s.csv') # input your data here y = np.log(data['PRICE']) stat = minimac(y,1/252) summary_minimac(stat)
-
All languages will return identical output
================ minimac testing result ================ >> Testing Statistics: K_0 K_1 K_2 K_3 H -0.683775 -1.61216 -3.90376 -3.90376 >> Rejection Status: K_0 K_1 K_2 K_3 1%, one-sided 0 0 1 1 1%, two-sided 0 0 1 1 5%, one-sided 0 0 1 1 5%, two-sided 0 0 1 1 10%, one-sided 0 1 1 1 10%, two-sided 0 0 1 1