This project implements MAESTRO, a GAN-based framework designed to produce synthetic alpha signals for predictive modeling in quantitative finance. This codebase contains the project code for preprocessing, clustering, models, training, evaluation, and visualization.
Follow the instructions below to set up and run the project.
git clone https://github.com/DavidG1542/maestro.git
It is recommended to use a virtual environment (e.g., venv or conda).
pip install -r requirements.txt
You can install this project as an editable package using setup.py.
This allows modules like data_processing, training, evaluation, etc. to be imported from anywhere within the project code, and is needed for functionality.
-
Navigate to the root of the project (where
setup.pyandREADME.mdare located). -
Install in editable mode using:
pip install -e .
.
├── README.md # Project overview and instructions
├── requirements.txt # Python dependencies
└── maestro/ # Main source code directory
├── main.py # Entry point script - start here! You can use this to run the entire pipeline.
├── data_processing.py # Data preprocessing steps
├── clustering.py # Various clustering methods, including spectral clustering
├── models.py # Generator and discriminator model implementations
├── training.py # WGAN training loop
├── evaluation.py # Evaluation using both distributional similarity and predictive performance
├── visualizations.py # Creating visualizations
The main script is main.py, located inside the maestro/ folder.
You can control the behavior of the pipeline through command-line arguments.
Basic usage:
python maestro/main.py [arguments]If you don't specify any arguments, default values will be used.
| Argument | Description | Default |
|---|---|---|
--clustering, -c |
Clustering method: single, industry, or spectral |
spectral |
--selected_stocks, -ss |
Stock IDs (only for single mode) |
None |
--batch_size, -bs |
Batch size for GAN training | 256 |
--epochs, -e |
Number of training epochs | 100 |
--steps_per_epoch, -spe |
Training steps per epoch | 500 |
--gen_lr, -glr |
Generator learning rate | 1e-4 |
--disc_lr, -dlr |
Discriminator learning rate | 1e-4 |
--gan_type, -gt |
GAN variant: solid or feature_matching |
solid |
--resume, -r |
Resume training from checkpoint (flag) | False |
--resume_epoch, -re |
Epoch number to resume from | None |
-
Step-by-Step Sections in the Code:
Inmain.py, many major steps (such as clustering, GAN training, evaluation) are already coded but commented out. -
To run only specific parts (e.g., just training, just evaluation), you can comment/uncomment the relevant blocks inside
main.py. -
Recommended Workflow:
- Set command-line arguments as needed.
- Open
main.pyand uncomment the sections you want to execute (e.g., justTraining, orEvaluation). - Run the script.
- You should not need to modify internal functions unless you want to customize anything.
- All intermediate files (like models, plots, evaluation results) will be automatically saved in the appropriate subfolders.
- If any required directory does not exist, it will be created automatically.
- David Geng (davidgen@andrew.cmu.edu)