|
@@ -35,16 +35,16 @@ def predict_today(file, day, model='10_18d', log=True):
|
35
|
35
|
|
36
|
36
|
for line in lines:
|
37
|
37
|
train_x = np.array([line[:size - 1]])
|
38
|
|
- train_x_tmp = train_x[:,:30*19]
|
39
|
|
- train_x_a = train_x_tmp.reshape(train_x.shape[0], 30, 19, 1)
|
40
|
|
- # train_x_b = train_x_tmp.reshape(train_x.shape[0], 18, 24)
|
41
|
|
- train_x_c = train_x[:,30*19:]
|
|
38
|
+ # train_x_tmp = train_x[:,:30*19]
|
|
39
|
+ # train_x_a = train_x_tmp.reshape(train_x.shape[0], 30, 19, 1)
|
|
40
|
+ # # train_x_b = train_x_tmp.reshape(train_x.shape[0], 18, 24)
|
|
41
|
+ # train_x_c = train_x[:,30*19:]
|
42
|
42
|
|
43
|
|
- result = model.predict([train_x_c, train_x_a, ])
|
|
43
|
+ result = model.predict([train_x, ])
|
44
|
44
|
# print(result, line[-1])
|
45
|
45
|
stock = code_table.find_one({'ts_code':line[-1][0]})
|
46
|
46
|
|
47
|
|
- if result[0][0] > 0.5 and stock['sw_industry'] in industry_list:
|
|
47
|
+ if result[0][0] > 0.85:
|
48
|
48
|
if line[-1][0].startswith('688'):
|
49
|
49
|
continue
|
50
|
50
|
# 去掉ST
|
|
@@ -66,27 +66,24 @@ def predict_today(file, day, model='10_18d', log=True):
|
66
|
66
|
|
67
|
67
|
if stock['ts_code'] in zixuan_stock_list:
|
68
|
68
|
# print(line[-1], stock['name'], stock['sw_industry'], str(concept_detail_list), 'buy', k_table_list[0]['pct_chg'])
|
69
|
|
- print(stock['ts_code'], stock['name'], '买入评级', k_table_list[0]['pct_chg'])
|
70
|
|
- Z_list.append([stock['name'], stock['sw_industry'], k_table_list[0]['pct_chg']])
|
71
|
|
- elif stock['ts_code'] in ROE_stock_list:
|
72
|
|
- print(stock['ts_code'], stock['name'], '买入评级', k_table_list[0]['pct_chg'])
|
73
|
|
- R_list.append([stock['name'], stock['sw_industry'], k_table_list[0]['pct_chg']])
|
|
69
|
+ print(stock['ts_code'], stock['name'], '买入评级', result[0][0])
|
|
70
|
+ Z_list.append([stock['name'], stock['sw_industry'], result[0][0]])
|
|
71
|
+ elif stock['ts_code'] in ROE_stock_list or stock['ts_code'] in zeng_stock_list:
|
|
72
|
+ print(stock['ts_code'], stock['name'], '买入评级', result[0][0])
|
|
73
|
+ R_list.append([stock['name'], stock['sw_industry'], result[0][0]])
|
74
|
74
|
else:
|
75
|
|
- O_list.append([stock['name'], stock['sw_industry'], k_table_list[0]['pct_chg']])
|
|
75
|
+ O_list.append([stock['name'], stock['sw_industry'], result[0][0]])
|
76
|
76
|
|
77
|
77
|
if log is True:
|
78
|
78
|
with open('D:\\data\\quantization\\predict\\' + str(day) + '_mix.txt', mode='a', encoding="utf-8") as f:
|
79
|
79
|
f.write(str(line[-1]) + ' ' + stock['name'] + ' ' + stock['sw_industry'] + ' ' + str(concept_detail_list) + ' ' + str(result[0][0]) + '\n')
|
80
|
80
|
|
81
|
|
- # elif result[0][1] > 0.5:
|
82
|
|
- # if stock['ts_code'] in holder_stock_list:
|
83
|
|
- # print(stock['ts_code'], stock['name'], '震荡评级')
|
84
|
|
- # elif result[0][2] > 0.4:
|
85
|
|
- # if stock['ts_code'] in holder_stock_list:
|
86
|
|
- # print(stock['ts_code'], stock['name'], '赶紧卖出')
|
87
|
|
- # else:
|
88
|
|
- # if stock['ts_code'] in holder_stock_list or stock['ts_code'] in ROE_stock_list:
|
89
|
|
- # print(stock['ts_code'], stock['name'], result[0],)
|
|
81
|
+ elif result[0][1] > 0.5:
|
|
82
|
+ if stock['ts_code'] in holder_stock_list:
|
|
83
|
+ print(stock['ts_code'], stock['name'], '震荡评级')
|
|
84
|
+ elif result[0][2] > 0.5:
|
|
85
|
+ if stock['ts_code'] in holder_stock_list:
|
|
86
|
+ print(stock['ts_code'], stock['name'], '赶紧卖出')
|
90
|
87
|
|
91
|
88
|
# print(gainian_map)
|
92
|
89
|
# print(hangye_map)
|
|
@@ -121,46 +118,12 @@ def predict_today(file, day, model='10_18d', log=True):
|
121
|
118
|
print(O_list[:3])
|
122
|
119
|
|
123
|
120
|
|
124
|
|
-def _read_pfile_map(path):
|
125
|
|
- s_list = []
|
126
|
|
- with open(path, encoding='utf-8') as f:
|
127
|
|
- for line in f.readlines()[:]:
|
128
|
|
- s_list.append(line)
|
129
|
|
- return s_list
|
130
|
|
-
|
131
|
|
-
|
132
|
|
-def join_two_day(a, b):
|
133
|
|
- a_list = _read_pfile_map('D:\\data\\quantization\\predict\\' + str(a) + '.txt')
|
134
|
|
- b_list = _read_pfile_map('D:\\data\\quantization\\predict\\dmi_' + str(b) + '.txt')
|
135
|
|
- for a in a_list:
|
136
|
|
- for b in b_list:
|
137
|
|
- if a[2:11] == b[2:11]:
|
138
|
|
- print(a)
|
139
|
|
-
|
140
|
|
-
|
141
|
|
-def check_everyday(day, today):
|
142
|
|
- a_list = _read_pfile_map('D:\\data\\quantization\\predict\\' + str(day) + '.txt')
|
143
|
|
- x = 0
|
144
|
|
- for a in a_list:
|
145
|
|
- print(a[:-1])
|
146
|
|
- k_day_list = list(k_table.find({'code':a[2:11], 'tradeDate':{'$lte':int(today)}}).sort('tradeDate', pymongo.DESCENDING).limit(5))
|
147
|
|
- if k_day_list is not None and len(k_day_list) > 0:
|
148
|
|
- k_day = k_day_list[0]
|
149
|
|
- k_day_0 = k_day_list[-1]
|
150
|
|
- k_day_last = k_day_list[1]
|
151
|
|
- if ((k_day_last['close'] - k_day_0['pre_close'])/k_day_0['pre_close']) < 0.2:
|
152
|
|
- print(k_day['open'], k_day['close'], 100*(k_day['close'] - k_day_last['close'])/k_day_last['close'])
|
153
|
|
- x = x + 100*(k_day['close'] - k_day_last['close'])/k_day_last['close']
|
154
|
|
-
|
155
|
|
- print(x/len(a_list))
|
156
|
|
-
|
157
|
|
-
|
158
|
121
|
if __name__ == '__main__':
|
159
|
122
|
# predict(file_path='D:\\data\\quantization\\stock6_5_test.log', model_path='5d_dnn_seq.h5')
|
160
|
123
|
# predict(file_path='D:\\data\\quantization\\stock6_test.log', model_path='15m_dnn_seq.h5')
|
161
|
124
|
# multi_predict()
|
162
|
125
|
# predict_today("D:\\data\\quantization\\stock405_30d_20200413.log", 20200413, model='405_30d_mix_5D_ma5_s_seq.h5', log=True)
|
163
|
|
- # 模型A
|
164
|
|
- predict_today("D:\\data\\quantization\\stock603_30d_20200415.log", 20200415, model='603_30d_mix_5D_ma5_s_seq.h5', log=True)
|
|
126
|
+ # 模型 下跌趋势,没大涨的不要买
|
|
127
|
+ predict_today("D:\\data\\quantization\\stock578A_5d_20200430.log", 20200430, model='5d_578A_dnn_seq.h5', log=True)
|
165
|
128
|
# join_two_day(20200305, 20200305)
|
166
|
129
|
# check_everyday(20200311, 20200312)
|