forked from waditu/czsc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
use_optimize.py
112 lines (102 loc) · 4.59 KB
/
use_optimize.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
from czsc.connectors.research import get_symbols, get_raw_bars
from czsc.traders.optimize import OpensOptimize, ExitsOptimize
def run_opens_optim():
symbols = get_symbols('期货主力')[:10]
results_path = r"D:\QMT投研\CCI入场优化结果B"
files_position = [
r"D:\QMT投研\基础策略V230707\A股日线CCI空头基准.json",
r"D:\QMT投研\基础策略V230707\A股日线CCI多头基准.json",
]
task_name = 'CCI入场优化'
candidate_signals = """
日线_D2单K趋势N5_BS辅助V230506_第1层_任意_任意_0
日线_D2单K趋势N5_BS辅助V230506_第2层_任意_任意_0
日线_D2单K趋势N5_BS辅助V230506_第3层_任意_任意_0
日线_D2单K趋势N5_BS辅助V230506_第4层_任意_任意_0
日线_D2单K趋势N10_BS辅助V230506_第1层_任意_任意_0
日线_D2单K趋势N10_BS辅助V230506_第2层_任意_任意_0
日线_D2单K趋势N10_BS辅助V230506_第4层_任意_任意_0
日线_D2单K趋势N10_BS辅助V230506_第6层_任意_任意_0
日线_D2单K趋势N10_BS辅助V230506_第7层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第11层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第12层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第13层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第14层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第15层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第16层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第18层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第1层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第2层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第3层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第4层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第5层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第6层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第7层_任意_任意_0
日线_D2单K趋势N20_BS辅助V230506_第8层_任意_任意_0
""".strip().replace(' ', '').split('\n')
candidate_signals = list(set(candidate_signals))
oop = OpensOptimize(symbols=symbols, files_position=files_position, task_name=task_name,
candidate_signals=candidate_signals, read_bars=get_raw_bars,
results_path=results_path, signals_module_name='czsc.signals',
bar_sdt='20160101', bar_edt='20230101', sdt='20170101')
oop.execute(n_jobs=10)
def run_exits_optim():
symbols = get_symbols('期货主力')[:10]
results_path = r"D:\QMT投研\CCI出场优化结果B"
files_position = [
r"D:\QMT投研\基础策略V230707\A股日线CCI空头基准.json",
r"D:\QMT投研\基础策略V230707\A股日线CCI多头基准.json",
]
task_name = '加速上涨优化多头'
candidate_events = [
{'operate': '平多',
'factors': [
{'name': '加速上涨',
'signals_all': [
"日线_D2N5T500_绝对动量V230227_超强_任意_任意_0",
]}
]},
{'operate': '平多',
'factors': [
{'name': '加速上涨',
'signals_all': [
"日线_D2N8T600_绝对动量V230227_超强_任意_任意_0",
]}
]},
{'operate': '平多',
'factors': [
{'name': '加速上涨',
'signals_all': [
"日线_D2N10T800_绝对动量V230227_超强_任意_任意_0",
]}
]},
{'operate': '平空',
'factors': [
{'name': '加速下跌',
'signals_all': [
"日线_D2N5T300_绝对动量V230227_超弱_任意_任意_0",
]}
]},
{'operate': '平空',
'factors': [
{'name': '加速下跌',
'signals_all': [
"日线_D2N8T500_绝对动量V230227_超弱_任意_任意_0",
]}
]},
{'operate': '平空',
'factors': [
{'name': '加速下跌',
'signals_all': [
"日线_D2N10T800_绝对动量V230227_超弱_任意_任意_0",
]}
]},
]
eop = ExitsOptimize(symbols=symbols, files_position=files_position, task_name=task_name,
candidate_events=candidate_events, read_bars=get_raw_bars,
results_path=results_path, signals_module_name='czsc.signals',
bar_sdt='20160101', bar_edt='20230101', sdt='20170101')
eop.execute(n_jobs=10)
if __name__ == '__main__':
run_opens_optim()
run_exits_optim()