gsyyysg / StockFormer

PyTorch implementation for Paper "StockFormer: Learning Hybrid Trading Machines with Predictive Coding".
219 stars 54 forks source link

A mistake (maybe) in stock_data_handle.py #11

Open Huang1720 opened 3 months ago

Huang1720 commented 3 months ago

Hello, when I checked the code of stock_data_handle.py, I got confused about the __getitem__ function of class DatasetStock_PRED because in the code you index the self.label with index instead of position, and I don't know why. I think it may lead to the return ratio generated from the first and second/ fifth day in seq_x being mistaken for the return ratio of the first and second/ fifth day in the future.

7c584df9226f3e7ebe609e64bedec6f

To prove what I found, I run sh train_pred_long.sh as an example and add some codes in the train funtion of Exp_pred in exp_pred.py as shown in the image below:

ac55d99d03b00204c4903d6a7a43bcf

It seems that the variable c which is a return ratio simply calculated from batch_x1 is exactly the same as batch_y. So I think in the code, there is an alignment problem between the training features and the labels

a1cc03f1e3767d51c995b2410bc41f5

Is this a mistake? If what I found is True, it will make the training process unreliable and may affect the conclusion. Could anyone help me? Thanks!