SJTU-Quant / MASTER

This is the official code and supplementary materials for our AAAI-2024 paper: MASTER: Market-Guided Stock Transformer for Stock Price Forecasting. MASTER is a stock transformer for stock price forecasting, which models the momentary and cross-time stock correlation and guide feature selection with market information.
96 stars 20 forks source link

Can you provide the detailed code about how Market information is calculated? #7

Closed XFeiF closed 3 days ago

XFeiF commented 3 weeks ago
I just found the value of feature.1 can not be inferred from the column feature.   feature feature.1
  Mask($close/Ref($close,1)-1,'SH000300') Mask(Mean($close/Ref($close,1)-1,5),'SH000300')
datetime    
2008/1/2 0.74735785 1.0109634
2008/1/3 0.57677513 1.1709653
2008/1/4 0.9783356 1.2388867
2008/1/7 1.1510324 1.0415094
2008/1/8 -0.4920946 1.0515707
2008/1/9 1.3472286 1.2670099

For example, at 2008/1/8 , the feature.1 's value is 1.0515707. While according to the expression Mask(Mean($close/Ref($close,1)-1,5),'SH000300'), I think it can be simply calculated by (0.74735785 + 0.57677513 + 0.9783356 + 1.1510324 -0.4920946 ) / 5, and the result is 0.592281276.

Do I misunderstand the expression of feature.1? Can anyone explain this? Besides, can you provide the detailed code about how Market information is calculated?

Many thanks!

LITONG99 commented 3 weeks ago

Both the market information and the 158 factors are considered as features, which means they undergo the same preprocessing. Sorry that I missed pointing this out earlier, and please refer to Readme/Dataset/Preprocessing for a description.

Specifically, the range of market information is [-3,3], which is due to the RobustZScoreNorm in Qlib. It is a common practice in Qlib and please refer to the Qlib documents for explanation. You may also find my answer to this closed issue helpful.

Based on the Qlib, a version of data preprocessing code is already available, which includes detailed code to calculate market information from raw data. Please refer to Readme/[New]A-Qlib-implementation.