## 3 Proposed Approach
### AGBCPT Flowchart  
The AGBCPT flowchart is shown in Figure 1.  
Figure 1 shows that the proposed approach collects the stock price series of the companies and then preprocesses the data, after which the population is randomly initialized according to the encoding scheme and the population size. The fitness calculation process determines the correlation coefficient matrix of all companies in each trading day \(T\) (Step 1). The number of days for the calculation is the _cDay_ gene. Next, the _cLimit_ gene is a threshold used to find the qualified stock pairs (Step 2), which are kept in _TPset_ when their correlation coefficient value is smaller than _cLimit_. Then, the Bollinger Band channels for stock pairs are generated using the _mDay_ and _BBentryWidth_ genes (Step 3). On each date \(T\), _mDay_ is used to calculate the moving average, and _BBentryWidth_ is used to calculate the upper and lower channels. The formulas of the upper and lower channels of entering are defined as  
\[UB_{i}(T)=MA_{i}(T)+BBentryWidth_{c}*\sqrt{\frac{\sum_{k=T-mDay_{c}}^{T-1}{(cp_ {k}^{i}-\mu^{i})}^{2}}{mDay_{c}}},\text{ and} \tag{1}\]  
\[LB_{i}(T)=MA_{i}(T)-BBentryWidth_{c}*\sqrt{\frac{\sum_{k=T-mDay_{c}}^{T-1}{(cp_ {k}^{i}-\mu^{i})}^{2}}{mDay_{c}}}, \tag{2}\]  
Figure 1: AGBCPT flowchart.  
where \(MA_{i}(T)\) is the \(i\)-th moving average calculated as  
\[MA_{i}(T)=\frac{\sum_{k=T-mDay_{c}}^{T-1}c\rho_{k}^{i}}{mDay_{c}}. \tag{3}\]  
Then, \(oDay\) is used to check whether stock pair (\(s_{i}\), \(s_{j}\)) is satisfied with the entry conditions, including (1) \(c\rho_{T-oDay}^{i}>UB_{i}(T)>cp_{T}^{i}\) for stock \(s_{i}\) and (2) \(c\rho_{T-oDay}^{j}<LB_{j}(T)<cp_{T}^{j}\) for stock \(s_{j}\), where \(cp_{T}^{h}\) is the close price of stock \(s_{h}\) on date \(T\). When both conditions are met and \(cp_{T}^{i}>cp_{T}^{j}\), the proposed approach sells \(s_{i}\) and buys \(s_{j}\), and the pair (\(s_{i}\), \(s_{j}\)) is also recorded. It then continues to judge the entry conditions for the next candidate pair until all pairs are processed.  
The next step is to generate the Bollinger Band channels again for the pairs that have been performed previously (Step 4). According to the \(mDay\) and \(BBoutWidth\), the exiting channels are calculated as:  
\[US_{i}(T)=MA_{i}(T)+BBoutWidth_{c}*\sqrt{\frac{\sum_{k=T-mDay_{c}}^{T-1}\left(cp _{k}^{i}-\mu^{i}\right)^{2}}{mDay_{c}}},\text{ and} \tag{4}\]  
\[LS_{i}(T)=MA_{i}(T)-BBoutWidth_{c}*\sqrt{\frac{\sum_{k=T-mDay_{c}}^{T-1}\left(cp _{k}^{i}-\mu^{i}\right)^{2}}{mDay_{c}}}. \tag{5}\]  
The exiting conditions are (1) \(c\rho_{T-oDay}^{i}>LS_{i}(T)>cp_{T}^{i}\) for stock \(s_{i}\) and (2) \(c\rho_{T-oDay}^{j}<US_{j}(T)<cp_{T}^{i}\) for stock \(s_{j}\), by which the proposed approach buys \(s_{i}\) and sells \(s_{j}\). When a stock pair trading is complete, it records \(profit(s_{i},s_{j})=income(s_{i},s_{j})/cost(s_{i},s_{j})\) as well as the minimum value of the return, after which the trading pair (\(s_{i},s_{j}\)) is removed from \(TPset\), and it continues to judge the next pair's exit condition until all pairs have been processed.  
Finally, the fitness value of a chromosome, that is, the profit of all trading pairs divided by the minimum value of the return, is evaluated and the genetic operators are executed to generate new offspring. The process is repeated until the termination conditions are met.