base R code for statistical arbitrage