LeonardoBerti nielsr HF staff commited on
Commit
8673be8
·
verified ·
1 Parent(s): 97822f9

Fix metadata (#1)

Browse files

- Fix metadata (d2f670f2f9a639d1840800d0f8fcb45e48ffa844)


Co-authored-by: Niels Rogge <[email protected]>

Files changed (1) hide show
  1. README.md +121 -118
README.md CHANGED
@@ -1,118 +1,121 @@
1
- # DeepMarket: Limit Order Book (LOB) simulation with Deep Learning.
2
- DeepMarket is a Python-based open-source framework developed for Limit Order Book (LOB) simulation with Deep Learning.
3
- This is also the official repository for the paper [TRADES: Generating Realistic Market Simulations with Diffusion Models](https://arxiv.org/abs/2502.07071).
4
-
5
- ## Introduction
6
- DeepMarket offers the following features:
7
- 1. Pre-processing for high-frequency market data.
8
- 2. Training environment implemented with PyTorch Lightning.
9
- 3. Hyperparameter search facilitated with WANDB.
10
- 4. Implementations and checkpoints for TRADES and CGAN to directly generate market simulations without training.
11
- 5. comprehensive qualitative (via the plots in the paper) and quantitative (via the predictive score) evaluation.
12
- 6. TRADES-LOB: a synthetic LOB dataset in data/TRADES-LOB.
13
-
14
- To perform the simulation with our world agent and historical data, we extend ABIDES, an open-source agent-based interactive Python tool.
15
-
16
- ## TRADES-LOB: A synthetic LOB dataset
17
- To foster collaboration and help the research community we release a synthetic LOB dataset: TRADES-LOB. TRADES-LOB comprises simulated TRADES market data for Tesla and Intel, for 29/01 and 30/01. Specifically, the dataset is structured into four CSV files, each containing 50 columns. The initial six columns delineate the order features, followed by 40 columns that represent a snapshot of the LOB across the top 10 levels. The concluding four columns provide key financial metrics: mid-price, spread, order volume imbalance, and Volume-Weighted Average Price (VWAP), which can be useful for downstream financial tasks, such as stock price prediction. In total, the dataset is composed of 265,986 rows and 13,299,300 cells, which is similar in size to the benchmark FI-2010 dataset.
18
-
19
- # Getting Started
20
- These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
21
-
22
- ## Prerequisities
23
- This project requires Python and pip. If you don't have them installed, please do so first.
24
-
25
- ## Installing
26
- To set up the environment for this project, follow these steps:
27
-
28
- 1. Clone the repository:
29
- ```sh
30
- git clone https://github.com/LeonardoBerti00/DeepMarket.git
31
- ```
32
- 2. Navigate to the project directory
33
- 3. Create a virtual environment:
34
- ```sh
35
- python -m venv env
36
- ```
37
- 4. Activate the new Conda environment:
38
- ```sh
39
- env\Scripts\activate
40
- ```
41
- 5. Download the necessary packages:
42
- ```sh
43
- pip install -r requirements.txt
44
- ```
45
-
46
- # Market Simulation
47
- If your objective is to execute a market simulation this is the section for you.
48
- ![TRADES's simulations mid-price traces](https://github.com/LeonardoBerti00/DeepMarket/blob/main/data/simulations-1.png)
49
-
50
- ## Generate a Market Simulation with TRADES checkpoint
51
- First of all, you need to download the TRADES checkpoints from [link](https://drive.google.com/drive/folders/1fg5G9KzmzC6E4FUYSCjObJ7sCEdjo43W?usp=sharing), then place the checkpoints in data/checkpoints/TRADES/. There is one trained with TSLA and one with INTC.
52
- To execute a market simulation with a TRADES checkpoint, there are two options:
53
- 1. If you do not have LOBSTER data, you can unzip INTC.zip and places the dir unzipped named INTC_2012-06-21_2012-06-21 in INTC. Finally, you can run the following command:
54
- ```sh
55
- python -u ABIDES/abides.py -c world_agent_sim -t INTC -date 2012-06-21 -d True -m TRADES -st '09:30:00' -et '12:00:00' -id 2.317
56
- ```
57
- Since the model was not trained with this data we cannot guarantee good performance.
58
-
59
- 2. If you have LOBSTER data you need to save the data in f"data/{stock_name}/{stock_name}_{year}-{start_month}-{start_day}_{year}-{end_month}-{end_day}". The format of the data should be the same of LOBSTER: f"{year}-{month}-{day}_34200000_57600000_{type}". You can see an example with INTC. Then you need to simply change cst.DATE_TRAING_DAYS setting the start day and end day, run the following command, inserting the stock symbol and the date that you want to simulate:
60
- ```sh
61
- python -u ABIDES/abides.py -c world_agent_sim -t ${stock_symbol} -date ${date} -d True -m TRADES -st '09:30:00' -et '12:00:00'
62
- ```
63
-
64
- When the simulation ends a log dir will be saved in ABIDES/log, here you can find the processed orders of the simulation, and all the plots used to in the paper to evaluate the stylized facts. At the end of the simulation also the predictive score will be computed.
65
- If you want to perform a simulation with CGAN you need simply to change the -m option to CGAN.
66
- To reproduce the results of the paper you need exactly the same data, so TSLA or INTC of 29/01/2015 or 30/01/2015.
67
-
68
- ## Running a Market Simulation with IABS configuration
69
- If you want to run the IABS configuration:
70
- ```sh
71
- python -u ABIDES/abides.py -c rsmc_03 -date 20150130 -st '09:30:00' -et '12:00:00'
72
- ```
73
-
74
- # Training
75
- If you aim to train a TRADES model or implement your model you should follow those steps.
76
-
77
- ## Data
78
- 1. Firstly you need to have some LOBSTER data otherwise it would be impossible to train a new model. The format of the data should be the same as LOBSTER: f"{year}-{month}-{day}_34200000_57600000_{type}" and the data should be saved in f"data/{stock_name}/{stock_name}_{year}-{start_month}-{start_day}_{year}-{end_month}-{end_day}". The type can be a message or orderbook.
79
- 2. You need to add the new stock to the constants and to the config file.
80
- 3. you need to change cst.DATE_TRAING_DAYS setting the start day and end day
81
- 4. You need to start the preprocessing setting, to do so set config.IS_DATA_PREPROCESSED to False and run python main.py
82
-
83
- ## Implementing and Training a new model
84
- To train a new model, follow these steps:
85
- 1. Implement your model class in the models/ directory. Your model class should inherit from the NNEngine class and should be a Pytorch Lightning engine.
86
- 2. Update the HP_DICT_MODEL dictionary in run.py to include your model and its hyperparameters.
87
- 3. Create a file {model_name}_hparam and write the hyperparameters that you want to use for your model. You can also specify hyperparameters for a hyperparameter search. Use the TRADES model as an example.
88
- 4. Choose a configuration by modifying the `configuration.py` file.
89
- 5. Run the training script:
90
- ```sh
91
- python main.py
92
- ```
93
- 6. A checkpoint will be saved in data/checkpoints/ that later you can use to perform a market simulation
94
-
95
- ## Training a TRADES Model
96
- ![TRADES's Architecture](https://github.com/LeonardoBerti00/DeepMarket/blob/main/data/architecture.jpg)
97
- To train a TRADES model, you need to follow these steps:
98
- 1. Set the CHOSEN_MODEL in configuration.py to cst.Models.TRADES
99
- 2. Optionally, adjust the simulation parameters in `configuration.py`.
100
- 3. Now you can run the main.py with:
101
- ```sh
102
- python main.py
103
- ```
104
-
105
- # Citing
106
- If you use the framework in a research project please cite:
107
- ```sh
108
- @misc{berti2025tradesgeneratingrealisticmarket,
109
- title={TRADES: Generating Realistic Market Simulations with Diffusion Models},
110
- author={Leonardo Berti and Bardh Prenkaj and Paola Velardi},
111
- year={2025},
112
- eprint={2502.07071},
113
- archivePrefix={arXiv},
114
- primaryClass={q-fin.TR},
115
- url={https://arxiv.org/abs/2502.07071},
116
- }
117
- ```
118
-
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+
5
+ DeepMarket: Limit Order Book (LOB) simulation with Deep Learning.
6
+ DeepMarket is a Python-based open-source framework developed for Limit Order Book (LOB) simulation with Deep Learning.
7
+ This is also the official repository for the paper [TRADES: Generating Realistic Market Simulations with Diffusion Models](https://arxiv.org/abs/2502.07071).
8
+
9
+ ## Introduction
10
+ DeepMarket offers the following features:
11
+ 1. Pre-processing for high-frequency market data.
12
+ 2. Training environment implemented with PyTorch Lightning.
13
+ 3. Hyperparameter search facilitated with WANDB.
14
+ 4. Implementations and checkpoints for TRADES and CGAN to directly generate market simulations without training.
15
+ 5. comprehensive qualitative (via the plots in the paper) and quantitative (via the predictive score) evaluation.
16
+ 6. TRADES-LOB: a synthetic LOB dataset in data/TRADES-LOB.
17
+
18
+ To perform the simulation with our world agent and historical data, we extend ABIDES, an open-source agent-based interactive Python tool.
19
+
20
+ ## TRADES-LOB: A synthetic LOB dataset
21
+ To foster collaboration and help the research community we release a synthetic LOB dataset: TRADES-LOB. TRADES-LOB comprises simulated TRADES market data for Tesla and Intel, for 29/01 and 30/01. Specifically, the dataset is structured into four CSV files, each containing 50 columns. The initial six columns delineate the order features, followed by 40 columns that represent a snapshot of the LOB across the top 10 levels. The concluding four columns provide key financial metrics: mid-price, spread, order volume imbalance, and Volume-Weighted Average Price (VWAP), which can be useful for downstream financial tasks, such as stock price prediction. In total, the dataset is composed of 265,986 rows and 13,299,300 cells, which is similar in size to the benchmark FI-2010 dataset.
22
+
23
+ # Getting Started
24
+ These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
25
+
26
+ ## Prerequisities
27
+ This project requires Python and pip. If you don't have them installed, please do so first.
28
+
29
+ ## Installing
30
+ To set up the environment for this project, follow these steps:
31
+
32
+ 1. Clone the repository:
33
+ ```sh
34
+ git clone https://github.com/LeonardoBerti00/DeepMarket.git
35
+ ```
36
+ 2. Navigate to the project directory
37
+ 3. Create a virtual environment:
38
+ ```sh
39
+ python -m venv env
40
+ ```
41
+ 4. Activate the new Conda environment:
42
+ ```sh
43
+ env\Scripts\activate
44
+ ```
45
+ 5. Download the necessary packages:
46
+ ```sh
47
+ pip install -r requirements.txt
48
+ ```
49
+
50
+ # Market Simulation
51
+ If your objective is to execute a market simulation this is the section for you.
52
+ ![TRADES's simulations mid-price traces](https://github.com/LeonardoBerti00/DeepMarket/blob/main/data/simulations-1.png)
53
+
54
+ ## Generate a Market Simulation with TRADES checkpoint
55
+ First of all, you need to download the TRADES checkpoints from [link](https://drive.google.com/drive/folders/1fg5G9KzmzC6E4FUYSCjObJ7sCEdjo43W?usp=sharing), then place the checkpoints in data/checkpoints/TRADES/. There is one trained with TSLA and one with INTC.
56
+ To execute a market simulation with a TRADES checkpoint, there are two options:
57
+ 1. If you do not have LOBSTER data, you can unzip INTC.zip and places the dir unzipped named INTC_2012-06-21_2012-06-21 in INTC. Finally, you can run the following command:
58
+ ```sh
59
+ python -u ABIDES/abides.py -c world_agent_sim -t INTC -date 2012-06-21 -d True -m TRADES -st '09:30:00' -et '12:00:00' -id 2.317
60
+ ```
61
+ Since the model was not trained with this data we cannot guarantee good performance.
62
+
63
+ 2. If you have LOBSTER data you need to save the data in f"data/{stock_name}/{stock_name}_{year}-{start_month}-{start_day}_{year}-{end_month}-{end_day}". The format of the data should be the same of LOBSTER: f"{year}-{month}-{day}_34200000_57600000_{type}". You can see an example with INTC. Then you need to simply change cst.DATE_TRAING_DAYS setting the start day and end day, run the following command, inserting the stock symbol and the date that you want to simulate:
64
+ ```sh
65
+ python -u ABIDES/abides.py -c world_agent_sim -t ${stock_symbol} -date ${date} -d True -m TRADES -st '09:30:00' -et '12:00:00'
66
+ ```
67
+
68
+ When the simulation ends a log dir will be saved in ABIDES/log, here you can find the processed orders of the simulation, and all the plots used to in the paper to evaluate the stylized facts. At the end of the simulation also the predictive score will be computed.
69
+ If you want to perform a simulation with CGAN you need simply to change the -m option to CGAN.
70
+ To reproduce the results of the paper you need exactly the same data, so TSLA or INTC of 29/01/2015 or 30/01/2015.
71
+
72
+ ## Running a Market Simulation with IABS configuration
73
+ If you want to run the IABS configuration:
74
+ ```sh
75
+ python -u ABIDES/abides.py -c rsmc_03 -date 20150130 -st '09:30:00' -et '12:00:00'
76
+ ```
77
+
78
+ # Training
79
+ If you aim to train a TRADES model or implement your model you should follow those steps.
80
+
81
+ ## Data
82
+ 1. Firstly you need to have some LOBSTER data otherwise it would be impossible to train a new model. The format of the data should be the same as LOBSTER: f"{year}-{month}-{day}_34200000_57600000_{type}" and the data should be saved in f"data/{stock_name}/{stock_name}_{year}-{start_month}-{start_day}_{year}-{end_month}-{end_day}". The type can be a message or orderbook.
83
+ 2. You need to add the new stock to the constants and to the config file.
84
+ 3. you need to change cst.DATE_TRAING_DAYS setting the start day and end day
85
+ 4. You need to start the preprocessing setting, to do so set config.IS_DATA_PREPROCESSED to False and run python main.py
86
+
87
+ ## Implementing and Training a new model
88
+ To train a new model, follow these steps:
89
+ 1. Implement your model class in the models/ directory. Your model class should inherit from the NNEngine class and should be a Pytorch Lightning engine.
90
+ 2. Update the HP_DICT_MODEL dictionary in run.py to include your model and its hyperparameters.
91
+ 3. Create a file {model_name}_hparam and write the hyperparameters that you want to use for your model. You can also specify hyperparameters for a hyperparameter search. Use the TRADES model as an example.
92
+ 4. Choose a configuration by modifying the `configuration.py` file.
93
+ 5. Run the training script:
94
+ ```sh
95
+ python main.py
96
+ ```
97
+ 6. A checkpoint will be saved in data/checkpoints/ that later you can use to perform a market simulation
98
+
99
+ ## Training a TRADES Model
100
+ ![TRADES's Architecture](https://github.com/LeonardoBerti00/DeepMarket/blob/main/data/architecture.jpg)
101
+ To train a TRADES model, you need to follow these steps:
102
+ 1. Set the CHOSEN_MODEL in configuration.py to cst.Models.TRADES
103
+ 2. Optionally, adjust the simulation parameters in `configuration.py`.
104
+ 3. Now you can run the main.py with:
105
+ ```sh
106
+ python main.py
107
+ ```
108
+
109
+ # Citing
110
+ If you use the framework in a research project please cite:
111
+ ```sh
112
+ @misc{berti2025tradesgeneratingrealisticmarket,
113
+ title={TRADES: Generating Realistic Market Simulations with Diffusion Models},
114
+ author={Leonardo Berti and Bardh Prenkaj and Paola Velardi},
115
+ year={2025},
116
+ eprint={2502.07071},
117
+ archivePrefix={arXiv},
118
+ primaryClass={q-fin.TR},
119
+ url={https://arxiv.org/abs/2502.07071},
120
+ }
121
+ ```