# High-Frequency Direction Forecasting of the Futures Market Using a Machine-Learning-Based Method
## 4 Experimental Design
### Trading Rule Design and Optimization  
Generally, it is necessary to optimize and select a set of optimal trading parameters for investors to improve the profit-making ability in the process of simulation trading. Instead of determining the parameters by experience of industry experts, the parameters of the trading rule designed in this research would be optimized by NSGA-II. To define the multiobjective optimization function, our proposed approach takes into account not only the profits from the trading rules but also the trading risks of transactions in the rebar futures market. Thus, two indicators, including the largest accumulated return and the smallest maximum drawdown, are designed as the optimization objectives of NSGA-II. Finally, through parameters optimization of the trading rule using NSGA-II, the XGBoost model with the Pareto optimal solutions in terms of those two optimization objectives is regarded as the optimal one for trading simulation in the corresponding testing period. In the proposed approach, there are five categories of the price-movement magnitude (see Table 2), and the trading signals are determined based on the predicted level thresholds. \begin{table}
\begin{tabular}{c c c c} \hline \hline \multirow{2}{*}{**Datasets**} & \multicolumn{2}{c}{**Training Dataset**} & \multicolumn{2}{c}{**Testing Dataset**} \\ \cline{2-4}  & **Period** & **Sample Size** & **Period** & **Sample Size** \\ \hline \multirow{2}{*}{Dataset 1} & 2016/Jan.– & \multirow{2}{*}{5680} & 2020/Jan.– & \multirow{2}{*}{243} \\  & 2019/Dec. & & 2020/Mar. & \\ \multirow{2}{*}{Dataset 2} & 2016/Apr.– & \multirow{2}{*}{5479} & 2020/Apr.– & \multirow{2}{*}{288} \\  & 2020/Mar. & & 2020/June & \\ \multirow{2}{*}{Dataset 3} & 2016/July- & \multirow{2}{*}{5389} & 2020/July- & \multirow{2}{*}{372} \\  & 2020/June & & 2020/Sep. & \\ \multirow{2}{*}{Dataset 4} & 2016/Oct.– & \multirow{2}{*}{5406} & 2020/Oct.– & \multirow{2}{*}{338} \\  & 2020/Sep. & & 2020/Dec. & \\ \hline \hline \end{tabular}
\end{table} 
Table 1: The dataset design for the experiments. Details for the multiclassification are shown in Figure 3. As the points B shown in Figure 3, when the predicted return (\(PR\)) is larger than \(T_{4}\), _label = 5_, and it will open a long position with leverage \(l_{4}\); similar to point A, when the \(PR\) is greater than \(T_{3}\) and less than or equal to \(T_{4}\), _label = 4_, and it will open a long position with leverage \(l_{3}\). As for point C, when \(PR\) is greater than or equal to \(T_{2}\) and less than or equal to \(T_{3}\), _label = 3_, and there is no transaction. As for point D, when the \(PR\) is greater than or equal to \(T_{1}\) and less than \(T_{2}\), _label = 2_, and a short-selling transaction will be conducted at the opening price of the next period with leverage \(l_{2}\). As for point E shown in Figure 3, when \(PR\) is less than \(T_{1}\), _label = 1_, and a short-selling transaction will be executed at the opening price of the next period with leverage \(l_{1}\). Note that the holding position will last for five hours. Then, the trading return \(TR_{i}\) for each transaction can be calculated. Additionally, the profit-taking thresholds (\(PT\)), loss-cutting thresholds (\(LT\)), and trading leverage (\(l\)) are comprehensively considered in the simulation trading of the rebar futures market. The primary purpose for the design of the loss-cutting threshold is to alleviate huge losses from potentially adverse market direction movements, while the profit-taking threshold is designed to prevent traders from losing profit opportunities if the market moves in the expected direction followed by a rapid retreat. When \(TR_{i}\) is greater than \(PT\) or less than \(LT\), the proposed method will close the opened position automatically.