-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmock_generator.py
More file actions
56 lines (49 loc) · 1.62 KB
/
Copy pathmock_generator.py
File metadata and controls
56 lines (49 loc) · 1.62 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
import argparse
from data.service import *
from util.constant import INCLUDED_CODES
from util.utils import get_date
if __name__ == "__main__":
parser = argparse.ArgumentParser("mock generator")
parser.add_argument("mode", help="backtesting or validation")
args = parser.parse_args()
start, from_date, to_date, end = (
get_date(
optimization_params["os_from_date"],
optimization_params["os_to_date"],
forward_period=90,
look_back=120,
)
if args.mode == "validation"
else get_date(
backtesting_config["from_date"],
backtesting_config["to_date"],
forward_period=90,
look_back=120,
)
)
financial_path = (
"mock/out-sample/financial_data.csv"
if args.mode == "validation"
else "mock/in-sample/financial_data.csv"
)
daily_path = (
"mock/out-sample/daily_data.csv"
if args.mode == "validation"
else "mock/in-sample/daily_data.csv"
)
index_path = (
"mock/out-sample/index_data.csv"
if args.mode == "validation"
else "mock/in-sample/index_data.csv"
)
print("Financial Data...")
financial_data = data_service.get_financial_data(
start.year, to_date.year, INCLUDED_CODES
)
financial_data.to_csv(financial_path, index=False)
print("Daily Data...")
daily_data = data_service.get_daily_data(start, end)
daily_data.to_csv(daily_path, index=False)
print("Index Data...")
index_data = data_service.get_index_data(from_date, end)
index_data.to_csv(index_path, index=False)