Statistical arbitrage identifies and exploits temporal price differencesbetween similar assets. We propose a unifying conceptual framework forstatistical arbitrage and develop a novel deep learning solution, which findscommonality and time-series patterns from large panels in a data-driven andflexible way. First, we construct arbitrage portfolios of similar assets asresidual portfolios from conditional latent asset pricing factors. Second, weextract the time series signals of these residual portfolios with one of themost powerful machine learning time-series solutions, a convolutionaltransformer. Last, we use these signals to form an optimal trading policy, thatmaximizes risk-adjusted returns under constraints. We conduct a comprehensiveempirical comparison study with daily large cap U.S. stocks. Our optimaltrading strategy obtains a consistently high out-of-sample Sharpe ratio andsubstantially outperforms all benchmark approaches. It is orthogonal to commonrisk factors, and exploits asymmetric local trend and reversion patterns. Ourstrategies remain profitable after taking into account trading frictions andcosts. Our findings suggest a high compensation for arbitrageurs to enforce thelaw of one price.