mns-scheduler 1.1.1.3__py3-none-any.whl → 1.1.1.5__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/company_info/constant/company_constant_data.py +1 -1
- mns_scheduler/concept/common/detaill/ths_concept_detail_api.py +3 -2
- mns_scheduler/concept/ths/common/ths_concept_sync_common_api.py +31 -22
- mns_scheduler/concept/ths/update_concept_info/sync_one_symbol_all_concepts_api.py +1 -1
- mns_scheduler/db/__init__.py +3 -0
- mns_scheduler/db/db_status.py +1 -1
- mns_scheduler/db/real_time_task_check.py +78 -0
- mns_scheduler/open/sync_one_day_open_data_to_db_service.py +5 -20
- mns_scheduler/zt/high_chg/sync_high_chg_pool_service.py +0 -1
- mns_scheduler/zt/high_chg/sync_high_chg_real_time_quotes_service.py +12 -8
- mns_scheduler/zt/open_data/kcx_high_chg_open_data_sync.py +10 -25
- mns_scheduler/zt/script/kcx_high_chg_open_his_data_handle.py +2 -3
- mns_scheduler/zt/script/sync_high_chg_pool_his_data.py +1 -1
- mns_scheduler/zz_task/data_sync_task.py +11 -1
- {mns_scheduler-1.1.1.3.dist-info → mns_scheduler-1.1.1.5.dist-info}/METADATA +1 -1
- {mns_scheduler-1.1.1.3.dist-info → mns_scheduler-1.1.1.5.dist-info}/RECORD +18 -21
- mns_scheduler/real_time/__init__.py +0 -7
- mns_scheduler/real_time/realtime_quotes_now_create_db_index.py +0 -29
- mns_scheduler/real_time/realtime_quotes_now_sync.py +0 -232
- mns_scheduler/zz_task/sync_realtime_quotes_task.py +0 -28
- {mns_scheduler-1.1.1.3.dist-info → mns_scheduler-1.1.1.5.dist-info}/WHEEL +0 -0
- {mns_scheduler-1.1.1.3.dist-info → mns_scheduler-1.1.1.5.dist-info}/top_level.txt +0 -0
|
@@ -14,7 +14,7 @@ mongodb_util = MongodbUtil('27017')
|
|
|
14
14
|
|
|
15
15
|
def get_fix_symbol_industry():
|
|
16
16
|
return pd.DataFrame([['688480', '赛恩斯', '760103', '环境治理'],
|
|
17
|
-
['000032', '深桑达A', '
|
|
17
|
+
['000032', '深桑达A', '730204', '通信网络设备及器件'],
|
|
18
18
|
['688480', '赛恩斯', '640704', '自动化设备'],
|
|
19
19
|
['603260', '合盛硅业', '220316', '有机硅'],
|
|
20
20
|
['300559', '佳发教育', '461102', '培训教育'],
|
|
@@ -189,8 +189,9 @@ def merge_data_common_fun(result_df, real_time_quotes_all_stocks):
|
|
|
189
189
|
|
|
190
190
|
|
|
191
191
|
if __name__ == '__main__':
|
|
192
|
-
|
|
192
|
+
|
|
193
193
|
real_time_quotes_all_stocks_df = east_money_stock_api.get_real_time_quotes_all_stocks()
|
|
194
|
-
get_ths_concept_detail_from_web('886072', real_time_quotes_all_stocks_df)
|
|
195
194
|
get_ths_concept_detail_by_explain('886078', real_time_quotes_all_stocks_df)
|
|
195
|
+
get_ths_concept_detail_from_web('886078', real_time_quotes_all_stocks_df)
|
|
196
|
+
get_ths_concept_detail('886073', '铜缆高速连接')
|
|
196
197
|
get_ths_concept_detail_by_wen_cai('PCB概念', real_time_quotes_all_stocks_df)
|
|
@@ -14,6 +14,10 @@ import mns_common.api.msg.push_msg_api as push_msg_api
|
|
|
14
14
|
import mns_scheduler.company_info.base.sync_company_base_info_api as company_info_sync_api
|
|
15
15
|
import mns_scheduler.company_info.clean.company_info_clean_api as company_info_clean_api
|
|
16
16
|
import mns_scheduler.concept.common.detaill.ths_concept_detail_api as ths_concept_detail_api
|
|
17
|
+
import mns_common.component.concept.ths_concept_common_service_api as ths_concept_common_service_api
|
|
18
|
+
import mns_common.component.company.company_common_service_new_api as company_common_service_new_api
|
|
19
|
+
import mns_common.utils.data_frame_util as data_frame_util
|
|
20
|
+
import mns_common.constant.db_name_constant as db_name_constant
|
|
17
21
|
|
|
18
22
|
max_concept_code = 886110
|
|
19
23
|
|
|
@@ -70,12 +74,13 @@ def save_ths_concept_detail(new_concept_symbol_df,
|
|
|
70
74
|
|
|
71
75
|
new_concept_symbol_df['concept_name'] = new_concept_symbol_df['concept_name'].replace(" ", "")
|
|
72
76
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
all_ths_concept_df = ths_concept_common_service_api.get_all_ths_concept()
|
|
78
|
+
ths_concept_one_df = all_ths_concept_df.loc[all_ths_concept_df['symbol'] == int(concept_code)]
|
|
79
|
+
|
|
80
|
+
if data_frame_util.is_empty(ths_concept_one_df):
|
|
76
81
|
concept_create_day = str_day
|
|
77
82
|
else:
|
|
78
|
-
concept_create_day = list(
|
|
83
|
+
concept_create_day = list(ths_concept_one_df['str_day'])[0]
|
|
79
84
|
|
|
80
85
|
new_concept_symbol_df['str_day'] = str_day
|
|
81
86
|
new_concept_symbol_df['str_now_time'] = str_now_time
|
|
@@ -84,19 +89,21 @@ def save_ths_concept_detail(new_concept_symbol_df,
|
|
|
84
89
|
new_concept_symbol_list = list(new_concept_symbol_df['symbol'])
|
|
85
90
|
|
|
86
91
|
query_company_info = {'symbol': {'$in': new_concept_symbol_list}}
|
|
92
|
+
query_company_info_key = str(query_company_info)
|
|
87
93
|
query_field = {"first_industry": 1, "first_industry": 1, "industry": 1,
|
|
88
94
|
"company_type": 1, "flow_mv_sp": 1,
|
|
89
95
|
"total_mv_sp": 1}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
query_field_key = str(query_field)
|
|
97
|
+
company_info = company_common_service_new_api.get_company_info_by_field(query_company_info_key, query_field_key)
|
|
98
|
+
|
|
99
|
+
if 'industry' in new_concept_symbol_df.columns:
|
|
100
|
+
del new_concept_symbol_df['industry']
|
|
101
|
+
if 'company_type' in new_concept_symbol_df.columns:
|
|
102
|
+
del new_concept_symbol_df['company_type']
|
|
103
|
+
if 'flow_mv_sp' in new_concept_symbol_df.columns:
|
|
104
|
+
del new_concept_symbol_df['flow_mv_sp']
|
|
105
|
+
if 'total_mv_sp' in new_concept_symbol_df.columns:
|
|
106
|
+
del new_concept_symbol_df['total_mv_sp']
|
|
100
107
|
|
|
101
108
|
company_info = company_info.set_index(['_id'], drop=True)
|
|
102
109
|
new_concept_symbol_df = new_concept_symbol_df.set_index(['symbol'], drop=False)
|
|
@@ -111,12 +118,13 @@ def save_ths_concept_detail(new_concept_symbol_df,
|
|
|
111
118
|
new_concept_symbol_df['change'] = 0
|
|
112
119
|
|
|
113
120
|
new_concept_symbol_df['concept_name'] = new_concept_symbol_df['concept_name'].replace(" ", "")
|
|
114
|
-
query = {'concept_code': concept_code}
|
|
115
121
|
|
|
116
122
|
if bool(1 - ('way' in new_concept_symbol_df.columns)):
|
|
117
123
|
new_concept_symbol_df['way'] = 'symbol_sync'
|
|
118
124
|
if "long" not in new_concept_symbol_df.columns:
|
|
119
125
|
new_concept_symbol_df['long'] = ''
|
|
126
|
+
if "short" not in new_concept_symbol_df.columns:
|
|
127
|
+
new_concept_symbol_df['short'] = new_concept_symbol_df['long']
|
|
120
128
|
new_concept_symbol_df = new_concept_symbol_df[[
|
|
121
129
|
"_id",
|
|
122
130
|
"index",
|
|
@@ -137,24 +145,25 @@ def save_ths_concept_detail(new_concept_symbol_df,
|
|
|
137
145
|
"company_type",
|
|
138
146
|
"concept_create_day",
|
|
139
147
|
"way",
|
|
140
|
-
"long"
|
|
148
|
+
"long",
|
|
149
|
+
'short'
|
|
141
150
|
]]
|
|
142
|
-
|
|
143
|
-
exist_concept_detail = mongodb_util.find_query_data(
|
|
151
|
+
query_detail = {"concept_code": int(concept_code)}
|
|
152
|
+
exist_concept_detail = mongodb_util.find_query_data(db_name_constant.THS_STOCK_CONCEPT_DETAIL, query_detail)
|
|
144
153
|
if exist_concept_detail is None or exist_concept_detail.shape[0] == 0:
|
|
145
|
-
mongodb_util.save_mongo(new_concept_symbol_df,
|
|
154
|
+
mongodb_util.save_mongo(new_concept_symbol_df, db_name_constant.THS_STOCK_CONCEPT_DETAIL)
|
|
146
155
|
# 保存到当日新增概念列表
|
|
147
156
|
new_concept_symbol_df['concept_type'] = 'ths'
|
|
148
|
-
mongodb_util.save_mongo(new_concept_symbol_df,
|
|
157
|
+
mongodb_util.save_mongo(new_concept_symbol_df, db_name_constant.TODAY_NEW_CONCEPT_LIST)
|
|
149
158
|
else:
|
|
150
159
|
exist_concept_detail_symbol_list = list(exist_concept_detail['symbol'])
|
|
151
160
|
new_concept_symbol_df = new_concept_symbol_df.loc[~(
|
|
152
161
|
new_concept_symbol_df['symbol'].isin(exist_concept_detail_symbol_list))]
|
|
153
162
|
if new_concept_symbol_df.shape[0] > 0:
|
|
154
|
-
mongodb_util.save_mongo(new_concept_symbol_df,
|
|
163
|
+
mongodb_util.save_mongo(new_concept_symbol_df, db_name_constant.THS_STOCK_CONCEPT_DETAIL)
|
|
155
164
|
# 保存到当日新增概念列表
|
|
156
165
|
new_concept_symbol_df['concept_type'] = 'ths'
|
|
157
|
-
mongodb_util.save_mongo(new_concept_symbol_df,
|
|
166
|
+
mongodb_util.save_mongo(new_concept_symbol_df, db_name_constant.TODAY_NEW_CONCEPT_LIST)
|
|
158
167
|
update_company_info(new_concept_symbol_df)
|
|
159
168
|
# 公司缓存信息清除
|
|
160
169
|
company_common_service_api.company_info_industry_cache_clear()
|
mns_scheduler/db/__init__.py
CHANGED
mns_scheduler/db/db_status.py
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
file_path = os.path.abspath(__file__)
|
|
5
|
+
end = file_path.index('mns') + 16
|
|
6
|
+
project_path = file_path[0:end]
|
|
7
|
+
sys.path.append(project_path)
|
|
8
|
+
import mns_common.constant.db_name_constant as db_name_constant
|
|
9
|
+
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
10
|
+
import mns_common.component.cache.cache_service as cache_service
|
|
11
|
+
import mns_common.utils.cmd_util as cmd_util
|
|
12
|
+
import mns_common.utils.data_frame_util as data_frame_util
|
|
13
|
+
from loguru import logger
|
|
14
|
+
from datetime import datetime
|
|
15
|
+
import mns_common.utils.date_handle_util as date_handle_util
|
|
16
|
+
|
|
17
|
+
MAX_NUMBER_KEY = 'max_number_key'
|
|
18
|
+
# 实时行情同步任务 python名称
|
|
19
|
+
REAL_TIME_SCHEDULER_NAME = "sync_realtime_quotes_task"
|
|
20
|
+
# 实时行情补偿任务 python名称
|
|
21
|
+
REAL_TIME_TASK_NAME = "realtime_quotes_now_sync"
|
|
22
|
+
|
|
23
|
+
REAL_TIME_SCHEDULER_NAME_PATH = 'H:\\real_time_task.bat'
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def get_real_time_max_number():
|
|
27
|
+
number = common_service_fun_api.realtime_quotes_now_max_number(db_name_constant.REAL_TIME_QUOTES_NOW,
|
|
28
|
+
'number')
|
|
29
|
+
|
|
30
|
+
return number
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# 检查数据同步最大值
|
|
34
|
+
def check_max_number():
|
|
35
|
+
now_max_number = get_real_time_max_number()
|
|
36
|
+
last_minute_number = cache_service.get_cache(MAX_NUMBER_KEY)
|
|
37
|
+
cache_service.set_cache(MAX_NUMBER_KEY, now_max_number)
|
|
38
|
+
if last_minute_number is None:
|
|
39
|
+
return True
|
|
40
|
+
elif now_max_number == last_minute_number:
|
|
41
|
+
return False
|
|
42
|
+
else:
|
|
43
|
+
return True
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# 实时行情数据同步状态check
|
|
47
|
+
def run_check_real_time_data_sync_status():
|
|
48
|
+
now_date = datetime.now()
|
|
49
|
+
if date_handle_util.is_close_time(now_date):
|
|
50
|
+
return False
|
|
51
|
+
flag = check_max_number()
|
|
52
|
+
if bool(1 - flag):
|
|
53
|
+
all_cmd_processes = cmd_util.get_cmd_processes()
|
|
54
|
+
if data_frame_util.is_empty(all_cmd_processes):
|
|
55
|
+
return None
|
|
56
|
+
all_cmd_processes_real_time_task = get_real_time_quotes_task(all_cmd_processes)
|
|
57
|
+
if data_frame_util.is_empty(all_cmd_processes_real_time_task):
|
|
58
|
+
return None
|
|
59
|
+
for match_task_one in all_cmd_processes_real_time_task.itertuples():
|
|
60
|
+
try:
|
|
61
|
+
processes_pid = match_task_one.process_pid
|
|
62
|
+
# 关闭当前进程
|
|
63
|
+
cmd_util.kill_process_by_pid(processes_pid)
|
|
64
|
+
except BaseException as e:
|
|
65
|
+
logger.error("关闭实时行情任务异常:{}", e)
|
|
66
|
+
# 重开任务进程
|
|
67
|
+
cmd_util.open_bat_file(REAL_TIME_SCHEDULER_NAME_PATH)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def get_real_time_quotes_task(all_cmd_processes):
|
|
71
|
+
return all_cmd_processes[
|
|
72
|
+
(all_cmd_processes['total_info'].str.contains(REAL_TIME_SCHEDULER_NAME, case=False, na=False))
|
|
73
|
+
| (all_cmd_processes['total_info'].str.contains(REAL_TIME_TASK_NAME, case=False, na=False))]
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
if __name__ == '__main__':
|
|
77
|
+
while True:
|
|
78
|
+
run_check_real_time_data_sync_status()
|
|
@@ -11,7 +11,7 @@ from loguru import logger
|
|
|
11
11
|
from datetime import time
|
|
12
12
|
from mns_common.db.MongodbUtil import MongodbUtil
|
|
13
13
|
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
14
|
-
import mns_common.component.company.
|
|
14
|
+
import mns_common.component.company.company_common_service_new_api as company_common_service_new_api
|
|
15
15
|
import mns_common.component.data.data_init_api as data_init_api
|
|
16
16
|
import pandas as pd
|
|
17
17
|
import mns_common.utils.db_util as db_util
|
|
@@ -51,12 +51,13 @@ def sync_one_day_open_data(str_day):
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
def handle_init_real_time_quotes_data(real_time_quotes_now, str_now_date, number):
|
|
54
|
+
# fix industry
|
|
55
|
+
real_time_quotes_now = company_common_service_new_api.amend_ths_industry(real_time_quotes_now.copy())
|
|
54
56
|
# exclude b symbol
|
|
55
57
|
real_time_quotes_now = common_service_fun_api.exclude_b_symbol(real_time_quotes_now.copy())
|
|
56
58
|
# classification symbol
|
|
57
59
|
real_time_quotes_now = common_service_fun_api.classify_symbol(real_time_quotes_now.copy())
|
|
58
|
-
|
|
59
|
-
real_time_quotes_now = fix_industry_data(real_time_quotes_now.copy())
|
|
60
|
+
|
|
60
61
|
# calculate parameter
|
|
61
62
|
real_time_quotes_now = data_init_api.calculate_parameter_factor(real_time_quotes_now.copy())
|
|
62
63
|
|
|
@@ -66,21 +67,5 @@ def handle_init_real_time_quotes_data(real_time_quotes_now, str_now_date, number
|
|
|
66
67
|
return real_time_quotes_now
|
|
67
68
|
|
|
68
69
|
|
|
69
|
-
# fix 错杀数据 有成交量的数据
|
|
70
|
-
def fix_industry_data(real_time_quotes_now):
|
|
71
|
-
# fix industry
|
|
72
|
-
real_time_quotes_now_r = company_common_service_api.amendment_industry(real_time_quotes_now.copy())
|
|
73
|
-
|
|
74
|
-
symbol_list = list(real_time_quotes_now_r['symbol'])
|
|
75
|
-
|
|
76
|
-
na_real_now = real_time_quotes_now.loc[
|
|
77
|
-
~(real_time_quotes_now['symbol'].isin(symbol_list))]
|
|
78
|
-
|
|
79
|
-
na_real_now = na_real_now.loc[na_real_now['amount'] != 0]
|
|
80
|
-
|
|
81
|
-
real_time_quotes_now_result = pd.concat([real_time_quotes_now_r, na_real_now], axis=0)
|
|
82
|
-
return real_time_quotes_now_result
|
|
83
|
-
|
|
84
|
-
|
|
85
70
|
if __name__ == '__main__':
|
|
86
|
-
sync_one_day_open_data('2024-06-
|
|
71
|
+
sync_one_day_open_data('2024-06-21')
|
|
@@ -9,7 +9,7 @@ sys.path.append(project_path)
|
|
|
9
9
|
from loguru import logger
|
|
10
10
|
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
11
11
|
import mns_common.utils.date_handle_util as date_handle_util
|
|
12
|
-
import mns_common.component.company.
|
|
12
|
+
import mns_common.component.company.company_common_service_new_api as company_common_service_new_api
|
|
13
13
|
import mns_common.component.data.data_init_api as data_init_api
|
|
14
14
|
from mns_common.db.MongodbUtil import MongodbUtil
|
|
15
15
|
import mns_common.utils.db_util as db_util
|
|
@@ -24,14 +24,15 @@ choose_field = ["_id",
|
|
|
24
24
|
"symbol",
|
|
25
25
|
"name",
|
|
26
26
|
"industry",
|
|
27
|
-
"now_price",
|
|
28
27
|
"chg",
|
|
29
28
|
"quantity_ratio",
|
|
30
29
|
"amount_level",
|
|
30
|
+
'sum_main_inflow_disk',
|
|
31
31
|
"disk_ratio",
|
|
32
|
+
"now_price",
|
|
32
33
|
"real_disk_diff_amount_exchange",
|
|
33
34
|
'max_real_main_inflow_multiple',
|
|
34
|
-
|
|
35
|
+
|
|
35
36
|
"real_main_inflow_multiple",
|
|
36
37
|
"real_super_main_inflow_multiple",
|
|
37
38
|
"super_main_inflow_multiple",
|
|
@@ -73,7 +74,7 @@ choose_field = ["_id",
|
|
|
73
74
|
def sync_high_chg_real_time_quotes(str_day):
|
|
74
75
|
mongo = db_util.get_db(str_day)
|
|
75
76
|
|
|
76
|
-
realtime_quotes_db_name =
|
|
77
|
+
realtime_quotes_db_name = db_name_constant.REAL_TIME_QUOTES_NOW + "_" + str_day
|
|
77
78
|
high_chg_list = get_high_chg_symbol(str_day)
|
|
78
79
|
if high_chg_list is None or len(high_chg_list) == 0:
|
|
79
80
|
return
|
|
@@ -84,16 +85,15 @@ def sync_high_chg_real_time_quotes(str_day):
|
|
|
84
85
|
real_time_quotes_now_high_chg_all = mongo.find_query_data(realtime_quotes_db_name, query_all)
|
|
85
86
|
if real_time_quotes_now_high_chg_all.shape[0] == 0:
|
|
86
87
|
return
|
|
87
|
-
real_time_quotes_now_high_chg_all =
|
|
88
|
-
real_time_quotes_now_high_chg_all
|
|
89
|
-
high_chg_list)
|
|
88
|
+
real_time_quotes_now_high_chg_all = company_common_service_new_api.amend_ths_industry(
|
|
89
|
+
real_time_quotes_now_high_chg_all)
|
|
90
90
|
real_time_quotes_now_high_chg_all.dropna(subset=['symbol'], axis=0,
|
|
91
91
|
inplace=True)
|
|
92
92
|
real_time_quotes_now_high_chg_all = data_init_api.calculate_parameter_factor(
|
|
93
93
|
real_time_quotes_now_high_chg_all)
|
|
94
94
|
|
|
95
95
|
real_time_quotes_now_high_chg_all['amount_level'] = round(
|
|
96
|
-
(real_time_quotes_now_high_chg_all['amount'] / common_service_fun_api.HUNDRED_MILLION), 2)
|
|
96
|
+
(real_time_quotes_now_high_chg_all['amount'] / common_service_fun_api.HUNDRED_MILLION), 2)
|
|
97
97
|
real_time_quotes_now_high_chg_all['flow_mv_sp'] = round(
|
|
98
98
|
(real_time_quotes_now_high_chg_all['flow_mv'] / common_service_fun_api.HUNDRED_MILLION), 2)
|
|
99
99
|
real_time_quotes_now_high_chg_all['total_mv_sp'] = round(
|
|
@@ -139,3 +139,7 @@ def save_realtime_quotes_now_zt_data(realtime_quotes_now_zt, str_day, symbol):
|
|
|
139
139
|
result = mongodb_util.remove_data(remove_query, db_name_constant.ZT_STOCK_REAL_TIME_QUOTES).acknowledged
|
|
140
140
|
if result:
|
|
141
141
|
mongodb_util.insert_mongo(realtime_quotes_now_zt, db_name_constant.ZT_STOCK_REAL_TIME_QUOTES)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
if __name__ == '__main__':
|
|
145
|
+
sync_high_chg_real_time_quotes('2024-06-24')
|
|
@@ -10,7 +10,7 @@ import mns_common.utils.date_handle_util as date_handle_util
|
|
|
10
10
|
from loguru import logger
|
|
11
11
|
|
|
12
12
|
import mns_common.component.trade_date.trade_date_common_service_api as trade_date_common_service_api
|
|
13
|
-
import mns_common.component.company.
|
|
13
|
+
import mns_common.component.company.company_common_service_new_api as company_common_service_new_api
|
|
14
14
|
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
15
15
|
import mns_common.component.data.data_init_api as data_init_api
|
|
16
16
|
import pandas as pd
|
|
@@ -62,22 +62,6 @@ realtime_quotes_now_zt_new_kc_open_field = ['_id',
|
|
|
62
62
|
'real_disk_diff_amount_exchange', 'no_open_data']
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
# fix 错杀数据 有成交量的数据
|
|
66
|
-
def fix_industry_data(real_time_quotes_now):
|
|
67
|
-
# fix industry
|
|
68
|
-
real_time_quotes_now_r = company_common_service_api.amendment_industry(real_time_quotes_now.copy())
|
|
69
|
-
|
|
70
|
-
symbol_list = list(real_time_quotes_now_r['symbol'])
|
|
71
|
-
|
|
72
|
-
na_real_now = real_time_quotes_now.loc[
|
|
73
|
-
~(real_time_quotes_now['symbol'].isin(symbol_list))]
|
|
74
|
-
|
|
75
|
-
na_real_now = na_real_now.loc[na_real_now['amount'] != 0]
|
|
76
|
-
|
|
77
|
-
real_time_quotes_now_result = pd.concat([real_time_quotes_now_r, na_real_now], axis=0)
|
|
78
|
-
return real_time_quotes_now_result
|
|
79
|
-
|
|
80
|
-
|
|
81
65
|
def sync_all_kc_zt_data(str_day, symbols):
|
|
82
66
|
if symbols is None:
|
|
83
67
|
query_daily = {'date': date_handle_util.no_slash_date(str_day),
|
|
@@ -92,11 +76,9 @@ def sync_all_kc_zt_data(str_day, symbols):
|
|
|
92
76
|
logger.error("无k线数据:{}", symbols)
|
|
93
77
|
return
|
|
94
78
|
|
|
95
|
-
|
|
96
|
-
company_info['symbol'] = company_info['_id']
|
|
97
|
-
company_info = company_info.loc[company_info['_id'].isin(list(kc_stock_qfq_daily['symbol']))]
|
|
79
|
+
kc_stock_qfq_daily = company_common_service_new_api.amend_ths_industry(kc_stock_qfq_daily)
|
|
98
80
|
|
|
99
|
-
for stock_one in
|
|
81
|
+
for stock_one in kc_stock_qfq_daily.itertuples():
|
|
100
82
|
try:
|
|
101
83
|
|
|
102
84
|
kc_stock_qfq_daily.loc[
|
|
@@ -150,7 +132,9 @@ def sync_all_kc_zt_data(str_day, symbols):
|
|
|
150
132
|
query_real_time = {'symbol': kc_one.symbol}
|
|
151
133
|
db = db_util.get_db(str_day)
|
|
152
134
|
realtime_quotes_now_kc = db.find_query_data(db_name, query_real_time)
|
|
153
|
-
|
|
135
|
+
stock_name = kc_one.name
|
|
136
|
+
if stock_name.startswith('N'):
|
|
137
|
+
continue
|
|
154
138
|
if realtime_quotes_now_kc.shape[0] == 0:
|
|
155
139
|
logger.error("当期日期代码无开盘数据:{},{}", str_day, kc_one.symbol)
|
|
156
140
|
continue
|
|
@@ -182,11 +166,14 @@ def one_symbol_day_open_data(realtime_quotes_now_kc, kc_one, str_day):
|
|
|
182
166
|
realtime_quotes_now_zt_new_kc_open_copy.loc[:, 'yesterday_high_chg'] = kc_one.yesterday_high_chg
|
|
183
167
|
realtime_quotes_now_zt_new_kc_open_copy.loc[:, 'today_chg'] = kc_one.chg
|
|
184
168
|
realtime_quotes_now_zt_new_kc_open_copy.loc[:, 'str_day'] = str_day
|
|
185
|
-
|
|
169
|
+
realtime_quotes_now_zt_new_kc_open_copy = company_common_service_new_api.amend_ths_industry(
|
|
170
|
+
realtime_quotes_now_zt_new_kc_open_copy)
|
|
186
171
|
realtime_quotes_now_zt_new_kc_open_copy = handle_init_real_time_quotes_data(
|
|
187
172
|
realtime_quotes_now_zt_new_kc_open_copy.copy(),
|
|
188
173
|
str_now_date,
|
|
189
174
|
1)
|
|
175
|
+
if data_frame_util.is_empty(realtime_quotes_now_zt_new_kc_open_copy):
|
|
176
|
+
return None
|
|
190
177
|
realtime_quotes_now_zt_new_kc_open_copy = realtime_quotes_now_zt_new_kc_open_copy[
|
|
191
178
|
realtime_quotes_now_zt_new_kc_open_field]
|
|
192
179
|
|
|
@@ -219,8 +206,6 @@ def handle_init_real_time_quotes_data(real_time_quotes_now, str_now_date, number
|
|
|
219
206
|
real_time_quotes_now = common_service_fun_api.exclude_b_symbol(real_time_quotes_now.copy())
|
|
220
207
|
# classification symbol
|
|
221
208
|
real_time_quotes_now = common_service_fun_api.classify_symbol(real_time_quotes_now.copy())
|
|
222
|
-
# fix industry
|
|
223
|
-
real_time_quotes_now = fix_industry_data(real_time_quotes_now.copy())
|
|
224
209
|
# calculate parameter
|
|
225
210
|
real_time_quotes_now = data_init_api.calculate_parameter_factor(real_time_quotes_now.copy())
|
|
226
211
|
|
|
@@ -8,11 +8,9 @@ sys.path.append(project_path)
|
|
|
8
8
|
import mns_scheduler.zt.open_data.kcx_high_chg_open_data_sync as kcx_high_chg_open_data_sync
|
|
9
9
|
from loguru import logger
|
|
10
10
|
|
|
11
|
-
|
|
12
11
|
from mns_common.db.MongodbUtil import MongodbUtil
|
|
13
12
|
import mns_common.utils.data_frame_util as data_frame_util
|
|
14
13
|
|
|
15
|
-
|
|
16
14
|
mongodb_util = MongodbUtil('27017')
|
|
17
15
|
mongodb_util_21019 = MongodbUtil('27019')
|
|
18
16
|
realtime_quotes_now_zt_new_kc_open_field = ['_id',
|
|
@@ -53,6 +51,7 @@ realtime_quotes_now_zt_new_kc_open_field = ['_id',
|
|
|
53
51
|
'real_super_main_inflow_multiple', 'real_flow_mv',
|
|
54
52
|
'real_disk_diff_amount_exchange', 'no_open_data']
|
|
55
53
|
|
|
54
|
+
|
|
56
55
|
# query = {'$and': [{"_id": {'$lte': str_end}}, {"_id": {'$gte': '2022-04-25'}}]}
|
|
57
56
|
def sync_all_high_chg_data(str_end):
|
|
58
57
|
query = {'$and': [{"_id": {'$lte': str_end}}, {"_id": {'$gte': '2024-03-01'}}]}
|
|
@@ -84,7 +83,7 @@ def fix_miss_data(str_end):
|
|
|
84
83
|
|
|
85
84
|
|
|
86
85
|
if __name__ == '__main__':
|
|
87
|
-
kcx_high_chg_open_data_sync.sync_all_kc_zt_data('2024-06-
|
|
86
|
+
kcx_high_chg_open_data_sync.sync_all_kc_zt_data('2024-06-24', None)
|
|
88
87
|
# sync_all_kc_zt_data('2023-08-16')
|
|
89
88
|
# sync_all_kc_zt_data('2023-07-07')
|
|
90
89
|
# realtime_quotes_now_zt_new_kc_open_sync()
|
|
@@ -48,6 +48,7 @@ import mns_scheduler.risk.transactions.transactions_check_api as transactions_ch
|
|
|
48
48
|
import mns_scheduler.concept.ths.sync_new_index.sync_ths_concept_new_index_api as sync_ths_concept_new_index_api
|
|
49
49
|
import mns_scheduler.company_info.clean.company_info_clean_api as company_info_clean_api
|
|
50
50
|
import mns_scheduler.zt.zt_pool.ths_zt_pool_sync_api as ths_zt_pool_sync_api
|
|
51
|
+
import mns_scheduler.db.real_time_task_check as real_time_task_check_api
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
# 同步交易日期任务完成
|
|
@@ -152,7 +153,8 @@ def sync_stock_zt_pool():
|
|
|
152
153
|
em_stock_zt_pool = em_zt_pool_sync_api.save_zt_info(str_day)
|
|
153
154
|
zt_five_boards_sync_api.update_five_connected_boards_task(em_stock_zt_pool)
|
|
154
155
|
logger.info('同步ths股票涨停池')
|
|
155
|
-
ths_zt_pool_sync_api.ths_zt_pool(str_day, None)
|
|
156
|
+
ths_zt_pool_df = ths_zt_pool_sync_api.ths_zt_pool(str_day, None)
|
|
157
|
+
ths_zt_pool_sync_api.save_ths_zt_pool(ths_zt_pool_df, str_day)
|
|
156
158
|
logger.info('同步当天涨停池股票完成')
|
|
157
159
|
|
|
158
160
|
|
|
@@ -341,6 +343,11 @@ def sync_all_interactive_questions():
|
|
|
341
343
|
stock_irm_cninfo_service.sync_all_interactive_questions(None)
|
|
342
344
|
|
|
343
345
|
|
|
346
|
+
# 数据同步状态check
|
|
347
|
+
def real_time_task_check_status():
|
|
348
|
+
real_time_task_check_api.run_check_real_time_data_sync_status()
|
|
349
|
+
|
|
350
|
+
|
|
344
351
|
# # 定义BlockingScheduler
|
|
345
352
|
blockingScheduler = BlockingScheduler()
|
|
346
353
|
# sync_trade_date 同步交易日期
|
|
@@ -419,6 +426,9 @@ blockingScheduler.add_job(sync_high_risk_stocks, 'cron', hour='0,09,12,16', minu
|
|
|
419
426
|
# 同步互动回答
|
|
420
427
|
blockingScheduler.add_job(sync_all_interactive_questions, 'cron', hour='08,12,17', minute='05')
|
|
421
428
|
|
|
429
|
+
# 实时数据状态同步check
|
|
430
|
+
blockingScheduler.add_job(real_time_task_check_status, 'interval', seconds=59, max_instances=4)
|
|
431
|
+
|
|
422
432
|
print('定时任务启动成功')
|
|
423
433
|
blockingScheduler.start()
|
|
424
434
|
#
|
|
@@ -15,7 +15,7 @@ mns_scheduler/company_info/base/sync_company_base_info_api.py,sha256=zI6CaQ7LuXe
|
|
|
15
15
|
mns_scheduler/company_info/clean/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
16
16
|
mns_scheduler/company_info/clean/company_info_clean_api.py,sha256=zMPbIz91l8DpIGc7ljG6dEdD5QXjir2a0wWHGt2Ca78,4805
|
|
17
17
|
mns_scheduler/company_info/constant/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
18
|
-
mns_scheduler/company_info/constant/company_constant_data.py,sha256=
|
|
18
|
+
mns_scheduler/company_info/constant/company_constant_data.py,sha256=9ZnI4_yPp9ylyX9_yzLX7SgcpTbJM46pdDtfbAoWXqQ,15886
|
|
19
19
|
mns_scheduler/company_info/de_list_stock/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
20
20
|
mns_scheduler/company_info/de_list_stock/de_list_stock_service.py,sha256=GCp6hlvO-SuH1oIpEsYZwEnGUOa6fXb2D7CqAUYXKQA,1993
|
|
21
21
|
mns_scheduler/concept/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
@@ -24,19 +24,20 @@ mns_scheduler/concept/clean/kpl_concept_clean_api.py,sha256=xxIIgrXLI6xLf10t4unJ
|
|
|
24
24
|
mns_scheduler/concept/clean/ths_concept_clean_api.py,sha256=42sbd8VqJeOKxJuxLVsU9YFK_YUSePTGrK2AWbabhA0,5964
|
|
25
25
|
mns_scheduler/concept/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
26
|
mns_scheduler/concept/common/detaill/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
-
mns_scheduler/concept/common/detaill/ths_concept_detail_api.py,sha256=
|
|
27
|
+
mns_scheduler/concept/common/detaill/ths_concept_detail_api.py,sha256=0w0NJIzXZ_G2rN6_jlyxsFHoZiyAPkqGtK7pr8IEI3A,9380
|
|
28
28
|
mns_scheduler/concept/ths/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
29
29
|
mns_scheduler/concept/ths/common/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
30
|
-
mns_scheduler/concept/ths/common/ths_concept_sync_common_api.py,sha256=
|
|
30
|
+
mns_scheduler/concept/ths/common/ths_concept_sync_common_api.py,sha256=CDo5d2dA36a99bS4vxg2ZRdSc-l_NwPSzmkxjAWLyFY,8146
|
|
31
31
|
mns_scheduler/concept/ths/common/ths_concept_update_common_api.py,sha256=4BQT3A9t-nDIyCpILgRZF7ZOgK1oabp-gJl5nyWvKWc,4418
|
|
32
32
|
mns_scheduler/concept/ths/sync_new_index/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
33
33
|
mns_scheduler/concept/ths/sync_new_index/sync_ths_concept_new_index_api.py,sha256=9ol2cvxSO2Ot4Z5fmlo9tUPFe6WwsuVX_H9ogtv3QrI,7841
|
|
34
34
|
mns_scheduler/concept/ths/update_concept_info/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
35
35
|
mns_scheduler/concept/ths/update_concept_info/sync_one_concept_all_symbols_api.py,sha256=wlsr70rcS-uAH6b8NXPbA-wG37saeIQ0FIg8vSSTXQA,1920
|
|
36
|
-
mns_scheduler/concept/ths/update_concept_info/sync_one_symbol_all_concepts_api.py,sha256=
|
|
37
|
-
mns_scheduler/db/__init__.py,sha256=
|
|
36
|
+
mns_scheduler/concept/ths/update_concept_info/sync_one_symbol_all_concepts_api.py,sha256=qeynu1zRzjWtHMOKZ8oJYrVs2aK_SafPo53vQbViSXE,8843
|
|
37
|
+
mns_scheduler/db/__init__.py,sha256=1dpcEuWKyblKcpyOss0Iyy_ZS4ZJsh8x8GoMAv3TiS8,193
|
|
38
38
|
mns_scheduler/db/col_move_service.py,sha256=VSGJROyErfytjGzSlhyTdH6z3ayHG5nFfJk8qjdpJhE,4057
|
|
39
|
-
mns_scheduler/db/db_status.py,sha256=
|
|
39
|
+
mns_scheduler/db/db_status.py,sha256=e5eW5ZSm5J7tHvmxxhFmFdbZb2_oB_SAcdcFqc4KDmw,733
|
|
40
|
+
mns_scheduler/db/real_time_task_check.py,sha256=XkoPLJt13bEP3ymf3EiYCogx9p1dZklUNH3LNVE-8Pg,2941
|
|
40
41
|
mns_scheduler/dt/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
41
42
|
mns_scheduler/dt/stock_dt_pool_sync.py,sha256=5ivRUOnFtOapZniwTbujf1lVq3y4btm2Cmd5R6JJAVo,3466
|
|
42
43
|
mns_scheduler/finance/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
@@ -80,10 +81,7 @@ mns_scheduler/kpl/selection/total/sync_kpl_best_total_sync_api.py,sha256=WRK-Pu0
|
|
|
80
81
|
mns_scheduler/lhb/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
81
82
|
mns_scheduler/lhb/stock_lhb_sync_service.py,sha256=NIW0jX23N1dCEdsrKwt7MyzXSfhU7vXNpIO04dUSZwc,641
|
|
82
83
|
mns_scheduler/open/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
83
|
-
mns_scheduler/open/sync_one_day_open_data_to_db_service.py,sha256=
|
|
84
|
-
mns_scheduler/real_time/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
85
|
-
mns_scheduler/real_time/realtime_quotes_now_create_db_index.py,sha256=ytGtRVGc6Alf9F2m4EUvjcSq8LlGYg8acVQdJO_lMoI,1076
|
|
86
|
-
mns_scheduler/real_time/realtime_quotes_now_sync.py,sha256=tXZUU9SLwM80YQv473i-uVw1w_lClTMFaO-uo4jERTI,9669
|
|
84
|
+
mns_scheduler/open/sync_one_day_open_data_to_db_service.py,sha256=wlwJtCeMoTrrqlTukq4A6RUrvj5RBNasa7kDpSt6QJc,2659
|
|
87
85
|
mns_scheduler/risk/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
88
86
|
mns_scheduler/risk/financial_report_risk_check_api.py,sha256=BPkMZ7aINfOFPswIV115kFUhyt0j7dLyA755QEDl-So,1648
|
|
89
87
|
mns_scheduler/risk/compliance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -113,20 +111,19 @@ mns_scheduler/zt/connected_boards/zt_five_boards_sync_api.py,sha256=HfjPHKD99fU9
|
|
|
113
111
|
mns_scheduler/zt/export/__init__.py,sha256=Tyvi_iQlv3jz59EdH67Mycnt9CSixcWPQoJwu55bOq0,165
|
|
114
112
|
mns_scheduler/zt/export/export_kcx_high_chg_open_data_to_excel.py,sha256=9LK1s2BCzsXLMAYMmiMAZsmz8iha88JVcp6SKqIW37s,4063
|
|
115
113
|
mns_scheduler/zt/high_chg/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
116
|
-
mns_scheduler/zt/high_chg/sync_high_chg_pool_service.py,sha256=
|
|
117
|
-
mns_scheduler/zt/high_chg/sync_high_chg_real_time_quotes_service.py,sha256=
|
|
114
|
+
mns_scheduler/zt/high_chg/sync_high_chg_pool_service.py,sha256=7hRfzQFhMSwdbzIg57JmX82DEW3Ig5hwZTzS_SPO0sg,13347
|
|
115
|
+
mns_scheduler/zt/high_chg/sync_high_chg_real_time_quotes_service.py,sha256=L69lsirRXaiddZ7GKSWbEABQcwMOeCOm33dlVKK3-oQ,6351
|
|
118
116
|
mns_scheduler/zt/open_data/__init__.py,sha256=Tyvi_iQlv3jz59EdH67Mycnt9CSixcWPQoJwu55bOq0,165
|
|
119
|
-
mns_scheduler/zt/open_data/kcx_high_chg_open_data_sync.py,sha256=
|
|
117
|
+
mns_scheduler/zt/open_data/kcx_high_chg_open_data_sync.py,sha256=wZiqOre2UK9CxIR7dDk11DmqRY3n2_eE2pe0JfmMcjk,11616
|
|
120
118
|
mns_scheduler/zt/script/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
121
|
-
mns_scheduler/zt/script/kcx_high_chg_open_his_data_handle.py,sha256=
|
|
122
|
-
mns_scheduler/zt/script/sync_high_chg_pool_his_data.py,sha256=
|
|
119
|
+
mns_scheduler/zt/script/kcx_high_chg_open_his_data_handle.py,sha256=mtILXQin6CrnqXbep6YV87OTLFHFEb3ta6mxrh3mcgE,5571
|
|
120
|
+
mns_scheduler/zt/script/sync_high_chg_pool_his_data.py,sha256=R4MmBqmYspaHsnyqJc0FkdmD4lCGCMfHZQMs2dsipIw,1685
|
|
123
121
|
mns_scheduler/zt/zt_pool/__init__.py,sha256=Tyvi_iQlv3jz59EdH67Mycnt9CSixcWPQoJwu55bOq0,165
|
|
124
122
|
mns_scheduler/zt/zt_pool/em_zt_pool_sync_api.py,sha256=YV0-9m6Rpy_KNDch6Esj83F4kt1fTqF-Y0wMZBPSEGg,7642
|
|
125
123
|
mns_scheduler/zt/zt_pool/ths_zt_pool_sync_api.py,sha256=Xx_R_WujCtV_p4k1eKaYPshQVpErtegub2OyIOBxzUw,10338
|
|
126
124
|
mns_scheduler/zz_task/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
127
|
-
mns_scheduler/zz_task/data_sync_task.py,sha256=
|
|
128
|
-
mns_scheduler/
|
|
129
|
-
mns_scheduler-1.1.1.
|
|
130
|
-
mns_scheduler-1.1.1.
|
|
131
|
-
mns_scheduler-1.1.1.
|
|
132
|
-
mns_scheduler-1.1.1.3.dist-info/RECORD,,
|
|
125
|
+
mns_scheduler/zz_task/data_sync_task.py,sha256=bILPyMR0LEtCxdjEonplUOnGCYHhI65pFrzQWdf8WqI,18050
|
|
126
|
+
mns_scheduler-1.1.1.5.dist-info/METADATA,sha256=Wa2F_UKwv1z80UXKs8NMibLKE1Tf9s2GUHFR04a6p88,64
|
|
127
|
+
mns_scheduler-1.1.1.5.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
128
|
+
mns_scheduler-1.1.1.5.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
|
|
129
|
+
mns_scheduler-1.1.1.5.dist-info/RECORD,,
|
|
@@ -1,29 +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
|
-
from loguru import logger
|
|
9
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
10
|
-
|
|
11
|
-
mongodb_util = MongodbUtil('27017')
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def create_db_index(str_day):
|
|
15
|
-
query_trade_day = {'_id': str_day}
|
|
16
|
-
is_trade_day = mongodb_util.exist_data_query('trade_date_list', query_trade_day)
|
|
17
|
-
if is_trade_day:
|
|
18
|
-
try:
|
|
19
|
-
mongodb_util.create_index('realtime_quotes_now_' + str_day, [("symbol", 1)])
|
|
20
|
-
mongodb_util.create_index('realtime_quotes_now_' + str_day, [("number", 1)])
|
|
21
|
-
mongodb_util.create_index('realtime_quotes_now_' + str_day, [("symbol", 1), ("number", 1)])
|
|
22
|
-
mongodb_util.create_index('realtime_quotes_now_' + str_day, [("str_now_date", 1)])
|
|
23
|
-
logger.info("创建索引成功:{}", str_day)
|
|
24
|
-
except BaseException as e:
|
|
25
|
-
logger.warning("创建索引异常:{}", e)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if __name__ == '__main__':
|
|
29
|
-
create_db_index("2023-08-11")
|
|
@@ -1,232 +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 datetime
|
|
10
|
-
import mns_common.utils.date_handle_util as date_util
|
|
11
|
-
import mns_common.component.company.company_common_service_api as company_common_service_api
|
|
12
|
-
from loguru import logger
|
|
13
|
-
import mns_common.api.em.east_money_stock_api as east_money_stock_api
|
|
14
|
-
import time
|
|
15
|
-
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
16
|
-
import mns_common.component.data.data_init_api as data_init_api
|
|
17
|
-
import mns_scheduler.real_time.realtime_quotes_now_create_db_index as realtime_quotes_now_create_db_index_api
|
|
18
|
-
import pandas as pd
|
|
19
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
20
|
-
from mns_common.utils.async_fun import async_fun
|
|
21
|
-
import mns_scheduler.trade.auto_sell_service_api as auto_sell_service_api
|
|
22
|
-
import mns_common.constant.db_name_constant as db_name_constant
|
|
23
|
-
import warnings
|
|
24
|
-
|
|
25
|
-
warnings.filterwarnings("ignore")
|
|
26
|
-
|
|
27
|
-
mongodb_util = MongodbUtil('27017')
|
|
28
|
-
order = ["_id",
|
|
29
|
-
"symbol",
|
|
30
|
-
"name",
|
|
31
|
-
"industry",
|
|
32
|
-
"chg",
|
|
33
|
-
"quantity_ratio",
|
|
34
|
-
"amount_level",
|
|
35
|
-
"real_exchange",
|
|
36
|
-
"disk_ratio",
|
|
37
|
-
'real_disk_diff_amount_exchange',
|
|
38
|
-
'max_real_main_inflow_multiple',
|
|
39
|
-
'sum_main_inflow_disk',
|
|
40
|
-
"main_inflow_multiple",
|
|
41
|
-
'super_main_inflow_multiple',
|
|
42
|
-
'disk_diff_amount',
|
|
43
|
-
"disk_diff_amount_exchange",
|
|
44
|
-
"exchange",
|
|
45
|
-
"amount",
|
|
46
|
-
"today_main_net_inflow",
|
|
47
|
-
"today_main_net_inflow_ratio",
|
|
48
|
-
"super_large_order_net_inflow",
|
|
49
|
-
"super_large_order_net_inflow_ratio",
|
|
50
|
-
"large_order_net_inflow",
|
|
51
|
-
"large_order_net_inflow_ratio",
|
|
52
|
-
"super_main_inflow_multiple",
|
|
53
|
-
"up_speed",
|
|
54
|
-
"up_speed_05",
|
|
55
|
-
"now_price",
|
|
56
|
-
"high",
|
|
57
|
-
"low",
|
|
58
|
-
"open",
|
|
59
|
-
"yesterday_price",
|
|
60
|
-
"volume",
|
|
61
|
-
"total_mv",
|
|
62
|
-
"flow_mv",
|
|
63
|
-
"list_date",
|
|
64
|
-
"wei_bi",
|
|
65
|
-
"buy_1_num",
|
|
66
|
-
"sell_1_num",
|
|
67
|
-
"outer_disk",
|
|
68
|
-
"inner_disk",
|
|
69
|
-
"average_price",
|
|
70
|
-
"classification",
|
|
71
|
-
"str_now_date",
|
|
72
|
-
"number"]
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
# 实时表移除数据
|
|
76
|
-
@async_fun
|
|
77
|
-
def remove_real_time_data(number, realtime_quotes_db_name):
|
|
78
|
-
if number % 50 == 0:
|
|
79
|
-
remove_query = {'number': {"$lte": number - 50}}
|
|
80
|
-
mongodb_util.remove_data(remove_query, realtime_quotes_db_name)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def remove_real_time_all_data():
|
|
84
|
-
remove_query = {}
|
|
85
|
-
mongodb_util.remove_data(remove_query, db_name_constant.REAL_TIME_QUOTES_NOW)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
# 保存实时表数据
|
|
89
|
-
def save_real_time_quotes(real_time_quotes, now_date, realtime_quotes_db_name, number):
|
|
90
|
-
if 'first_sw_industry' in real_time_quotes.columns:
|
|
91
|
-
real_time_quotes.drop(columns=['first_sw_industry'], inplace=True)
|
|
92
|
-
if 'second_sw_industry' in real_time_quotes.columns:
|
|
93
|
-
real_time_quotes.drop(columns=['second_sw_industry'], inplace=True)
|
|
94
|
-
if 'third_sw_industry' in real_time_quotes.columns:
|
|
95
|
-
real_time_quotes.drop(columns=['third_sw_industry'], inplace=True)
|
|
96
|
-
real_time_quotes.symbol = real_time_quotes.symbol.astype(str)
|
|
97
|
-
str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S:%f')
|
|
98
|
-
real_time_quotes['_id'] = real_time_quotes['symbol'] + '-' + str_now_date
|
|
99
|
-
|
|
100
|
-
try:
|
|
101
|
-
|
|
102
|
-
real_time_quotes = real_time_quotes[order]
|
|
103
|
-
real_time_quotes['sum_main_inflow_disk'] = round(real_time_quotes['sum_main_inflow_disk'], 2)
|
|
104
|
-
mongodb_util.insert_mongo(real_time_quotes, realtime_quotes_db_name)
|
|
105
|
-
# 移除现在的数据
|
|
106
|
-
remove_real_time_data(number, realtime_quotes_db_name)
|
|
107
|
-
except BaseException as e:
|
|
108
|
-
logger.error('保存实时数据异常:{}', e)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
# 保存历史表数据
|
|
112
|
-
def save_real_time_quotes_his(real_time_quotes, now_date, realtime_quotes_db_name, number_his):
|
|
113
|
-
if 'first_sw_industry' in real_time_quotes.columns:
|
|
114
|
-
real_time_quotes.drop(columns=['first_sw_industry'], inplace=True)
|
|
115
|
-
if 'second_sw_industry' in real_time_quotes.columns:
|
|
116
|
-
real_time_quotes.drop(columns=['second_sw_industry'], inplace=True)
|
|
117
|
-
if 'third_sw_industry' in real_time_quotes.columns:
|
|
118
|
-
real_time_quotes.drop(columns=['third_sw_industry'], inplace=True)
|
|
119
|
-
real_time_quotes.symbol = real_time_quotes.symbol.astype(str)
|
|
120
|
-
str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S:%f')
|
|
121
|
-
real_time_quotes['_id'] = real_time_quotes['symbol'] + '-' + str_now_date
|
|
122
|
-
|
|
123
|
-
try:
|
|
124
|
-
real_time_quotes['number'] = number_his
|
|
125
|
-
|
|
126
|
-
real_time_quotes = real_time_quotes[order]
|
|
127
|
-
mongodb_util.insert_mongo(real_time_quotes, realtime_quotes_db_name)
|
|
128
|
-
except Exception as e:
|
|
129
|
-
logger.error('保存实时历史数据异常:{}', e)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
def handle_init_real_time_quotes_data(real_time_quotes_now, str_now_date, number):
|
|
133
|
-
# exclude b symbol
|
|
134
|
-
real_time_quotes_now = common_service_fun_api.exclude_b_symbol(real_time_quotes_now.copy())
|
|
135
|
-
# classification symbol
|
|
136
|
-
real_time_quotes_now = common_service_fun_api.classify_symbol(real_time_quotes_now.copy())
|
|
137
|
-
# fix industry
|
|
138
|
-
real_time_quotes_now = fix_industry_data(real_time_quotes_now.copy())
|
|
139
|
-
# calculate parameter
|
|
140
|
-
real_time_quotes_now = data_init_api.calculate_parameter_factor(real_time_quotes_now.copy())
|
|
141
|
-
|
|
142
|
-
real_time_quotes_now = real_time_quotes_now.loc[real_time_quotes_now['amount'] != 0]
|
|
143
|
-
real_time_quotes_now['str_now_date'] = str_now_date
|
|
144
|
-
real_time_quotes_now['number'] = number
|
|
145
|
-
return real_time_quotes_now
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
# fix 错杀数据 有成交量的数据
|
|
149
|
-
def fix_industry_data(real_time_quotes_now):
|
|
150
|
-
# fix industry
|
|
151
|
-
real_time_quotes_now_r = company_common_service_api.amendment_industry(real_time_quotes_now.copy())
|
|
152
|
-
|
|
153
|
-
symbol_list = list(real_time_quotes_now_r['symbol'])
|
|
154
|
-
|
|
155
|
-
na_real_now = real_time_quotes_now.loc[
|
|
156
|
-
~(real_time_quotes_now['symbol'].isin(symbol_list))]
|
|
157
|
-
|
|
158
|
-
na_real_now = na_real_now.loc[na_real_now['amount'] != 0]
|
|
159
|
-
|
|
160
|
-
real_time_quotes_now_result = pd.concat([real_time_quotes_now_r, na_real_now], axis=0)
|
|
161
|
-
return real_time_quotes_now_result
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
def sync_realtime_quotes():
|
|
165
|
-
# 移除昨日数据
|
|
166
|
-
remove_real_time_all_data()
|
|
167
|
-
|
|
168
|
-
now_date_init = datetime.datetime.now()
|
|
169
|
-
str_day_init = now_date_init.strftime('%Y-%m-%d')
|
|
170
|
-
realtime_quotes_db_name = db_name_constant.REAL_TIME_QUOTES_NOW + "_" + str_day_init
|
|
171
|
-
number_his = common_service_fun_api.realtime_quotes_now_max_number(realtime_quotes_db_name, 'number')
|
|
172
|
-
number_his = number_his + 1
|
|
173
|
-
number = common_service_fun_api.realtime_quotes_now_max_number(
|
|
174
|
-
db_name_constant.REAL_TIME_QUOTES_NOW + '_' + str_day_init, 'number')
|
|
175
|
-
number = number + 1
|
|
176
|
-
realtime_quotes_now_create_db_index_api.create_db_index(str_day_init)
|
|
177
|
-
while True:
|
|
178
|
-
now_date = datetime.datetime.now()
|
|
179
|
-
|
|
180
|
-
str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
181
|
-
if bool(date_util.is_trade_time(now_date)):
|
|
182
|
-
try:
|
|
183
|
-
real_time_quotes_now = east_money_stock_api.get_real_time_quotes_all_stocks()
|
|
184
|
-
real_time_quotes_now = handle_init_real_time_quotes_data(real_time_quotes_now.copy(),
|
|
185
|
-
str_now_date, number)
|
|
186
|
-
save_real_time_quotes(real_time_quotes_now.copy(), now_date, db_name_constant.REAL_TIME_QUOTES_NOW,
|
|
187
|
-
number)
|
|
188
|
-
try:
|
|
189
|
-
auto_sell_service_api.auto_sell_stock(real_time_quotes_now.copy())
|
|
190
|
-
except Exception as e:
|
|
191
|
-
logger.error("自动卖出执行异常:{}", e)
|
|
192
|
-
# 集合竞价前同步
|
|
193
|
-
if date_util.is_call_auction(str_now_date):
|
|
194
|
-
if number % 4 == 0:
|
|
195
|
-
save_real_time_quotes_his(real_time_quotes_now.copy(), now_date, realtime_quotes_db_name,
|
|
196
|
-
number_his)
|
|
197
|
-
number_his = number_his + 1
|
|
198
|
-
# 开盘前一个小时同步
|
|
199
|
-
elif date_util.is_begin_one_hour(now_date):
|
|
200
|
-
save_real_time_quotes_his(real_time_quotes_now.copy(), now_date, realtime_quotes_db_name,
|
|
201
|
-
number_his)
|
|
202
|
-
number_his = number_his + 1
|
|
203
|
-
# 下午同步次数
|
|
204
|
-
elif date_util.is_afternoon_time(now_date):
|
|
205
|
-
if number % 3 == 0:
|
|
206
|
-
save_real_time_quotes_his(real_time_quotes_now.copy(), now_date, realtime_quotes_db_name,
|
|
207
|
-
number_his)
|
|
208
|
-
number_his = number_his + 1
|
|
209
|
-
|
|
210
|
-
else:
|
|
211
|
-
# 10:30 到11:30
|
|
212
|
-
if number % 2 == 0:
|
|
213
|
-
save_real_time_quotes_his(real_time_quotes_now.copy(), now_date, realtime_quotes_db_name,
|
|
214
|
-
number_his)
|
|
215
|
-
number_his = number_his + 1
|
|
216
|
-
|
|
217
|
-
logger.info("同步实时行情信息:{}", number)
|
|
218
|
-
number = number + 1
|
|
219
|
-
|
|
220
|
-
except Exception as e:
|
|
221
|
-
number_his = number_his + 1
|
|
222
|
-
number = number + 1
|
|
223
|
-
logger.error("获取实时行情信息:{}", e)
|
|
224
|
-
elif bool(date_util.is_no_trade_time(now_date)):
|
|
225
|
-
|
|
226
|
-
break
|
|
227
|
-
else:
|
|
228
|
-
time.sleep(1)
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if __name__ == '__main__':
|
|
232
|
-
sync_realtime_quotes()
|
|
@@ -1,28 +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
|
-
import mns_scheduler.real_time.realtime_quotes_now_sync as realtime_quotes_now_sync
|
|
9
|
-
import mns_scheduler.company_info.clean.company_info_clean_api as company_info_clean_api
|
|
10
|
-
from loguru import logger
|
|
11
|
-
from apscheduler.schedulers.blocking import BlockingScheduler
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def sync_realtime_quotes():
|
|
15
|
-
logger.error("同步实时数据开始")
|
|
16
|
-
# 更新新股公司信息
|
|
17
|
-
company_info_clean_api.new_company_info_update()
|
|
18
|
-
realtime_quotes_now_sync.sync_realtime_quotes()
|
|
19
|
-
logger.error("同步实时数据完成")
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
blockingScheduler = BlockingScheduler()
|
|
23
|
-
|
|
24
|
-
# 同步实时数据
|
|
25
|
-
blockingScheduler.add_job(sync_realtime_quotes, 'cron', hour='09', minute='20', max_instances=4)
|
|
26
|
-
|
|
27
|
-
print('同步实时行情定时任务启动成功')
|
|
28
|
-
blockingScheduler.start()
|
|
File without changes
|
|
File without changes
|