Stock Trend Prediction with Multi-granularity Data: A Contrastive Learning Approach with Adaptive Fusion
-
Install packages from
requirements.txt
. -
$ cd ./load_data
$ python load_dataset.py
-
Change parameter
market
to get data from different dataset:csi300
,csi800
,NASDAQ
etc.features dimensions = 6 * 20 + 1 = 121
$ python high_freq_resample.py
-
- Pre-training Stage: Contrastive Mechanisms:
./framework/models/contrastive_all_2_encoder.py
- Adaptive Multi-granularity Feature Fusion:
./framework/models/contrastive_all_2_stage.py
$ cd ./framework
$ python main_contrast.py with config/contrast_all_2_encoder.json model_name=contrastive_all_2_encoder
- Add
hyper-param
= {values
} afterwith
or change them inconfig/main_model.json
- Prediction results of each model are saved as
pred_{model_name}.pkl
in./out/
.
$ python main_contrast_2_stage.py with config/contrast_all_2_stage.json model_name=contrastive_all_2_stage
- Prerequisites:
- Server with qlib
- Prediction results
$ cd ./framework
$ python trade_sim.py
-
Records for each experiment are saved in
./framework/my_runs/
.
Each record file includes:config.json
- contains the parameter settings and data path.
cout.txt
- contains the name of dataset, detailed model output, and experiment results.
pred_{model_name}_{seed}.pkl
> * contains the `score` (model prediction) and `label`
> run.json
* contains the hash ids of every script used in the experiment. And the source code can be found in `./framework/my_runs/source/`.