# A Novel Approach to Short-Term Stock Price Movement Prediction using Transfer Learning
## 5 Deep Transfer with Related Stock Information (DTRSI) Framework
### Base Model Construction
#### 5.1.1 Source Data Preparation  
In this study, three different source data with three different types of input features are employed. Specifically, Type I input features are only one-day returns of the COI stock, Type II input features are a combination of one-day returns of the COI stock and an index (e.g., KOSPI 200 and S&P 500), and Type III input features are a combination of one-day return values of the COI stock, the index and other stocks that have the highest cosine similarity to the COI stock. Let \(x_{t}^{s}\) denote an input that is used in predicting the closing price movement of stock \(s\) on day \(t+1\). In addition, \(R_{t}^{s}\), \(R_{t}^{index}\), and \(R_{t}^{rs}\) are feature vectors of stock \(s\), the index, and related stocks \(rs\in\{rs_{1},rs_{2},...,rs_{m}\}\) with stock \(s\), respectively, on day \(t\), in which \(m\) is the number of stocks that are related to stock \(s\). As defined in Section 4, \(R_{t}^{s}=\{r_{t-19,1}^{s},r_{t-18,1}^{s},...,r_{t,1}^{s}\}\), \(R_{t}^{index}=\{r_{t-19,1}^{index},r_{t-18,1}^{index},...,r_{t,1}^{index}\}\), and \(R_{t}^{rs}=\{r_{t-19,1}^{rs},r_{t-18,1}^{rs},...,r_{t,1}^{rs}\}\). In the base model, \(x_{t}^{s}=\{R_{t}^{s}\}\), \(x_{t}^{s}=\{R_{t}^{s},R_{t}^{index}\}\), and \(x_{t}^{s}=\{R_{t}^{s},R_{t}^{index},R_{t}^{rs_{1}},R_{t}^{rs_{2}},...,R_{t}^{ rs_{m}}\}\) represent the Type I input features, the Type II input features, and the Type III input features, respectively. Let \(n^{\prime}\) and \(n_{samp}\) denote the number of training samples of source data and the number of training samples of each stock \(s\), respectively. In our work, three dimensional tensors (\(\mathbb{X}_{1}\), \(\mathbb{X}_{2}\), and \(\mathbb{X}_{3}\)) with dimensions of \(n^{\prime}\times 20\times k\) corresponding to the source data of three types of input features, are constructed, where \(k\) is the number of input features. \(\mathbb{X}_{1}\), \(\mathbb{X}_{2}\) and \(\mathbb{X}_{3}\) are illustrated in Figure 4, in which each matrix with dimensions of \(20\times k\) corresponds to one training sample. Specifically, in the Type I input features and the Type II input features, we choose data from the top 50 stocks in terms of market capitalization, in which \(s\in\{s_{1},s_{2},...,s_{50}\}\) and stack them into one large dataset. In these cases, \(n^{\prime}=n_{samp}\times 50\). For example, the number of training samples becomes approximately 35,900 for the first study period. Note that \(k=\{1,2\}\) for Type I input features and Type  
Figure 4: Training samples with different types of input features. II input features, respectively. A main objective is to optimize model parameters by using training samples from 50 stocks instead of using training samples from only one stock. Unlike the two first types of input features, in the Type III input features, we first choose 50 stocks closest (in terms of cosine similarity) to each COI stock, because features of these stocks may improve the base model performance. From \(rs\in\{rs_{1},rs_{2},...,rs_{50}\}\), the 50 related stocks are randomly divided into groups, and each group includes \(m\) stocks. For instance, when \(m=5\), 10 different groups will be generated. An illustration is provided in Figure 4c, which shows how each group is used to design Type III input features. As shown in Figure 4c, for each COI stock, each \(x_{t}^{COI}=\{R_{t}^{COI},R_{t}^{index},R_{t}^{rs_{1}},R_{t}^{rs_{2}},...,R_{t}^ {rs_{m}}\}\), \(x_{t}^{COI}=\{R_{t}^{COI},R_{t}^{index},R_{t}^{index},R_{t}^{rs_{m+1}},R_{t}^{ rs_{m+2}},...,R_{t}^{rs_{2m}}\}\),..., \(x_{t}^{COI}=\{R_{t}^{COI},R_{t}^{index},R_{t}^{rs_{46}},R_{t}^{rs_{47}},...,R_{t} ^{rs_{50}}\}\) denotes the inputs designed from 10 generated groups. In the Type III input features, with each \(x_{t}^{COI}\), \(n_{samp}\) training samples are fed into the base model to predict COI stock price movements. In our study, \(m=\{3,5,7\}\) is taken into account. In this case, \(n^{\prime}=n_{samp}\times\frac{50}{m}\) and \(k=2+m\).