-
Notifications
You must be signed in to change notification settings - Fork 91
/
script_create_features.py
80 lines (68 loc) · 2 KB
/
script_create_features.py
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import argparse
import datetime as dt
from typing import List
import pandas as pd
from data.pull_data import pull_yahoo_sample_data
from settings.default import (
COMMODITIES_TICKERS,
CPD_DEFAULT_LBW,
CPD_OUTPUT_FOLDER_DEFAULT,
FEATURES_FILE_PATH_DEFAULT,
)
from src.data_prep import deep_momentum_strategy_features, include_changepoint_features
def main(
tickers: List[str],
cpd_module_folder: str,
lookback_window_length: int,
output_file_path: str,
):
features = pd.concat(
[
deep_momentum_strategy_features(pull_yahoo_sample_data(ticker)).assign(
ticker=ticker
)
for ticker in tickers
]
)
include_changepoint_features(
features, cpd_module_folder, lookback_window_length
).to_csv(output_file_path)
if __name__ == "__main__":
def get_args():
"""Returns settings from command line."""
parser = argparse.ArgumentParser(description="Run changepoint detection module")
parser.add_argument(
"cpd_module_folder",
metavar="c",
type=str,
nargs="?",
default=CPD_OUTPUT_FOLDER_DEFAULT,
# choices=[],
help="Input folder for CPD outputs.",
)
parser.add_argument(
"lookback_window_length",
metavar="l",
type=int,
nargs="?",
default=CPD_DEFAULT_LBW,
# choices=[],
help="Input folder for CPD outputs.",
)
parser.add_argument(
"output_file_path",
metavar="f",
type=str,
nargs="?",
default=FEATURES_FILE_PATH_DEFAULT,
# choices=[],
help="Output file location for csv.",
)
args = parser.parse_known_args()[0]
return (
COMMODITIES_TICKERS,
args.cpd_module_folder,
args.lookback_window_length,
args.output_file_path,
)
main(*get_args())