-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.py
More file actions
64 lines (47 loc) · 1.82 KB
/
Copy pathrun.py
File metadata and controls
64 lines (47 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# dependencies & imports
import sys, json, os
import warnings
import pandas as pd
import matplotlib.pyplot as plt
warnings.filterwarnings("ignore")
sys.path.insert(0, 'src')
from data import make_dataset
from features import build_features, build_images, build_labels
# define main
def main(targets):
if ('test' in targets):
# get test params
with open('config/test_params.json') as fh:
data_cfg = json.load(fh)
raw_fp = data_cfg['raw_path']
test_fn = data_cfg['file_name']
market_fn = data_cfg['market_name']
time_wdw = data_cfg['time_wdw']
img_fp = data_cfg['output_img_path']
label_fp = data_cfg["output_lable_path"]
data_file = os.path.join(raw_fp, test_fn)
data = pd.read_csv(data_file, parse_dates = ['time'])
market_file = os.path.join(raw_fp, market_fn)
market_data = pd.read_csv(market_file, parse_dates = ['time'])
# all case
else:
# get all params
with open('config/data_params.json') as fh:
data_cfg = json.load(fh)
raw_fp = data_cfg['raw_path']
time_wdw = data_cfg['time_wdw']
img_fp = data_cfg['output_img_path']
# merged 8:30-9:30 data
data = make_dataset.merge_data(raw_fp)
# data with volatility
data = build_features.feature_engineer(data, time_wdw)
# data for gramian angular field
data_gaf = make_dataset.gaf_df(data)
# creates images from polar coordinates, saves them to img_fp
build_images.gramian_img(img_fp, data_gaf)
# creates a table of image id and its corresponding label, saves it to label_fp
build_labels.label (data, market_data, label_fp)
return
if __name__ == '__main__':
targets = sys.argv[1:]
main(targets)