MCPcopy Create free account
hub / github.com/FinancialComputingUCL/LOBFrame / DataUtils

Class DataUtils

data_processing/data_process_utils.py:6–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5
6class DataUtils:
7 def __init__(self, ticker, dataset, experiment_id, horizons, normalization_window):
8 self.ticker = ticker # Ticker of the stock to be processed.
9 self.dataset = dataset # Dataset to be used.
10 self.experiment_id = experiment_id # Experiment ID.
11 self.horizons = horizons # Horizons to be used when computing labels.
12 self.normalization_window = normalization_window # Normalization window to be used when normalizing data.
13
14 self.__raw_data_path = None # Path containing the raw LOB data.
15 self.__processed_data_path_unscaled_data = (
16 None # Path containing the processed but unscaled LOB data.
17 )
18 self.__processed_data_path_scaled_data = (
19 None # Path containing the processed and scaled LOB data.
20 )
21 self.__logs_path = None # Path containing the logs of the data processing.
22
23 def __set_raw_data_path(self):
24 # Set the raw data path according to the dataset.
25 if self.dataset == "nasdaq":
26 self.__raw_data_path = f"./data/{self.dataset}/raw/{self.ticker}"
27
28 def __set_processed_data_path_unscaled_data(self):
29 # Set the path containing the processed but unscaled LOB data according to the dataset.
30 if self.dataset == "nasdaq":
31 self.__processed_data_path_unscaled_data = (
32 f"./data/{self.dataset}/unscaled_data/{self.ticker}"
33 )
34
35 def __set_processed_data_path_scaled_data(self):
36 # Set the path containing the processed and scaled LOB data according to the dataset.
37 if self.dataset == "nasdaq":
38 self.__processed_data_path_scaled_data = (
39 f"./data/{self.dataset}/scaled_data/{self.ticker}"
40 )
41
42 def __set_logs_path(self):
43 # Set the path containing the logs of the data processing according to the experiment ID.
44 self.__logs_path = (
45 f"./loggers/results/{self.experiment_id}/data_processing_logs"
46 )
47
48 def generate_data_folders(self):
49 self.__set_raw_data_path() # Set the raw data path.
50 self.__set_processed_data_path_unscaled_data() # Set the path containing the processed but unscaled LOB data.
51 self.__set_processed_data_path_scaled_data() # Set the path containing the processed and scaled LOB data.
52 self.__set_logs_path() # Set the path containing the logs of the data processing.
53
54 # Create the folder for the processed but unscaled LOB data if it does not exist.
55 if not os.path.exists(self.__processed_data_path_unscaled_data):
56 os.makedirs(self.__processed_data_path_unscaled_data)
57
58 # Create the folder for the processed and scaled LOB data if it does not exist.
59 if not os.path.exists(self.__processed_data_path_scaled_data):
60 os.makedirs(self.__processed_data_path_scaled_data)
61
62 # Create the folder for the logs of the data processing if it does not exist.
63 if not os.path.exists(self.__logs_path):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected