-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.py
177 lines (163 loc) · 6.25 KB
/
config.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# -*- coding=utf-8 -*-
# @File : myconfig.py
# @Time : 2023/8/2 18:57
# @Author : EvanHong
# @Email : [email protected]
# @Project : 2023.06.08超高频上证50指数计算
# @Description: 回测系统的config,包括费率等超参的设定
from datetime import timedelta
import os
from backtest.support import str2timedelta, create_dirs
code_dict = {
# '浦发银行': '600000.XSHG',
# 沪深300
# '贵州茅台': '600519.XSHG',
# '宁德时代': '300750.XSHE',
# '招商银行': '600036.XSHG',
# '中国平安': '601318.XSHG',
# '隆基绿能': '601012.XSHG',
# '五粮液': '000858.XSHE',
# '比亚迪': '002594.XSHE',
# '美的集团': '000333.XSHE',
# '兴业银行': '601166.XSHG',
# '东方财富': '300059.XSHE',
# 上证50
'贵州茅台': '600519.XSHG',
'中国平安': '601318.XSHG',
'招商银行': '600036.XSHG',
'兴业银行': '601166.XSHG',
'中信证券': '600030.XSHG',
'紫金矿业': '601899.XSHG',
'长江电力': '600900.XSHG',
'恒瑞医药': '600276.XSHG',
'万华化学': '600309.XSHG',
'伊利股份': '600887.XSHG',
'隆基绿能': '601012.XSHG',
'工商银行': '601398.XSHG',
'药明康德': '603259.XSHG',
'中国建筑': '601668.XSHG',
'中国中免': '601888.XSHG',
'中国石化': '600028.XSHG',
'山西汾酒': '600809.XSHG',
'农业银行': '601288.XSHG',
'三一重工': '600031.XSHG',
'保利发展': '600048.XSHG', # <-
'中国联通': '600050.XSHG',
'国电南瑞': '600406.XSHG',
'通威股份': '600438.XSHG',
'中国神华': '601088.XSHG',
'海尔智家': '600690.XSHG',
'中国石油': '601857.XSHG',
'中国电信': '601728.XSHG',
'片仔癀': '600436.XSHG',
'韦尔股份': '603501.XSHG',
'特变电工': '600089.XSHG',
'中国中铁': '601390.XSHG',
'海天味业': '603288.XSHG',
'三峡能源': '600905.XSHG',
'兆易创新': '603986.XSHG',
'金山办公': '688111.XSHG',
'上汽集团': '600104.XSHG',
'华友钴业': '603799.XSHG',
'中远海控': '601919.XSHG',
'陕西煤业': '601225.XSHG',
'北方稀土': '600111.XSHG',
'中国人寿': '601628.XSHG',
'航发动力': '600893.XSHG',
'包钢股份': '600010.XSHG',
'中国电建': '601669.XSHG',
'天合光能': '688599.XSHG',
'闻泰科技': '600745.XSHG',
'复星医药': '600196.XSHG',
'长城汽车': '601633.XSHG',
'中信建投': '601066.XSHG',
'合盛硅业': '603260.XSHG',
# 测试
# '恒瑞医药': '600276.XSHG',
# '紫金矿业': '601899.XSHG',
# '浦发银行': '600000.XSHG',
# '海通证券': '600837.XSHG',
# '沪深300ETF': '510300.XSHG',
# '涨停股测试': '600219.XSHG',
# lobster
# "AAPL":"AAPL",
# "AMZN": "AMZN",
# "GOOG": "GOOG",
# "INTC": "INTC",
# "MSFT": "MSFT",
}
complete_status = {}
stk_name_dict = {v: k for k, v in code_dict.items()}
exclude = []
root='/Users/hongyifan/Desktop/work/internship/citic_futures/20231226bid-ask-spread/'
data_root = root + 'data/'
detail_data_root = data_root + '个股交易细节/'
res_root = root + 'res/'
model_root = root + 'models/'
scaler_root = root + 'scalers/'
sub_dirs = [d + '10min_10min/' for d in [res_root, model_root, scaler_root]]
# create_dirs(sub_dirs)
# 函数比formatted字符串更灵活
FILE_FMT_order_book_history = "{}_{}_order_book_history.csv" # 默认买卖各10档
FILE_FMT_order_book_history_dict = "{}_{}_order_book_history.pkl" # 默认买卖各10档
FILE_FMT_price_history = "{}_{}_price_history.csv"
FILE_FMT_clean_obh = "{}_{}_clean_obh.csv" # 默认买卖各5档
FILE_FMT_my_trade_details = "{}_{}_my_trade_details.csv"
FILE_FMT_vol_tov = "{}_{}_vol_tov.csv"
FILE_FMT_model = "{}_period{}_{}.pkl" # "{[stkname|'general']}_period{period}_{extract_model_name(model)}.pkl"
FILE_FMT_scaler = "{}_scaler_{}_{}.pkl" # "{stkname}_scaler_{period}_{Any:default:'_'}.pkl"
FILE_FMT_events = "{}_{}_events.csv"
FILE_FMT_feature = "{}_{}_feature{}.csv"
y = None
m = None
d = None
date = None
date1 = None
start = None
end = None
important_times = None
ranges = None
# ==========prediction settings===========
# ret
# target = Target.vol.name # ret,current
# min_freq='10ms' # 最小精度,agg前data的频率,load data默认将数据asfreq至该freq
# agg_freq=min_freq # 计算feature agg的时候,用多少的数据去agg出一个数据点,也即agg后feature的freq
# freq = agg_freq
# freq_minutes=1
# pred_n_steps = 200 # 预测1个1min
# use_n_steps = 3 # 利用use_n_steps个steps的数据去预测pred_n_steps之后的涨跌幅
# drop_current = False # 是否将当前股价作为因子输入给模型
# use_level = 5
# strip_time='5min' # 去掉开收盘5min数据
# # vol
# target = Target.vol.name # vol
# min_freq='1s' # 最小精度,agg前data的频率,load data默认将数据asfreq至该freq
# agg_freq='1min' # 计算feature agg的时候,用多少的数据去agg出一个数据点,也即agg后feature的freq
# freq = agg_freq
# # freq_minutes=1
# pred_n_steps = 10 # 预测1个1min
# use_n_steps = 10 # 利用use_n_steps个steps的数据去预测pred_n_steps之后的涨跌幅
# drop_current = False # 是否将当前股价作为因子输入给模型
# use_level = 5
# strip_time='5min' # 去掉开收盘5min数据
# --------若要使用海通时期的代码,请取消注释以下片段----------
# # vol_chg
# target = Target.vol_chg.name # vol_chg
# min_freq='3s' # 最小精度,agg前data的频率,calc_features将数据asfreq至该freq
# agg_freq='10min' # 计算feature agg的时候,用多少的数据去agg出一个数据点,也即agg后feature的freq
# freq = agg_freq
# # freq_minutes=1
# pred_n_steps = 1 # 预测1个10min
# use_n_steps = 1 # 利用use_n_steps个steps的数据去预测pred_n_steps之后的涨跌幅
# drop_current = False # 是否将当前股价作为因子输入给模型
# use_level = 5
# strip_time='5min' # 去掉开收盘5min数据
strip_time=None
# min_timedelta=str2timedelta(min_freq)
# agg_timedelta=str2timedelta(agg_freq,use_n_steps)
# pred_timedelta=str2timedelta(agg_freq,pred_n_steps)
# strip_timedelta=str2timedelta(strip_time)
# ------------------------------------------------------
# ====================================
# init
# update_date(yyyy='2022', mm='06', dd='29')