| This paper mainly focuses on the application of mathematical model in the practical pairs trading based on strict theory. In this paper, we make analysis of pairs trading strategy, and quantitatively describe some key concepts in pairs trading from a mathematical point of view. At the same time, the two key points in pairs trading are described and analyzed, that is, selection of trading pairs and time of building a position. For selection of trading pairs, statistical cointegration approach is applied so as to find securities with intrinsically linked value for pairs trading, and we strive to explore more and better trading opportunities. For selection of the building time, this paper describes the important link between the maximum detection model and selection of the building time in the pairs trading. In theory, such model can be used to select the time of building a position and maximize the revenue in pairs trading.To put the maximum detection model into the use of practical pairs trading, realize the corresponding program trading method, and achieve the research goal of this paper, we first carry out a comparative analysis on differences and similarities between the maximum objective selection and model solution method of the maximum detection model. Then we discuss a special maximum detection-local ultimate maximum detection of mean revert-ing process.On the basis of the maximum detection, we discuss the necessary link of such theoretical model with practical pairs trading, including the cointegration test method of financial price time series, parameter estimate in the process of mean reverting process, as well as numerical implementation method for maximum detection theory model in mean reverting process, making it possible for the practical application of theoretical model.On this basis, we established a relatively complete pairs trading testing framework, and implement it with MATLAB, including data process and analysis, cointegration judg-ment of securities price series and parameter estimate of portfolio, parameter estimation of maximum detection model, realization of trading strategy and calculation of optimal time to build a position, as well as the assessment of final algorithm performance in this paper. Meanwhile, based on the framework and market historical data in futures market, the per-formance of this programmed pairs trading algorithm is tested in this paper, and compared with the time selection of building a position in the current pairs trading. The result shows that the performance of this trading algorithm is relatively ideal, and the performance in most cases is superior to the strategy of selecting building position time in the current pairs trading.In this paper, the theoretical model-maximum detection technology is first applied to pairs trading, the maximum detection is found useful in practical pairs trading, and on this basis a relatively complete pairs trading program framework has been established, which is an innovative attempt. |