mns-scheduler 1.0.7.5__py3-none-any.whl → 1.0.7.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mns-scheduler might be problematic. Click here for more details.
- mns_scheduler/db/col_move_service.py +5 -1
- mns_scheduler/open/__init__.py +7 -0
- mns_scheduler/open/sync_one_day_open_data_to_db_service.py +86 -0
- mns_scheduler/zt/connected_boards/__init__.py +8 -0
- mns_scheduler/zt/export/__init__.py +8 -0
- mns_scheduler/zt/{export_open_data_to_excel.py → export/export_kcx_high_chg_open_data_to_excel.py} +2 -0
- mns_scheduler/zt/high_chg/__init__.py +7 -0
- mns_scheduler/zt/high_chg/sync_high_chg_pool_service.py +283 -0
- mns_scheduler/zt/high_chg/sync_high_chg_real_time_quotes_service.py +141 -0
- mns_scheduler/zt/open_data/__init__.py +8 -0
- mns_scheduler/zt/{realtime_quotes_now_zt_kc_sync.py → open_data/kcx_high_chg_open_data_sync.py} +9 -142
- mns_scheduler/zt/script/__init__.py +7 -0
- mns_scheduler/zt/script/kcx_high_chg_open_his_data_handle.py +113 -0
- mns_scheduler/zt/script/sync_high_chg_pool_his_data.py +39 -0
- mns_scheduler/zt/zt_pool/__init__.py +8 -0
- mns_scheduler/zz_task/data_sync_task.py +16 -10
- {mns_scheduler-1.0.7.5.dist-info → mns_scheduler-1.0.7.7.dist-info}/METADATA +1 -1
- {mns_scheduler-1.0.7.5.dist-info → mns_scheduler-1.0.7.7.dist-info}/RECORD +22 -11
- mns_scheduler/zt/today_high_chg_pool_sync_api.py +0 -481
- /mns_scheduler/zt/{zt_five_boards_sync_api.py → connected_boards/zt_five_boards_sync_api.py} +0 -0
- /mns_scheduler/zt/{zt_pool_sync_api.py → zt_pool/zt_pool_sync_api.py} +0 -0
- {mns_scheduler-1.0.7.5.dist-info → mns_scheduler-1.0.7.7.dist-info}/WHEEL +0 -0
- {mns_scheduler-1.0.7.5.dist-info → mns_scheduler-1.0.7.7.dist-info}/top_level.txt +0 -0
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
file_path = os.path.abspath(__file__)
|
|
5
|
-
end = file_path.index('mns') + 17
|
|
6
|
-
project_path = file_path[0:end]
|
|
7
|
-
sys.path.append(project_path)
|
|
8
|
-
|
|
9
|
-
import sys
|
|
10
|
-
import os
|
|
11
|
-
|
|
12
|
-
file_path = os.path.abspath(__file__)
|
|
13
|
-
end = file_path.index('mns') + 17
|
|
14
|
-
project_path = file_path[0:end]
|
|
15
|
-
sys.path.append(project_path)
|
|
16
|
-
|
|
17
|
-
import pandas as pd
|
|
18
|
-
from loguru import logger
|
|
19
|
-
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
20
|
-
import mns_common.component.trade_date.trade_date_common_service_api as trade_date_common_service_api
|
|
21
|
-
import mns_common.api.em.east_money_stock_api as east_money_stock_api
|
|
22
|
-
import mns_common.utils.date_handle_util as date_handle_util
|
|
23
|
-
import mns_common.component.company.company_common_service_api as company_common_service_api
|
|
24
|
-
import mns_common.component.data.data_init_api as data_init_api
|
|
25
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
26
|
-
import mns_common.utils.data_frame_util as data_frame_util
|
|
27
|
-
import mns_common.component.zt.zt_common_service_api as zt_common_service_api
|
|
28
|
-
|
|
29
|
-
mongodb_util = MongodbUtil('27017')
|
|
30
|
-
mongodb_util_27019 = MongodbUtil('27019')
|
|
31
|
-
|
|
32
|
-
save_zt_name = 'realtime_quotes_now_zt_new'
|
|
33
|
-
choose_field = ["_id",
|
|
34
|
-
"symbol",
|
|
35
|
-
"name",
|
|
36
|
-
"industry",
|
|
37
|
-
"now_price",
|
|
38
|
-
"chg",
|
|
39
|
-
"quantity_ratio",
|
|
40
|
-
"amount_level",
|
|
41
|
-
"disk_ratio",
|
|
42
|
-
"real_disk_diff_amount_exchange",
|
|
43
|
-
'max_real_main_inflow_multiple',
|
|
44
|
-
'sum_main_inflow_disk',
|
|
45
|
-
"real_main_inflow_multiple",
|
|
46
|
-
"real_super_main_inflow_multiple",
|
|
47
|
-
"super_main_inflow_multiple",
|
|
48
|
-
"main_inflow_multiple",
|
|
49
|
-
"disk_diff_amount_exchange",
|
|
50
|
-
"large_inflow_multiple",
|
|
51
|
-
"today_main_net_inflow",
|
|
52
|
-
"today_main_net_inflow_ratio",
|
|
53
|
-
"super_large_order_net_inflow",
|
|
54
|
-
"super_large_order_net_inflow_ratio",
|
|
55
|
-
"large_order_net_inflow",
|
|
56
|
-
"large_order_net_inflow_ratio",
|
|
57
|
-
"reference_main_inflow",
|
|
58
|
-
"disk_diff_amount",
|
|
59
|
-
"mv_circulation_ratio",
|
|
60
|
-
"real_exchange",
|
|
61
|
-
"exchange",
|
|
62
|
-
'real_exchange',
|
|
63
|
-
"total_mv",
|
|
64
|
-
"flow_mv",
|
|
65
|
-
"volume",
|
|
66
|
-
"high",
|
|
67
|
-
"low",
|
|
68
|
-
"open",
|
|
69
|
-
"yesterday_price",
|
|
70
|
-
"amount",
|
|
71
|
-
"total_mv_sp",
|
|
72
|
-
"flow_mv_sp",
|
|
73
|
-
"outer_disk",
|
|
74
|
-
"inner_disk",
|
|
75
|
-
"classification",
|
|
76
|
-
"number",
|
|
77
|
-
"str_day",
|
|
78
|
-
"str_now_date"
|
|
79
|
-
]
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def create_index():
|
|
83
|
-
mongodb_util.create_index(save_zt_name,
|
|
84
|
-
[("symbol", 1), ("number", 1)])
|
|
85
|
-
|
|
86
|
-
mongodb_util.create_index(save_zt_name,
|
|
87
|
-
[("symbol", 1)])
|
|
88
|
-
|
|
89
|
-
mongodb_util.create_index(save_zt_name,
|
|
90
|
-
[("number", 1)])
|
|
91
|
-
|
|
92
|
-
mongodb_util.create_index(save_zt_name,
|
|
93
|
-
[("str_day", 1)])
|
|
94
|
-
|
|
95
|
-
mongodb_util.create_index(save_zt_name,
|
|
96
|
-
[("str_now_date", 1)])
|
|
97
|
-
mongodb_util.create_index(save_zt_name,
|
|
98
|
-
[("symbol", 1), ("str_now_date", 1)])
|
|
99
|
-
mongodb_util.create_index(save_zt_name,
|
|
100
|
-
[("str_day", 1), ("str_now_date", 1)])
|
|
101
|
-
|
|
102
|
-
mongodb_util.create_index(save_zt_name,
|
|
103
|
-
[("symbol", 1), ("str_day", 1)])
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def get_mongodb_util(str_day):
|
|
107
|
-
tag = mongodb_util.exist_data_query('trade_date_list', query={'_id': str_day, "tag": True})
|
|
108
|
-
if tag:
|
|
109
|
-
return mongodb_util_27019
|
|
110
|
-
else:
|
|
111
|
-
return mongodb_util
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
# 同步一天高涨幅列表
|
|
115
|
-
def save_stock_high_chg_pool(str_day):
|
|
116
|
-
real_time_quotes_now_init = east_money_stock_api.get_real_time_quotes_all_stocks()
|
|
117
|
-
|
|
118
|
-
sync_date = date_handle_util.add_date_day(date_handle_util.no_slash_date(str_day), 0)
|
|
119
|
-
str_now_day = sync_date.strftime('%Y-%m-%d')
|
|
120
|
-
|
|
121
|
-
realtime_quotes_db_name = 'realtime_quotes_now_' + str_now_day
|
|
122
|
-
number = get_today_realtime_quotes_max_number(realtime_quotes_db_name, str_day)
|
|
123
|
-
|
|
124
|
-
query = {"number": number, "chg": {'$gte': 9.7}}
|
|
125
|
-
|
|
126
|
-
real_time_quotes_now = mongodb_util.find_query_data(realtime_quotes_db_name, query)
|
|
127
|
-
if real_time_quotes_now.shape[0] == 0:
|
|
128
|
-
return
|
|
129
|
-
real_time_quotes_now = common_service_fun_api.total_mv_classification(
|
|
130
|
-
real_time_quotes_now.copy())
|
|
131
|
-
real_time_quotes_now = real_time_quotes_now.sort_values(by=['chg'], ascending=False)
|
|
132
|
-
real_time_quotes_now = common_service_fun_api.exclude_new_stock(real_time_quotes_now)
|
|
133
|
-
|
|
134
|
-
# todo fix industry
|
|
135
|
-
industry_group_df = company_common_service_api.get_company_info_industry()
|
|
136
|
-
industry_group_df = industry_group_df.set_index(['_id'], drop=True)
|
|
137
|
-
real_time_quotes_now.drop(columns=['industry'], inplace=True)
|
|
138
|
-
real_time_quotes_now = real_time_quotes_now.set_index(['symbol'], drop=False)
|
|
139
|
-
real_time_quotes_now = pd.merge(real_time_quotes_now, industry_group_df, how='outer',
|
|
140
|
-
left_index=True, right_index=True)
|
|
141
|
-
real_time_quotes_now = real_time_quotes_now.dropna(inplace=False)
|
|
142
|
-
|
|
143
|
-
zt_symbol_info = zt_common_service_api.get_last_trade_day_zt(str_day)
|
|
144
|
-
|
|
145
|
-
zt_symbol_connected_boards_numbers_list = zt_symbol_info.loc[
|
|
146
|
-
zt_symbol_info['symbol'].isin(real_time_quotes_now['symbol'])]
|
|
147
|
-
|
|
148
|
-
real_time_quotes_now['connected_boards_numbers'] = 1
|
|
149
|
-
if zt_symbol_connected_boards_numbers_list is not None and zt_symbol_connected_boards_numbers_list.shape[0] != 0:
|
|
150
|
-
for yesterday_zt in zt_symbol_connected_boards_numbers_list.itertuples():
|
|
151
|
-
real_time_quotes_now.loc[
|
|
152
|
-
real_time_quotes_now["symbol"] == yesterday_zt.symbol, ['connected_boards_numbers']] \
|
|
153
|
-
= 1 + yesterday_zt.connected_boards_numbers
|
|
154
|
-
|
|
155
|
-
for stock_one in real_time_quotes_now.itertuples():
|
|
156
|
-
try:
|
|
157
|
-
|
|
158
|
-
symbol = stock_one.symbol
|
|
159
|
-
|
|
160
|
-
classification = common_service_fun_api.classify_symbol_one(symbol)
|
|
161
|
-
|
|
162
|
-
chg = float(stock_one.chg)
|
|
163
|
-
if classification == 'X' and chg > 30:
|
|
164
|
-
continue
|
|
165
|
-
elif classification != 'X' and chg > 21:
|
|
166
|
-
continue
|
|
167
|
-
real_time_quotes_now_one = real_time_quotes_now_init.loc[
|
|
168
|
-
real_time_quotes_now_init['symbol'] == symbol]
|
|
169
|
-
list_date = list(real_time_quotes_now_one['list_date'])[0]
|
|
170
|
-
list_date = str(list_date)
|
|
171
|
-
list_date = list_date.replace(".0", "")
|
|
172
|
-
list_date = date_handle_util.lash_date(list_date)
|
|
173
|
-
|
|
174
|
-
list_date_time = date_handle_util.str_to_date(list_date, "%Y-%m-%d")
|
|
175
|
-
str_now_day_time = date_handle_util.str_to_date(str_now_day, "%Y-%m-%d")
|
|
176
|
-
|
|
177
|
-
list_to_now_days = date_handle_util.days_diff(str_now_day_time, list_date_time)
|
|
178
|
-
|
|
179
|
-
last_trade_day = trade_date_common_service_api.get_last_trade_day(str_day)
|
|
180
|
-
|
|
181
|
-
last_day_high_chg = mongodb_util.exist_data_query('stock_hfq_daily',
|
|
182
|
-
query={"symbol": symbol, "date": last_trade_day,
|
|
183
|
-
"chg": {'$gte': 9}})
|
|
184
|
-
|
|
185
|
-
open = stock_one.open
|
|
186
|
-
high = stock_one.high
|
|
187
|
-
close = stock_one.now_price
|
|
188
|
-
yi_zhi_ban = False
|
|
189
|
-
if open == high and open == close:
|
|
190
|
-
yi_zhi_ban = True
|
|
191
|
-
|
|
192
|
-
stock_high_chg_pool = {
|
|
193
|
-
'_id': symbol + '_' + str_now_day,
|
|
194
|
-
'symbol': symbol,
|
|
195
|
-
'name': stock_one.name,
|
|
196
|
-
'industry': stock_one.industry,
|
|
197
|
-
'str_day': str_now_day,
|
|
198
|
-
'classification': classification,
|
|
199
|
-
'chg': stock_one.chg,
|
|
200
|
-
"connected_boards_numbers": stock_one.connected_boards_numbers,
|
|
201
|
-
"open": stock_one.open,
|
|
202
|
-
"close": stock_one.now_price,
|
|
203
|
-
"high": stock_one.high,
|
|
204
|
-
"low": stock_one.low,
|
|
205
|
-
"volume": stock_one.volume,
|
|
206
|
-
"amount": stock_one.amount,
|
|
207
|
-
"flow_mv_level": stock_one.flow_mv_level,
|
|
208
|
-
"flow_mv_sp": stock_one.flow_mv_sp,
|
|
209
|
-
"total_mv_sp": stock_one.total_mv_sp,
|
|
210
|
-
"list_to_now_days": list_to_now_days,
|
|
211
|
-
"list_date": list_date,
|
|
212
|
-
"exchange": stock_one.exchange,
|
|
213
|
-
"last_day_high_chg": last_day_high_chg,
|
|
214
|
-
"yi_zhi_ban": yi_zhi_ban
|
|
215
|
-
}
|
|
216
|
-
mongodb_util.save_mongo(pd.DataFrame([stock_high_chg_pool], index=[0]),
|
|
217
|
-
'stock_high_chg_pool')
|
|
218
|
-
logger.info("更新高涨幅数据成功{},{}", stock_one.symbol, str_now_day)
|
|
219
|
-
except Exception as e:
|
|
220
|
-
logger.error("更新高涨幅数据异常:{},{},{}", stock_one.symbol, str_now_day, e)
|
|
221
|
-
continue
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
def get_today_realtime_quotes_max_number(realtime_quotes_db_name, str_day):
|
|
225
|
-
mongo = get_mongodb_util(str_day)
|
|
226
|
-
query = {"symbol": "000001"}
|
|
227
|
-
realtime_quotes = mongo.descend_query(query, realtime_quotes_db_name, 'number', 1)
|
|
228
|
-
if realtime_quotes is None or realtime_quotes.shape[0] == 0:
|
|
229
|
-
return 1
|
|
230
|
-
else:
|
|
231
|
-
return list(realtime_quotes['number'])[0]
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
def get_high_chg_symbol(str_day):
|
|
235
|
-
realtime_quotes_db_name = 'stock_qfq_daily'
|
|
236
|
-
|
|
237
|
-
query = {"date": date_handle_util.no_slash_date(str_day), "chg": {'$gte': 9.7}}
|
|
238
|
-
# 今日高涨幅的list
|
|
239
|
-
real_time_quotes_now_high_chg = mongodb_util.find_query_data(realtime_quotes_db_name, query)
|
|
240
|
-
if real_time_quotes_now_high_chg.shape[0] == 0:
|
|
241
|
-
return None
|
|
242
|
-
high_chg_list = list(real_time_quotes_now_high_chg['symbol'])
|
|
243
|
-
# 今日涨停股
|
|
244
|
-
|
|
245
|
-
query_zt = {'str_day': str_day}
|
|
246
|
-
zt_pool = mongodb_util.find_query_data('stock_zt_pool', query_zt)
|
|
247
|
-
if zt_pool.shape[0] > 0:
|
|
248
|
-
zt_pool_list = list(zt_pool['symbol'])
|
|
249
|
-
high_chg_list.extend(zt_pool_list)
|
|
250
|
-
high_chg_list = list(set(high_chg_list))
|
|
251
|
-
return high_chg_list
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
# 保存一天详细涨停数据
|
|
255
|
-
def sync_his_high_one_day(str_day):
|
|
256
|
-
mongo = get_mongodb_util(str_day)
|
|
257
|
-
|
|
258
|
-
realtime_quotes_db_name = 'realtime_quotes_now_' + str_day
|
|
259
|
-
high_chg_list = get_high_chg_symbol(str_day)
|
|
260
|
-
if high_chg_list is None or len(high_chg_list) == 0:
|
|
261
|
-
return
|
|
262
|
-
|
|
263
|
-
for symbol in high_chg_list:
|
|
264
|
-
try:
|
|
265
|
-
query_all = {"symbol": symbol}
|
|
266
|
-
real_time_quotes_now_high_chg_all = mongo.find_query_data(realtime_quotes_db_name, query_all)
|
|
267
|
-
if real_time_quotes_now_high_chg_all.shape[0] == 0:
|
|
268
|
-
return
|
|
269
|
-
real_time_quotes_now_high_chg_all = company_common_service_api.amendment_industry_exist_na(
|
|
270
|
-
real_time_quotes_now_high_chg_all,
|
|
271
|
-
high_chg_list)
|
|
272
|
-
real_time_quotes_now_high_chg_all.dropna(subset=['symbol'], axis=0,
|
|
273
|
-
inplace=True)
|
|
274
|
-
real_time_quotes_now_high_chg_all = data_init_api.calculate_parameter_factor(
|
|
275
|
-
real_time_quotes_now_high_chg_all)
|
|
276
|
-
|
|
277
|
-
real_time_quotes_now_high_chg_all['amount_level'] = round(
|
|
278
|
-
(real_time_quotes_now_high_chg_all['amount'] / common_service_fun_api.HUNDRED_MILLION), 2) * 10
|
|
279
|
-
real_time_quotes_now_high_chg_all['flow_mv_sp'] = round(
|
|
280
|
-
(real_time_quotes_now_high_chg_all['flow_mv'] / common_service_fun_api.HUNDRED_MILLION), 2)
|
|
281
|
-
real_time_quotes_now_high_chg_all['total_mv_sp'] = round(
|
|
282
|
-
(real_time_quotes_now_high_chg_all['total_mv'] / common_service_fun_api.HUNDRED_MILLION), 2)
|
|
283
|
-
|
|
284
|
-
save_realtime_quotes_now_zt_data(real_time_quotes_now_high_chg_all, str_day, symbol)
|
|
285
|
-
logger.info("同步涨停信息:{},{}", str_day, symbol)
|
|
286
|
-
except BaseException as e:
|
|
287
|
-
logger.error("发生异常:{}:{},{}", str_day, e, symbol)
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
def save_one_symbol_day(symbol, str_day):
|
|
291
|
-
mongo = get_mongodb_util(str_day)
|
|
292
|
-
realtime_quotes_db_name = 'realtime_quotes_now_' + str_day
|
|
293
|
-
high_chg_list = [symbol]
|
|
294
|
-
query_all = {"symbol": symbol}
|
|
295
|
-
real_time_quotes_now_high_chg_all = mongo.find_query_data(realtime_quotes_db_name, query_all)
|
|
296
|
-
if real_time_quotes_now_high_chg_all.shape[0] == 0:
|
|
297
|
-
return
|
|
298
|
-
real_time_quotes_now_high_chg_all = company_common_service_api.amendment_industry_exist_na(
|
|
299
|
-
real_time_quotes_now_high_chg_all,
|
|
300
|
-
high_chg_list)
|
|
301
|
-
real_time_quotes_now_high_chg_all = real_time_quotes_now_high_chg_all.dropna(inplace=False)
|
|
302
|
-
real_time_quotes_now_high_chg_all = data_init_api.calculate_parameter_factor(
|
|
303
|
-
real_time_quotes_now_high_chg_all)
|
|
304
|
-
|
|
305
|
-
real_time_quotes_now_high_chg_all.loc[:, 'amount_level'] = round(
|
|
306
|
-
(real_time_quotes_now_high_chg_all.loc[:, 'amount'] / common_service_fun_api.HUNDRED_MILLION), 2) * 10
|
|
307
|
-
real_time_quotes_now_high_chg_all.loc[:, 'flow_mv_sp'] = round(
|
|
308
|
-
(real_time_quotes_now_high_chg_all.loc[:, 'flow_mv'] / common_service_fun_api.HUNDRED_MILLION), 2)
|
|
309
|
-
real_time_quotes_now_high_chg_all.loc[:, 'total_mv_sp'] = round(
|
|
310
|
-
(real_time_quotes_now_high_chg_all['total_mv'] / common_service_fun_api.HUNDRED_MILLION), 2)
|
|
311
|
-
|
|
312
|
-
save_realtime_quotes_now_zt_data(real_time_quotes_now_high_chg_all, str_day, symbol)
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
def save_realtime_quotes_now_zt_data(realtime_quotes_now_zt, str_day, symbol):
|
|
316
|
-
realtime_quotes_now_zt = common_service_fun_api.classify_symbol(realtime_quotes_now_zt.copy())
|
|
317
|
-
# create_index()
|
|
318
|
-
if 'wei_bi' in realtime_quotes_now_zt.columns and bool(1 - ("wei_bi" in choose_field)):
|
|
319
|
-
choose_field.append("wei_bi")
|
|
320
|
-
if 'up_speed' in realtime_quotes_now_zt.columns and bool(1 - ("up_speed" in choose_field)):
|
|
321
|
-
choose_field.append("up_speed")
|
|
322
|
-
if 'list_date' in realtime_quotes_now_zt.columns and bool(1 - ("list_date" in choose_field)):
|
|
323
|
-
choose_field.append("list_date")
|
|
324
|
-
realtime_quotes_now_zt.loc[:, 'str_day'] = str_day
|
|
325
|
-
realtime_quotes_now_zt = realtime_quotes_now_zt[choose_field]
|
|
326
|
-
remove_query = {"symbol": symbol, "str_day": str_day}
|
|
327
|
-
result = mongodb_util.remove_data(remove_query, save_zt_name).acknowledged
|
|
328
|
-
if result:
|
|
329
|
-
mongodb_util.insert_mongo(realtime_quotes_now_zt, save_zt_name)
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
def sync_one_day_zt_info(str_day):
|
|
333
|
-
sync_his_high_one_day(str_day)
|
|
334
|
-
save_stock_high_chg_pool(str_day)
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
def sync_all_data():
|
|
338
|
-
create_index()
|
|
339
|
-
end_date = date_handle_util.add_date_day('20231029', 0)
|
|
340
|
-
|
|
341
|
-
sync_date = date_handle_util.add_date_day('20231030', 0)
|
|
342
|
-
|
|
343
|
-
str_now_day = sync_date.strftime('%Y-%m-%d')
|
|
344
|
-
while sync_date > end_date:
|
|
345
|
-
try:
|
|
346
|
-
sync_one_day_zt_info(str_now_day)
|
|
347
|
-
sync_date = date_handle_util.add_date_day(date_handle_util.no_slash_date(str_now_day), -1)
|
|
348
|
-
str_now_day = sync_date.strftime('%Y-%m-%d')
|
|
349
|
-
logger.info(str_now_day)
|
|
350
|
-
except BaseException as e:
|
|
351
|
-
logger.error("发生异常:{}:{}", str_now_day, e)
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
# fix miss symbol
|
|
355
|
-
def stock_qfq_daily_high_chg_pool(str_day):
|
|
356
|
-
high_chg_list = get_high_chg_symbol(str_day)
|
|
357
|
-
|
|
358
|
-
realtime_quotes_db_name = 'realtime_quotes_now_' + str_day
|
|
359
|
-
number = get_today_realtime_quotes_max_number(realtime_quotes_db_name, str_day)
|
|
360
|
-
|
|
361
|
-
query = {"number": number, "chg": {'$gte': 9.7}}
|
|
362
|
-
mongodb = get_mongodb_util(str_day)
|
|
363
|
-
real_time_quotes_now = mongodb.find_query_data(realtime_quotes_db_name, query)
|
|
364
|
-
if real_time_quotes_now.shape[0] == 0:
|
|
365
|
-
high_chg_list = high_chg_list
|
|
366
|
-
else:
|
|
367
|
-
real_time_quotes_now_symbol_list = real_time_quotes_now['symbol']
|
|
368
|
-
high_chg_list.extend(real_time_quotes_now_symbol_list)
|
|
369
|
-
high_chg_list = list(set(high_chg_list))
|
|
370
|
-
|
|
371
|
-
if high_chg_list is None:
|
|
372
|
-
return
|
|
373
|
-
|
|
374
|
-
query = {'symbol': {"$in": high_chg_list}, 'date': date_handle_util.no_slash_date(str_day)}
|
|
375
|
-
stock_qfq_daily_list = mongodb_util.find_query_data('stock_qfq_daily', query)
|
|
376
|
-
|
|
377
|
-
real_time_quotes_now_init = east_money_stock_api.get_real_time_quotes_all_stocks()
|
|
378
|
-
|
|
379
|
-
stock_qfq_daily_list = stock_qfq_daily_list.sort_values(by=['chg'], ascending=False)
|
|
380
|
-
|
|
381
|
-
zt_symbol_info = zt_common_service_api.get_last_trade_day_zt(str_day)
|
|
382
|
-
|
|
383
|
-
zt_symbol_connected_boards_numbers_list = zt_symbol_info.loc[
|
|
384
|
-
zt_symbol_info['symbol'].isin(stock_qfq_daily_list['symbol'])]
|
|
385
|
-
|
|
386
|
-
stock_qfq_daily_list['connected_boards_numbers'] = 1
|
|
387
|
-
if zt_symbol_connected_boards_numbers_list is not None and zt_symbol_connected_boards_numbers_list.shape[0] != 0:
|
|
388
|
-
for yesterday_zt in zt_symbol_connected_boards_numbers_list.itertuples():
|
|
389
|
-
stock_qfq_daily_list.loc[
|
|
390
|
-
stock_qfq_daily_list["symbol"] == yesterday_zt.symbol, ['connected_boards_numbers']] \
|
|
391
|
-
= 1 + yesterday_zt.connected_boards_numbers
|
|
392
|
-
|
|
393
|
-
for stock_one in stock_qfq_daily_list.itertuples():
|
|
394
|
-
try:
|
|
395
|
-
|
|
396
|
-
symbol = stock_one.symbol
|
|
397
|
-
|
|
398
|
-
classification = common_service_fun_api.classify_symbol_one(symbol)
|
|
399
|
-
|
|
400
|
-
real_time_quotes_now_one = real_time_quotes_now_init.loc[
|
|
401
|
-
real_time_quotes_now_init['symbol'] == symbol]
|
|
402
|
-
if data_frame_util.is_empty(real_time_quotes_now_one):
|
|
403
|
-
list_date = '19890729'
|
|
404
|
-
else:
|
|
405
|
-
list_date = list(real_time_quotes_now_one['list_date'])[0]
|
|
406
|
-
list_date = str(list_date)
|
|
407
|
-
list_date = list_date.replace(".0", "")
|
|
408
|
-
list_date = date_handle_util.lash_date(list_date)
|
|
409
|
-
|
|
410
|
-
list_date_time = date_handle_util.str_to_date(list_date, "%Y-%m-%d")
|
|
411
|
-
str_now_day_time = date_handle_util.str_to_date(str_day, "%Y-%m-%d")
|
|
412
|
-
|
|
413
|
-
list_to_now_days = date_handle_util.days_diff(str_now_day_time, list_date_time)
|
|
414
|
-
if list_to_now_days == 0:
|
|
415
|
-
# 排除当天上市新股
|
|
416
|
-
continue
|
|
417
|
-
|
|
418
|
-
last_trade_day = trade_date_common_service_api.get_last_trade_day(str_day)
|
|
419
|
-
|
|
420
|
-
last_day_high_chg = mongodb_util.exist_data_query('stock_hfq_daily',
|
|
421
|
-
query={"symbol": symbol, "date": last_trade_day,
|
|
422
|
-
"chg": {'$gte': 9}})
|
|
423
|
-
|
|
424
|
-
open = stock_one.open
|
|
425
|
-
high = stock_one.high
|
|
426
|
-
close = stock_one.close
|
|
427
|
-
yi_zhi_ban = False
|
|
428
|
-
if open == high and open == close:
|
|
429
|
-
yi_zhi_ban = True
|
|
430
|
-
|
|
431
|
-
stock_high_chg_pool = {
|
|
432
|
-
'_id': symbol + '_' + str_day,
|
|
433
|
-
'symbol': symbol,
|
|
434
|
-
'name': stock_one.name,
|
|
435
|
-
'industry': stock_one.industry,
|
|
436
|
-
'str_day': str_day,
|
|
437
|
-
'classification': classification,
|
|
438
|
-
'chg': stock_one.chg,
|
|
439
|
-
"connected_boards_numbers": stock_one.connected_boards_numbers,
|
|
440
|
-
"open": stock_one.open,
|
|
441
|
-
"close": stock_one.close,
|
|
442
|
-
"high": stock_one.high,
|
|
443
|
-
"low": stock_one.low,
|
|
444
|
-
"volume": stock_one.volume,
|
|
445
|
-
"amount": stock_one.amount,
|
|
446
|
-
# "flow_mv_level": stock_one.flow_mv_level,
|
|
447
|
-
"flow_mv_sp": stock_one.flow_mv_sp,
|
|
448
|
-
# "total_mv_sp": stock_one.total_mv_sp,
|
|
449
|
-
"list_to_now_days": list_to_now_days,
|
|
450
|
-
"list_date": list_date,
|
|
451
|
-
"exchange": stock_one.exchange,
|
|
452
|
-
"last_day_high_chg": last_day_high_chg,
|
|
453
|
-
"yi_zhi_ban": yi_zhi_ban,
|
|
454
|
-
"miss_out": True
|
|
455
|
-
}
|
|
456
|
-
query_exists = {"symbol": symbol, "str_day": str_day}
|
|
457
|
-
if mongodb_util.exist_data_query('stock_high_chg_pool', query_exists):
|
|
458
|
-
continue
|
|
459
|
-
else:
|
|
460
|
-
mongodb_util.save_mongo(pd.DataFrame([stock_high_chg_pool], index=[0]),
|
|
461
|
-
'stock_high_chg_pool')
|
|
462
|
-
logger.info("更新高涨幅数据成功{},{}", stock_one.symbol, str_day)
|
|
463
|
-
except Exception as e:
|
|
464
|
-
logger.error("更新高涨幅数据异常:{},{},{}", stock_one.symbol, str_day, e)
|
|
465
|
-
continue
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
if __name__ == '__main__':
|
|
469
|
-
sync_one_day_zt_info('2024-05-17')
|
|
470
|
-
|
|
471
|
-
# sync_date = date_handle_util.add_date_day('20221022', 0)
|
|
472
|
-
# now_date = datetime.now()
|
|
473
|
-
# str_now_day = sync_date.strftime('%Y-%m-%d')
|
|
474
|
-
# while now_date > sync_date:
|
|
475
|
-
# try:
|
|
476
|
-
# save_one_symbol_day('000948', str_now_day)
|
|
477
|
-
# sync_date = date_handle_util.add_date_day(date_handle_util.no_slash_date(str_now_day), 1)
|
|
478
|
-
# str_now_day = sync_date.strftime('%Y-%m-%d')
|
|
479
|
-
# print(str_now_day)
|
|
480
|
-
# except BaseException as e:
|
|
481
|
-
# logger.error("发生异常:{}:{}", str_now_day, e)
|
/mns_scheduler/zt/{zt_five_boards_sync_api.py → connected_boards/zt_five_boards_sync_api.py}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|