mns-scheduler 1.1.3.6__py3-none-any.whl → 1.1.3.9__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/common/redis/redis_msg_push_service.py +18 -0
- mns_scheduler/company_info/clean/company_info_clean_api.py +1 -1
- mns_scheduler/concept/clean/ths_concept_clean_api.py +56 -50
- mns_scheduler/concept/ths/common/ths_concept_sync_common_api.py +23 -29
- mns_scheduler/concept/{common → ths}/detaill/ths_concept_detail_api.py +33 -7
- mns_scheduler/concept/ths/sync_new_index/sync_ths_concept_new_index_api.py +18 -26
- mns_scheduler/concept/ths/update_concept_info/sync_one_concept_all_symbols_api.py +9 -21
- mns_scheduler/concept/ths/update_concept_info/sync_one_symbol_all_concepts_api.py +11 -8
- mns_scheduler/risk/self/wei_pan_stock_api.py +1 -1
- mns_scheduler/zz_task/data_sync_task.py +1 -1
- {mns_scheduler-1.1.3.6.dist-info → mns_scheduler-1.1.3.9.dist-info}/METADATA +1 -1
- {mns_scheduler-1.1.3.6.dist-info → mns_scheduler-1.1.3.9.dist-info}/RECORD +17 -27
- mns_scheduler/backup/data/collection_move.py +0 -53
- mns_scheduler/backup/data/sync_data_to_local.py +0 -55
- mns_scheduler/backup/data/sync_remote_by_str_day.py +0 -33
- mns_scheduler/backup/em/__init__.py +0 -7
- mns_scheduler/backup/em/em_new_concept_his_sync.py +0 -99
- mns_scheduler/backup/em/em_new_concept_sync_common_api.py +0 -139
- mns_scheduler/backup/em/em_new_concept_sync_web.py +0 -55
- mns_scheduler/backup/ths/sync_ths_concept_by_ak_api.py +0 -103
- mns_scheduler/backup/ths/sync_ths_new_concept_by_web_api.py +0 -88
- mns_scheduler/concept/common/__init__.py +0 -0
- mns_scheduler/concept/common/detaill/__init__.py +0 -0
- /mns_scheduler/{backup → common}/__init__.py +0 -0
- /mns_scheduler/{backup/data → common/redis}/__init__.py +0 -0
- /mns_scheduler/{backup/ths → concept/ths/detaill}/__init__.py +0 -0
- {mns_scheduler-1.1.3.6.dist-info → mns_scheduler-1.1.3.9.dist-info}/WHEEL +0 -0
- {mns_scheduler-1.1.3.6.dist-info → mns_scheduler-1.1.3.9.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
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 redis
|
|
9
|
+
import mns_common.constant.redis_msg_constant as redis_msg_constant
|
|
10
|
+
|
|
11
|
+
# 连接到Redis服务器
|
|
12
|
+
r = redis.Redis(host='localhost', port=6379, db=0)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# 发送消息
|
|
16
|
+
def send_redis_msg(message):
|
|
17
|
+
# 将消息推送到队列中
|
|
18
|
+
r.publish(redis_msg_constant.THS_NEW_CONCEPT_ADD, message)
|
|
@@ -11,7 +11,7 @@ from datetime import datetime
|
|
|
11
11
|
from loguru import logger
|
|
12
12
|
import mns_scheduler.company_info.constant.company_constant_data as company_constant_data
|
|
13
13
|
import mns_common.constant.db_name_constant as db_name_constant
|
|
14
|
-
import mns_scheduler.concept.
|
|
14
|
+
import mns_scheduler.concept.ths.detaill.ths_concept_detail_api as ths_concept_detail_api
|
|
15
15
|
import mns_scheduler.company_info.base.sync_company_base_info_api as company_info_sync_api
|
|
16
16
|
|
|
17
17
|
mongodb_util = MongodbUtil('27017')
|
|
@@ -7,11 +7,12 @@ project_path = file_path[0:end]
|
|
|
7
7
|
sys.path.append(project_path)
|
|
8
8
|
from mns_common.db.MongodbUtil import MongodbUtil
|
|
9
9
|
import pandas as pd
|
|
10
|
-
import mns_scheduler.concept.
|
|
10
|
+
import mns_scheduler.concept.ths.detaill.ths_concept_detail_api as ths_concept_detail_api
|
|
11
11
|
import time
|
|
12
12
|
from loguru import logger
|
|
13
13
|
import mns_common.component.company.company_common_service_api as company_common_service_api
|
|
14
14
|
import mns_common.constant.db_name_constant as db_name_constant
|
|
15
|
+
import mns_common.component.concept.ths_concept_common_service_api as ths_concept_common_service_api
|
|
15
16
|
|
|
16
17
|
mongodb_util = MongodbUtil('27017')
|
|
17
18
|
|
|
@@ -21,59 +22,64 @@ def update_ths_concept_info():
|
|
|
21
22
|
ths_concept_list = mongodb_util.find_all_data(db_name_constant.THS_CONCEPT_LIST)
|
|
22
23
|
for ths_concept_one in ths_concept_list.itertuples():
|
|
23
24
|
try:
|
|
24
|
-
|
|
25
|
-
ths_stock_concept_detail_df = (mongodb_util
|
|
26
|
-
.find_query_data(db_name_constant.THS_STOCK_CONCEPT_DETAIL, query))
|
|
27
|
-
concept_count = ths_stock_concept_detail_df.shape[0]
|
|
28
|
-
ths_concept_list_one_df = ths_concept_list.loc[ths_concept_list['symbol'] == ths_concept_one.symbol]
|
|
29
|
-
ths_concept_list_one_df['concept_count'] = concept_count
|
|
30
|
-
|
|
31
|
-
ths_stock_concept_detail_df = ths_stock_concept_detail_df.reset_index(drop=True)
|
|
32
|
-
if 'industry' in ths_stock_concept_detail_df.columns:
|
|
33
|
-
del ths_stock_concept_detail_df['industry']
|
|
34
|
-
|
|
35
|
-
company_info_df = company_common_service_api.get_company_info_industry()
|
|
36
|
-
company_info_df = company_info_df[['_id', 'industry']]
|
|
37
|
-
company_info_df = company_info_df.loc[
|
|
38
|
-
company_info_df['_id'].isin(list(ths_stock_concept_detail_df['symbol']))]
|
|
39
|
-
company_info_df = company_info_df.set_index(['_id'], drop=True)
|
|
40
|
-
|
|
41
|
-
ths_stock_concept_detail_df = ths_stock_concept_detail_df.set_index(['symbol'], drop=False)
|
|
42
|
-
ths_stock_concept_detail_df = pd.merge(ths_stock_concept_detail_df, company_info_df,
|
|
43
|
-
how='outer',
|
|
44
|
-
left_index=True, right_index=True)
|
|
45
|
-
ths_stock_concept_detail_df.dropna(subset=['industry'], axis=0, inplace=True)
|
|
46
|
-
|
|
47
|
-
grouped = ths_stock_concept_detail_df.groupby('industry')
|
|
48
|
-
result_list = grouped.size()
|
|
49
|
-
ths_concept_group = pd.DataFrame(result_list, columns=['number'])
|
|
50
|
-
ths_concept_group['industry'] = ths_concept_group.index
|
|
51
|
-
ths_concept_group = ths_concept_group.sort_values(by=['number'], ascending=False)
|
|
52
|
-
if ths_concept_group.shape[0] >= 2:
|
|
53
|
-
first_relevance_industry = list(ths_concept_group.iloc[0:1]['industry'])[0]
|
|
54
|
-
first_relevance_industry_number = list(ths_concept_group.iloc[0:1]['number'])[0]
|
|
55
|
-
second_relevance_industry = list(ths_concept_group.iloc[1:2]['industry'])[0]
|
|
56
|
-
second_relevance_industry_number = list(ths_concept_group.iloc[1:2]['number'])[0]
|
|
57
|
-
else:
|
|
58
|
-
first_relevance_industry = list(ths_concept_group.iloc[0:1]['industry'])[0]
|
|
59
|
-
first_relevance_industry_number = list(ths_concept_group.iloc[0:1]['number'])[0]
|
|
60
|
-
second_relevance_industry = '无'
|
|
61
|
-
second_relevance_industry_number = 0
|
|
62
|
-
ths_concept_list_one_df['first_relevance_industry'] = first_relevance_industry
|
|
63
|
-
ths_concept_list_one_df['second_relevance_industry'] = second_relevance_industry
|
|
64
|
-
ths_concept_list_one_df['first_relevance_industry_number'] = first_relevance_industry_number
|
|
65
|
-
ths_concept_list_one_df['second_relevance_industry_number'] = second_relevance_industry_number
|
|
66
|
-
|
|
67
|
-
ths_stock_concept_detail_df['first_relevance_industry'] = first_relevance_industry
|
|
68
|
-
ths_stock_concept_detail_df['second_relevance_industry'] = second_relevance_industry
|
|
69
|
-
|
|
70
|
-
mongodb_util.save_mongo(ths_concept_list_one_df, db_name_constant.THS_CONCEPT_LIST)
|
|
71
|
-
mongodb_util.save_mongo(ths_stock_concept_detail_df, db_name_constant.THS_STOCK_CONCEPT_DETAIL)
|
|
72
|
-
|
|
25
|
+
update_one_concept_relevance_industry(ths_concept_one.symbol)
|
|
73
26
|
except BaseException as e:
|
|
74
27
|
logger.error("更新概念信息异常:{},{}", e, ths_concept_one.name)
|
|
75
28
|
|
|
76
29
|
|
|
30
|
+
# 更新一个概念行业相关
|
|
31
|
+
def update_one_concept_relevance_industry(concept_code):
|
|
32
|
+
query = {'concept_code': concept_code}
|
|
33
|
+
ths_stock_concept_detail_df = (mongodb_util
|
|
34
|
+
.find_query_data(db_name_constant.THS_STOCK_CONCEPT_DETAIL, query))
|
|
35
|
+
concept_count = ths_stock_concept_detail_df.shape[0]
|
|
36
|
+
ths_concept_list = ths_concept_common_service_api.get_all_ths_concept()
|
|
37
|
+
ths_concept_list_one_df = ths_concept_list.loc[ths_concept_list['symbol'] == concept_code]
|
|
38
|
+
ths_concept_list_one_df['concept_count'] = concept_count
|
|
39
|
+
|
|
40
|
+
ths_stock_concept_detail_df = ths_stock_concept_detail_df.reset_index(drop=True)
|
|
41
|
+
if 'industry' in ths_stock_concept_detail_df.columns:
|
|
42
|
+
del ths_stock_concept_detail_df['industry']
|
|
43
|
+
|
|
44
|
+
company_info_df = company_common_service_api.get_company_info_industry()
|
|
45
|
+
company_info_df = company_info_df[['_id', 'industry']]
|
|
46
|
+
company_info_df = company_info_df.loc[
|
|
47
|
+
company_info_df['_id'].isin(list(ths_stock_concept_detail_df['symbol']))]
|
|
48
|
+
company_info_df = company_info_df.set_index(['_id'], drop=True)
|
|
49
|
+
|
|
50
|
+
ths_stock_concept_detail_df = ths_stock_concept_detail_df.set_index(['symbol'], drop=False)
|
|
51
|
+
ths_stock_concept_detail_df = pd.merge(ths_stock_concept_detail_df, company_info_df,
|
|
52
|
+
how='outer',
|
|
53
|
+
left_index=True, right_index=True)
|
|
54
|
+
ths_stock_concept_detail_df.dropna(subset=['industry'], axis=0, inplace=True)
|
|
55
|
+
|
|
56
|
+
grouped = ths_stock_concept_detail_df.groupby('industry')
|
|
57
|
+
result_list = grouped.size()
|
|
58
|
+
ths_concept_group = pd.DataFrame(result_list, columns=['number'])
|
|
59
|
+
ths_concept_group['industry'] = ths_concept_group.index
|
|
60
|
+
ths_concept_group = ths_concept_group.sort_values(by=['number'], ascending=False)
|
|
61
|
+
if ths_concept_group.shape[0] >= 2:
|
|
62
|
+
first_relevance_industry = list(ths_concept_group.iloc[0:1]['industry'])[0]
|
|
63
|
+
first_relevance_industry_number = list(ths_concept_group.iloc[0:1]['number'])[0]
|
|
64
|
+
second_relevance_industry = list(ths_concept_group.iloc[1:2]['industry'])[0]
|
|
65
|
+
second_relevance_industry_number = list(ths_concept_group.iloc[1:2]['number'])[0]
|
|
66
|
+
else:
|
|
67
|
+
first_relevance_industry = list(ths_concept_group.iloc[0:1]['industry'])[0]
|
|
68
|
+
first_relevance_industry_number = list(ths_concept_group.iloc[0:1]['number'])[0]
|
|
69
|
+
second_relevance_industry = '无'
|
|
70
|
+
second_relevance_industry_number = 0
|
|
71
|
+
ths_concept_list_one_df['first_relevance_industry'] = first_relevance_industry
|
|
72
|
+
ths_concept_list_one_df['second_relevance_industry'] = second_relevance_industry
|
|
73
|
+
ths_concept_list_one_df['first_relevance_industry_number'] = first_relevance_industry_number
|
|
74
|
+
ths_concept_list_one_df['second_relevance_industry_number'] = second_relevance_industry_number
|
|
75
|
+
|
|
76
|
+
ths_stock_concept_detail_df['first_relevance_industry'] = first_relevance_industry
|
|
77
|
+
ths_stock_concept_detail_df['second_relevance_industry'] = second_relevance_industry
|
|
78
|
+
|
|
79
|
+
mongodb_util.save_mongo(ths_concept_list_one_df, db_name_constant.THS_CONCEPT_LIST)
|
|
80
|
+
mongodb_util.save_mongo(ths_stock_concept_detail_df, db_name_constant.THS_STOCK_CONCEPT_DETAIL)
|
|
81
|
+
|
|
82
|
+
|
|
77
83
|
# 更新空名字
|
|
78
84
|
def update_null_name():
|
|
79
85
|
query = {"_id": {'$gte': 886025}}
|
|
@@ -13,32 +13,26 @@ mongodb_util = MongodbUtil('27017')
|
|
|
13
13
|
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
|
-
import mns_scheduler.concept.
|
|
16
|
+
import mns_scheduler.concept.ths.detaill.ths_concept_detail_api as ths_concept_detail_api
|
|
17
17
|
import mns_common.component.concept.ths_concept_common_service_api as ths_concept_common_service_api
|
|
18
18
|
import mns_common.component.company.company_common_service_new_api as company_common_service_new_api
|
|
19
19
|
import mns_common.utils.data_frame_util as data_frame_util
|
|
20
20
|
import mns_common.constant.db_name_constant as db_name_constant
|
|
21
|
+
import mns_scheduler.common.redis.redis_msg_push_service as redis_msg_push_service
|
|
22
|
+
import mns_scheduler.concept.clean.ths_concept_clean_api as ths_concept_clean_api
|
|
21
23
|
|
|
22
|
-
max_concept_code = 886110
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"symbol",
|
|
27
|
-
"name",
|
|
28
|
-
"now_price",
|
|
29
|
-
"chg",
|
|
30
|
-
"change",
|
|
31
|
-
"exchange",
|
|
32
|
-
"amount",
|
|
33
|
-
"concept_code",
|
|
34
|
-
]
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
# 推送到手机
|
|
38
|
-
def push_msg_to_we_chat_web(concept_code, concept_name, url):
|
|
25
|
+
# 推送消息
|
|
26
|
+
def push_msg_to_we_chat_and_redis(concept_code, concept_name, url):
|
|
39
27
|
msg = "概念代码:" + str(concept_code) + "," + "概念名称:" + concept_name + "," + "url: " + url
|
|
40
28
|
title = "新增同花顺概念:" + str(concept_code) + "-" + concept_name
|
|
29
|
+
# 推送到微信
|
|
41
30
|
push_msg_api.push_msg_to_wechat(title, msg)
|
|
31
|
+
# 项目之前推送消息
|
|
32
|
+
redis_msg_push_service.send_redis_msg("新增同花顺概念")
|
|
33
|
+
|
|
34
|
+
# 更新ths概念信息
|
|
35
|
+
ths_concept_clean_api.update_ths_concept_info()
|
|
42
36
|
|
|
43
37
|
|
|
44
38
|
# 保存新概念信息到数据库
|
|
@@ -50,18 +44,6 @@ def save_ths_concept_list(concept_code, concept_name, str_day, str_now_time):
|
|
|
50
44
|
mongodb_util.save_mongo(ths_concept_list, 'ths_concept_list')
|
|
51
45
|
|
|
52
46
|
|
|
53
|
-
# 获取最大概念代码
|
|
54
|
-
def get_max_concept_code():
|
|
55
|
-
query = {"symbol": {'$ne': 'null'}, "success": True}
|
|
56
|
-
ths_concept_max = mongodb_util.descend_query(query, 'ths_concept_list', 'symbol', 1)
|
|
57
|
-
if ths_concept_max.shape[0] == 0:
|
|
58
|
-
concept_code = 885284
|
|
59
|
-
else:
|
|
60
|
-
concept_code = list(ths_concept_max['symbol'])[0]
|
|
61
|
-
|
|
62
|
-
return concept_code
|
|
63
|
-
|
|
64
|
-
|
|
65
47
|
# 保存新概念详细信息到数据库
|
|
66
48
|
def save_ths_concept_detail(new_concept_symbol_df,
|
|
67
49
|
concept_name, str_day,
|
|
@@ -179,6 +161,18 @@ def update_company_info(new_concept_symbol_df):
|
|
|
179
161
|
company_common_service_api.company_info_industry_cache_clear()
|
|
180
162
|
|
|
181
163
|
|
|
164
|
+
# 获取最大概念代码
|
|
165
|
+
def get_max_concept_code():
|
|
166
|
+
query = {"symbol": {'$ne': 'null'}, "success": True}
|
|
167
|
+
ths_concept_max = mongodb_util.descend_query(query, 'ths_concept_list', 'symbol', 1)
|
|
168
|
+
if ths_concept_max.shape[0] == 0:
|
|
169
|
+
concept_code = 885284
|
|
170
|
+
else:
|
|
171
|
+
concept_code = list(ths_concept_max['symbol'])[0]
|
|
172
|
+
|
|
173
|
+
return concept_code
|
|
174
|
+
|
|
175
|
+
|
|
182
176
|
def get_concept_detail_info_web(concept_code):
|
|
183
177
|
new_concept_symbol_list = ths_concept_detail_api.get_ths_concept_detail(concept_code, None)
|
|
184
178
|
if new_concept_symbol_list is None or new_concept_symbol_list.shape[0] == 0:
|
|
@@ -16,7 +16,10 @@ import math
|
|
|
16
16
|
from loguru import logger
|
|
17
17
|
import pandas as pd
|
|
18
18
|
import mns_common.utils.data_frame_util as data_frame_util
|
|
19
|
-
|
|
19
|
+
import time
|
|
20
|
+
from datetime import datetime
|
|
21
|
+
import mns_scheduler.concept.ths.common.ths_concept_sync_common_api as ths_concept_sync_common_api
|
|
22
|
+
import mns_scheduler.common.redis.redis_msg_push_service as redis_msg_push_service
|
|
20
23
|
|
|
21
24
|
def get_ths_concept_detail(concept_code, concept_name):
|
|
22
25
|
real_time_quotes_all_stocks = east_money_stock_api.get_real_time_quotes_all_stocks()
|
|
@@ -55,6 +58,9 @@ def get_ths_concept_detail(concept_code, concept_name):
|
|
|
55
58
|
not_in_ths_concept_detail_by_explain = result_df.loc[~(
|
|
56
59
|
result_df['symbol'].isin(ths_concept_detail_by_explain['symbol']))]
|
|
57
60
|
result_df = pd.concat([ths_concept_detail_by_explain_new, not_in_ths_concept_detail_by_explain])
|
|
61
|
+
result_df['concept_code'] = concept_code
|
|
62
|
+
result_df['change'] = 0
|
|
63
|
+
result_df['index'] = 0
|
|
58
64
|
return result_df
|
|
59
65
|
|
|
60
66
|
|
|
@@ -188,10 +194,30 @@ def merge_data_common_fun(result_df, real_time_quotes_all_stocks):
|
|
|
188
194
|
return result_df
|
|
189
195
|
|
|
190
196
|
|
|
197
|
+
# 同步概念详情到db
|
|
198
|
+
def sync_ths_concept_detail_to_db(concept_code, concept_name):
|
|
199
|
+
new_concept_symbol_detail_df = get_ths_concept_detail(concept_code, concept_name)
|
|
200
|
+
if data_frame_util.is_empty(new_concept_symbol_detail_df):
|
|
201
|
+
time.sleep(10)
|
|
202
|
+
return None
|
|
203
|
+
now_date = datetime.now()
|
|
204
|
+
str_now_time = now_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
205
|
+
time.sleep(1)
|
|
206
|
+
str_day = now_date.strftime('%Y-%m-%d')
|
|
207
|
+
new_concept_symbol_detail_df.loc[:, 'way'] = 'index_sync'
|
|
208
|
+
ths_concept_sync_common_api.save_ths_concept_detail(new_concept_symbol_detail_df,
|
|
209
|
+
concept_name,
|
|
210
|
+
str_day,
|
|
211
|
+
str_now_time, concept_code)
|
|
212
|
+
|
|
213
|
+
# 项目之前推送消息
|
|
214
|
+
redis_msg_push_service.send_redis_msg("新增同花顺概念")
|
|
215
|
+
|
|
216
|
+
|
|
191
217
|
if __name__ == '__main__':
|
|
192
|
-
|
|
193
|
-
real_time_quotes_all_stocks_df = east_money_stock_api.get_real_time_quotes_all_stocks()
|
|
194
|
-
get_ths_concept_detail_by_explain('
|
|
195
|
-
get_ths_concept_detail_from_web('
|
|
196
|
-
get_ths_concept_detail('
|
|
197
|
-
get_ths_concept_detail_by_wen_cai('
|
|
218
|
+
sync_ths_concept_detail_to_db('886084', '光纤概念')
|
|
219
|
+
# real_time_quotes_all_stocks_df = east_money_stock_api.get_real_time_quotes_all_stocks()
|
|
220
|
+
# get_ths_concept_detail_by_explain('886084', real_time_quotes_all_stocks_df)
|
|
221
|
+
# get_ths_concept_detail_from_web('886084', real_time_quotes_all_stocks_df)
|
|
222
|
+
# get_ths_concept_detail('886084', '光纤概念')
|
|
223
|
+
# get_ths_concept_detail_by_wen_cai('光纤概念', real_time_quotes_all_stocks_df)
|
|
@@ -14,10 +14,12 @@ from mns_common.db.MongodbUtil import MongodbUtil
|
|
|
14
14
|
from datetime import datetime
|
|
15
15
|
import mns_scheduler.concept.clean.ths_concept_clean_api as ths_concept_clean_api
|
|
16
16
|
import pandas as pd
|
|
17
|
-
import mns_scheduler.concept.
|
|
17
|
+
import mns_scheduler.concept.ths.detaill.ths_concept_detail_api as ths_concept_detail_api
|
|
18
18
|
import mns_common.constant.db_name_constant as db_name_constant
|
|
19
|
+
import mns_scheduler.common.redis.redis_msg_push_service as redis_msg_push_service
|
|
19
20
|
|
|
20
21
|
mongodb_util = MongodbUtil('27017')
|
|
22
|
+
import mns_common.component.concept.ths_concept_common_service_api as ths_concept_common_service_api
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
def sync_ths_concept_new_index():
|
|
@@ -28,17 +30,17 @@ def sync_ths_concept_new_index():
|
|
|
28
30
|
|
|
29
31
|
|
|
30
32
|
'''
|
|
31
|
-
同步ths新概念 通过app
|
|
33
|
+
同步ths新概念 通过app搜索代码
|
|
32
34
|
'''
|
|
33
35
|
|
|
34
36
|
|
|
35
37
|
def sync_ths_concept_new_index_from_app():
|
|
36
38
|
# 当前最大概念代码
|
|
37
39
|
max_concept_code = ths_concept_sync_common_api.get_max_concept_code()
|
|
38
|
-
#
|
|
40
|
+
# 最大概念代码上限
|
|
39
41
|
max_concept_code_limit = max_concept_code + 2
|
|
40
42
|
# 同花顺概念列表
|
|
41
|
-
ths_concept_list_exist =
|
|
43
|
+
ths_concept_list_exist = ths_concept_common_service_api.get_all_ths_concept()
|
|
42
44
|
# 同步向上3次
|
|
43
45
|
while max_concept_code <= max_concept_code_limit:
|
|
44
46
|
try:
|
|
@@ -76,16 +78,10 @@ def sync_ths_concept_new_index_from_app():
|
|
|
76
78
|
diff_one_df = pd.DataFrame(new_concept_one, index=[1])
|
|
77
79
|
mongodb_util.save_mongo(diff_one_df, db_name_constant.THS_CONCEPT_LIST)
|
|
78
80
|
# 新增概念信息处理
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
continue
|
|
84
|
-
new_concept_symbol_detail_df.loc[:, 'way'] = 'index_sync'
|
|
85
|
-
ths_concept_sync_common_api.save_ths_concept_detail(new_concept_symbol_detail_df,
|
|
86
|
-
concept_name,
|
|
87
|
-
str_day,
|
|
88
|
-
str_now_time, concept_code)
|
|
81
|
+
ths_concept_sync_common_api.push_msg_to_we_chat_and_redis(concept_code, concept_name,
|
|
82
|
+
url)
|
|
83
|
+
# 同步概念详情到db
|
|
84
|
+
ths_concept_detail_api.sync_ths_concept_detail_to_db(concept_code, concept_name)
|
|
89
85
|
# 更新ths概念统计信息
|
|
90
86
|
ths_concept_clean_api.update_ths_concept_info()
|
|
91
87
|
|
|
@@ -96,7 +92,7 @@ def sync_ths_concept_new_index_from_app():
|
|
|
96
92
|
|
|
97
93
|
|
|
98
94
|
'''
|
|
99
|
-
同步新概念 by ths detail
|
|
95
|
+
同步新概念 by ths detail 通过详情判断
|
|
100
96
|
'''
|
|
101
97
|
|
|
102
98
|
|
|
@@ -142,7 +138,8 @@ def sync_ths_concept_new_index_from_detail():
|
|
|
142
138
|
diff_one_df = pd.DataFrame(new_concept_one, index=[1])
|
|
143
139
|
mongodb_util.save_mongo(diff_one_df, db_name_constant.THS_CONCEPT_LIST)
|
|
144
140
|
# 新增概念信息处理
|
|
145
|
-
|
|
141
|
+
ths_concept_sync_common_api.push_msg_to_we_chat_and_redis(concept_code, concept_name,
|
|
142
|
+
url)
|
|
146
143
|
|
|
147
144
|
new_concept_symbol_detail_df.loc[:, 'way'] = 'index_sync'
|
|
148
145
|
ths_concept_sync_common_api.save_ths_concept_detail(new_concept_symbol_detail_df,
|
|
@@ -150,21 +147,16 @@ def sync_ths_concept_new_index_from_detail():
|
|
|
150
147
|
str_day,
|
|
151
148
|
str_now_time,
|
|
152
149
|
concept_code)
|
|
153
|
-
# 更新ths概念统计信息
|
|
154
|
-
ths_concept_clean_api.update_ths_concept_info()
|
|
155
150
|
|
|
156
151
|
logger.info("新增同花顺新概念:{}", concept_name)
|
|
157
152
|
|
|
158
153
|
except BaseException as e:
|
|
159
154
|
logger.error("同步新增概念代码:{},信息异常:{}", max_concept_code, e)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
#
|
|
163
|
-
|
|
164
|
-
# 推送新概念信息到微信
|
|
165
|
-
ths_concept_sync_common_api.push_msg_to_we_chat_web(concept_code, concept_name,
|
|
166
|
-
url)
|
|
155
|
+
# 更新ths概念统计信息
|
|
156
|
+
ths_concept_clean_api.update_ths_concept_info()
|
|
157
|
+
# 项目之前推送消息
|
|
158
|
+
redis_msg_push_service.send_redis_msg("新增同花顺概念")
|
|
167
159
|
|
|
168
160
|
|
|
169
161
|
if __name__ == '__main__':
|
|
170
|
-
|
|
162
|
+
sync_ths_concept_new_index()
|
|
@@ -5,36 +5,24 @@ file_path = os.path.abspath(__file__)
|
|
|
5
5
|
end = file_path.index('mns') + 17
|
|
6
6
|
project_path = file_path[0:end]
|
|
7
7
|
sys.path.append(project_path)
|
|
8
|
-
|
|
9
|
-
import time
|
|
10
8
|
import datetime
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
mongodb_util = MongodbUtil('27017')
|
|
9
|
+
import mns_scheduler.concept.ths.detaill.ths_concept_detail_api as ths_concept_detail_api
|
|
10
|
+
import mns_common.component.concept.ths_concept_common_service_api as ths_concept_common_service_api
|
|
11
|
+
from loguru import logger
|
|
15
12
|
|
|
16
13
|
|
|
17
14
|
# 通过概念指数同步所有概念下的股票组成
|
|
18
15
|
|
|
19
16
|
# 同步概念下所有股票组成
|
|
20
17
|
def update_concept_all_detail_info():
|
|
21
|
-
|
|
22
|
-
new_concept_list = mongodb_util.find_query_data("ths_concept_list", query)
|
|
18
|
+
new_concept_list = ths_concept_common_service_api.get_all_ths_concept()
|
|
23
19
|
new_concept_list = new_concept_list.sort_values(by=['symbol'], ascending=False)
|
|
24
|
-
if new_concept_list.shape[0] > 0:
|
|
25
|
-
for one_concept in new_concept_list.itertuples():
|
|
26
|
-
now_date_time = datetime.datetime.now()
|
|
27
|
-
str_day = now_date_time.strftime('%Y-%m-%d')
|
|
28
|
-
str_now_time = now_date_time.strftime('%Y-%m-%d %H:%M:%S')
|
|
29
|
-
new_concept_symbol_df = ths_concept_sync_common_api.get_concept_detail_info_web(one_concept.symbol)
|
|
30
20
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
ths_concept_sync_common_api.save_ths_concept_detail(new_concept_symbol_df, one_concept.name,
|
|
37
|
-
str_day, str_now_time, one_concept.symbol)
|
|
21
|
+
for one_concept in new_concept_list.itertuples():
|
|
22
|
+
try:
|
|
23
|
+
ths_concept_detail_api.sync_ths_concept_detail_to_db(one_concept.symbol, one_concept.name)
|
|
24
|
+
except BaseException as e:
|
|
25
|
+
logger.error("同步概念下所有股票组成异常:{},{},{}", one_concept.symbol, one_concept.name, e)
|
|
38
26
|
|
|
39
27
|
|
|
40
28
|
if __name__ == '__main__':
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import sys
|
|
3
|
-
import pandas as pd
|
|
4
3
|
import mns_common.api.ths.concept.web.ths_concept_detail_web as ths_concept_detail_web
|
|
5
4
|
import mns_common.api.em.east_money_stock_api as east_money_stock_api
|
|
6
5
|
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
@@ -13,6 +12,8 @@ import mns_scheduler.concept.ths.common.ths_concept_sync_common_api as ths_conce
|
|
|
13
12
|
import threading
|
|
14
13
|
import mns_scheduler.concept.ths.common.ths_concept_update_common_api as ths_concept_update_common_api
|
|
15
14
|
import mns_common.utils.date_handle_util as date_handle_util
|
|
15
|
+
import mns_common.constant.db_name_constant as db_name_constant
|
|
16
|
+
import mns_scheduler.common.redis.redis_msg_push_service as redis_msg_push_service
|
|
16
17
|
|
|
17
18
|
file_path = os.path.abspath(__file__)
|
|
18
19
|
end = file_path.index('mns') + 17
|
|
@@ -21,16 +22,16 @@ sys.path.append(project_path)
|
|
|
21
22
|
mongodb_util = MongodbUtil('27017')
|
|
22
23
|
# 分页大小
|
|
23
24
|
MAX_PAGE_NUMBER = 2500
|
|
24
|
-
# 获取单只股票新增概念
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
# 获取单只股票新增概念
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
def create_index():
|
|
30
|
-
mongodb_util.create_index(
|
|
31
|
-
mongodb_util.create_index(
|
|
32
|
-
mongodb_util.create_index(
|
|
33
|
-
mongodb_util.create_index(
|
|
31
|
+
mongodb_util.create_index(db_name_constant.THS_STOCK_CONCEPT_DETAIL_APP, [("symbol", 1)])
|
|
32
|
+
mongodb_util.create_index(db_name_constant.THS_STOCK_CONCEPT_DETAIL_APP, [("str_day", 1)])
|
|
33
|
+
mongodb_util.create_index(db_name_constant.THS_STOCK_CONCEPT_DETAIL_APP, [("title", 1)])
|
|
34
|
+
mongodb_util.create_index(db_name_constant.THS_STOCK_CONCEPT_DETAIL_APP, [("str_now_date", 1)])
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
# 同步新概念到详情表中
|
|
@@ -52,6 +53,8 @@ def sync_new_concept_to_ths_detail(symbol_add_new_concept_df, str_day, str_now_t
|
|
|
52
53
|
|
|
53
54
|
except BaseException as e:
|
|
54
55
|
logger.error("转换同花顺概念异常:{},{}", new_concept_one, e)
|
|
56
|
+
# 项目之前推送消息
|
|
57
|
+
redis_msg_push_service.send_redis_msg("新增同花顺概念")
|
|
55
58
|
|
|
56
59
|
|
|
57
60
|
# 保存数据到对比
|
|
@@ -60,7 +63,7 @@ def save_data_to_db(ths_concept_df):
|
|
|
60
63
|
if data_frame_util.is_empty(ths_concept_df):
|
|
61
64
|
return
|
|
62
65
|
json_data = ths_concept_df.to_dict(orient='records')
|
|
63
|
-
mongodb_util.save_mongo_json(json_data,
|
|
66
|
+
mongodb_util.save_mongo_json(json_data, db_name_constant.THS_STOCK_CONCEPT_DETAIL_APP)
|
|
64
67
|
|
|
65
68
|
|
|
66
69
|
# 对比数据库和接口概念详情的差值
|
|
@@ -6,7 +6,7 @@ end = file_path.index('mns') + 16
|
|
|
6
6
|
project_path = file_path[0:end]
|
|
7
7
|
sys.path.append(project_path)
|
|
8
8
|
|
|
9
|
-
import mns_scheduler.concept.
|
|
9
|
+
import mns_scheduler.concept.ths.detaill.ths_concept_detail_api as ths_concept_detail_api
|
|
10
10
|
import mns_common.component.self_choose.black_list_service_api as black_list_service_api
|
|
11
11
|
from datetime import datetime
|
|
12
12
|
from loguru import logger
|
|
@@ -437,7 +437,7 @@ blockingScheduler.add_job(update_best_choose_plate_relation, 'cron', hour='09,18
|
|
|
437
437
|
blockingScheduler.add_job(sync_kpl_best_his_quotes, 'cron', hour='18,22', minute='25')
|
|
438
438
|
|
|
439
439
|
# 更新开盘啦指数关系
|
|
440
|
-
blockingScheduler.add_job(sync_position, 'cron', hour='0,
|
|
440
|
+
blockingScheduler.add_job(sync_position, 'cron', hour='0,09', minute='10')
|
|
441
441
|
|
|
442
442
|
# 同步高风险股票
|
|
443
443
|
blockingScheduler.add_job(sync_high_risk_stocks, 'cron', hour='0,09,12,16', minute='20')
|
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
mns_scheduler/__init__.py,sha256=Tyvi_iQlv3jz59EdH67Mycnt9CSixcWPQoJwu55bOq0,165
|
|
2
|
-
mns_scheduler/backup/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
3
|
-
mns_scheduler/backup/data/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
4
|
-
mns_scheduler/backup/data/collection_move.py,sha256=WZN6-312jBbWrNqXCSk-0yTQ60ajUUWAqr2exVfotKU,2005
|
|
5
|
-
mns_scheduler/backup/data/sync_data_to_local.py,sha256=o_kEcBoG8-CjLS7f_cXUBMo_z5MHn2z1WYnaobNDW90,1737
|
|
6
|
-
mns_scheduler/backup/data/sync_remote_by_str_day.py,sha256=uEi-8j5gqRvWoJwIJGAr1Dc7UCmpXAh7q1IMS-Z88Fw,1220
|
|
7
|
-
mns_scheduler/backup/em/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
8
|
-
mns_scheduler/backup/em/em_new_concept_his_sync.py,sha256=Yqbuz9VE9433o0Z6BvDo5adhj3lK4vmN66XNQBIdC1k,4992
|
|
9
|
-
mns_scheduler/backup/em/em_new_concept_sync_common_api.py,sha256=KnNCf0KXy31GFwF1-wbbkfDM-H7-cEtcVoCwl4QmoVs,7083
|
|
10
|
-
mns_scheduler/backup/em/em_new_concept_sync_web.py,sha256=wVS0yLyPYzpcxfWAuUqmqbYkjw9wjpo48CvLSZFckzw,2334
|
|
11
|
-
mns_scheduler/backup/ths/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
mns_scheduler/backup/ths/sync_ths_concept_by_ak_api.py,sha256=8QBiRKc0Q3ez-kBwvz7G8HrFDD_ANd8smOpQtGyvKIs,5371
|
|
13
|
-
mns_scheduler/backup/ths/sync_ths_new_concept_by_web_api.py,sha256=dLd2V67AFnE9xf5H8YGyaJ0j7z8FhtTemFVGOuOeHJ4,4087
|
|
14
2
|
mns_scheduler/big_deal/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
15
3
|
mns_scheduler/big_deal/ths_big_deal_sync.py,sha256=aMFj-_pLprh4vGjSSzmr_tlYoPA0L4Lm0SkLRkQwIiw,4564
|
|
4
|
+
mns_scheduler/common/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
5
|
+
mns_scheduler/common/redis/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
6
|
+
mns_scheduler/common/redis/redis_msg_push_service.py,sha256=LypT8Sl91xGcO1bF9o3utThk_SUtotuD-UEfgFjCww8,476
|
|
16
7
|
mns_scheduler/company_info/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
17
8
|
mns_scheduler/company_info/base/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
18
9
|
mns_scheduler/company_info/base/sync_company_base_info_api.py,sha256=NRuwc5oJF9Ngt932OrnG76oP22OmkjbGgcWKgWplafg,19106
|
|
19
10
|
mns_scheduler/company_info/clean/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
20
|
-
mns_scheduler/company_info/clean/company_info_clean_api.py,sha256=
|
|
11
|
+
mns_scheduler/company_info/clean/company_info_clean_api.py,sha256=n3kxsqihPjKJvGDkAjMYqB_U2EPemOi1Yjez5yOYJeo,4858
|
|
21
12
|
mns_scheduler/company_info/constant/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
22
13
|
mns_scheduler/company_info/constant/company_constant_data.py,sha256=XIM81fA4PNalVJNBYXiMddkcW012fFtofoPGYy2VtD0,16001
|
|
23
14
|
mns_scheduler/company_info/de_list_stock/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
@@ -27,19 +18,18 @@ mns_scheduler/company_info/remark/company_remark_info_sync.py,sha256=hzQ8uBK4-od
|
|
|
27
18
|
mns_scheduler/concept/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
28
19
|
mns_scheduler/concept/clean/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
29
20
|
mns_scheduler/concept/clean/kpl_concept_clean_api.py,sha256=xxIIgrXLI6xLf10t4unJa7aMB_QeKeki1HJVeXsntkY,4512
|
|
30
|
-
mns_scheduler/concept/clean/ths_concept_clean_api.py,sha256=
|
|
31
|
-
mns_scheduler/concept/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
-
mns_scheduler/concept/common/detaill/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
|
-
mns_scheduler/concept/common/detaill/ths_concept_detail_api.py,sha256=Au_l7SVcp4kRaR2vo1FP3BmYHeRI9fkOk_sTwzpRYw4,9435
|
|
21
|
+
mns_scheduler/concept/clean/ths_concept_clean_api.py,sha256=wxdT5Eb3awHW9HuFlgSe8-C6sC6TNaDYozr8VvNdYe0,5953
|
|
34
22
|
mns_scheduler/concept/ths/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
35
23
|
mns_scheduler/concept/ths/common/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
36
|
-
mns_scheduler/concept/ths/common/ths_concept_sync_common_api.py,sha256=
|
|
24
|
+
mns_scheduler/concept/ths/common/ths_concept_sync_common_api.py,sha256=xreSNZDdooI0do9RQLTKqrQ85JgbNRhQzaNCI9SgKns,8328
|
|
37
25
|
mns_scheduler/concept/ths/common/ths_concept_update_common_api.py,sha256=4BQT3A9t-nDIyCpILgRZF7ZOgK1oabp-gJl5nyWvKWc,4418
|
|
26
|
+
mns_scheduler/concept/ths/detaill/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
+
mns_scheduler/concept/ths/detaill/ths_concept_detail_api.py,sha256=OdtLnF4St15-4vYck_5qj4k5KMSTFbAaAbtWP5kvqLk,10694
|
|
38
28
|
mns_scheduler/concept/ths/sync_new_index/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
39
|
-
mns_scheduler/concept/ths/sync_new_index/sync_ths_concept_new_index_api.py,sha256=
|
|
29
|
+
mns_scheduler/concept/ths/sync_new_index/sync_ths_concept_new_index_api.py,sha256=4vzKeQ2WfDOZlADgPSWsFHcqAIQAoRtUpWmsNCrJRnw,7533
|
|
40
30
|
mns_scheduler/concept/ths/update_concept_info/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
41
|
-
mns_scheduler/concept/ths/update_concept_info/sync_one_concept_all_symbols_api.py,sha256=
|
|
42
|
-
mns_scheduler/concept/ths/update_concept_info/sync_one_symbol_all_concepts_api.py,sha256=
|
|
31
|
+
mns_scheduler/concept/ths/update_concept_info/sync_one_concept_all_symbols_api.py,sha256=wwuLfjj9AnFcHP-oQPC5AhpwgZ8IsPiNUh-Z6swcngA,1380
|
|
32
|
+
mns_scheduler/concept/ths/update_concept_info/sync_one_symbol_all_concepts_api.py,sha256=83I6UDL9IDUrIozXyuLcFjilQFEk3tAWWxwn1SBcMgk,9217
|
|
43
33
|
mns_scheduler/db/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
44
34
|
mns_scheduler/db/col_move_service.py,sha256=-d3JUCjWyaGKBhyUSkqwpCgZtHkIy1JOasgpxmH74zg,4057
|
|
45
35
|
mns_scheduler/db/db_status.py,sha256=e5eW5ZSm5J7tHvmxxhFmFdbZb2_oB_SAcdcFqc4KDmw,733
|
|
@@ -102,7 +92,7 @@ mns_scheduler/risk/financial/stock_equity_mortgage_check_api.py,sha256=SQ7dieSCO
|
|
|
102
92
|
mns_scheduler/risk/major_violations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
103
93
|
mns_scheduler/risk/major_violations/register_and_investigate_stock_sync_api.py,sha256=_xPQxT6OS7J7_PtA7hbfCmMS7VzpZTWoZUOXzwoesUs,5672
|
|
104
94
|
mns_scheduler/risk/self/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
105
|
-
mns_scheduler/risk/self/wei_pan_stock_api.py,sha256=
|
|
95
|
+
mns_scheduler/risk/self/wei_pan_stock_api.py,sha256=5ebrjFqK49j_yEMffFBCumMeBzq_rmtsA4--lL5mhZs,1899
|
|
106
96
|
mns_scheduler/risk/test/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
107
97
|
mns_scheduler/risk/test/fix_blask_list.py,sha256=jjLhhIWH1L4CgNp2jQ_HAHbC3wVgeX1TzhqC--_D2MI,1249
|
|
108
98
|
mns_scheduler/risk/transactions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -137,8 +127,8 @@ mns_scheduler/zt/zt_pool/__init__.py,sha256=Tyvi_iQlv3jz59EdH67Mycnt9CSixcWPQoJw
|
|
|
137
127
|
mns_scheduler/zt/zt_pool/em_zt_pool_sync_api.py,sha256=x3-NCugHoY5IuX2s1UOUMl8DZsi9nrtMbEGzxWqJj3c,7642
|
|
138
128
|
mns_scheduler/zt/zt_pool/ths_zt_pool_sync_api.py,sha256=LJVGqJyLn04oC-Xp59RVE1IOz7lx6ao78bw9l67sKBM,10382
|
|
139
129
|
mns_scheduler/zz_task/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
140
|
-
mns_scheduler/zz_task/data_sync_task.py,sha256=
|
|
141
|
-
mns_scheduler-1.1.3.
|
|
142
|
-
mns_scheduler-1.1.3.
|
|
143
|
-
mns_scheduler-1.1.3.
|
|
144
|
-
mns_scheduler-1.1.3.
|
|
130
|
+
mns_scheduler/zz_task/data_sync_task.py,sha256=KI7I5R4RFZ67KSzXJiObnIrsKecvvvMQpCFNMX1qHJQ,19069
|
|
131
|
+
mns_scheduler-1.1.3.9.dist-info/METADATA,sha256=B7k2ga2WhdPCcL4LZ8i8OMtzSTdNhLdpyl0RsdXC9oc,64
|
|
132
|
+
mns_scheduler-1.1.3.9.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
133
|
+
mns_scheduler-1.1.3.9.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
|
|
134
|
+
mns_scheduler-1.1.3.9.dist-info/RECORD,,
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
import os
|
|
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
|
-
from loguru import logger
|
|
9
|
-
|
|
10
|
-
db_name_list = [
|
|
11
|
-
# 'company_info', 'company_info_base', 'company_info_his', 'company_info_hk', 'de_list_stock',
|
|
12
|
-
# 'em_stock_asset_liability',
|
|
13
|
-
# 'em_stock_profit',
|
|
14
|
-
# 'k_line_info',
|
|
15
|
-
'kpl_best_choose_daily', 'kpl_best_choose_his', 'kpl_best_choose_index',
|
|
16
|
-
'kpl_best_choose_index_detail',
|
|
17
|
-
'kpl_his_quotes', 'recent_hot_stocks', 'self_black_stock', 'self_choose_plate', 'self_choose_stock', 'sse_info_uid',
|
|
18
|
-
'stock_gdfx_free_top_10', 'stock_high_chg_pool', 'stock_interactive_question', 'stock_qfq_daily',
|
|
19
|
-
'stock_qfq_monthly', 'stock_qfq_weekly', 'stock_zt_pool', 'stock_zt_pool_five', 'stock_zb_pool', 'sw_industry',
|
|
20
|
-
'ths_concept_list', 'ths_stock_concept_detail', 'ths_stock_concept_detail_app', 'ths_zt_pool',
|
|
21
|
-
'today_new_concept_list',
|
|
22
|
-
'trade_date_list', 'realtime_quotes_now_zt_new', 'realtime_quotes_now_open', 'realtime_quotes_now_zt_new_kc_open']
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def db_export(db, col):
|
|
26
|
-
cmd = 'F:/mongo/bin/mongodump.exe --host ' + db + ' -d patience -c ' + col + ' -o D:/back'
|
|
27
|
-
os.system(cmd)
|
|
28
|
-
logger.info("export finished:{}", col)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def db_import(db, col):
|
|
32
|
-
cmd = 'F:/mongo/bin/mongorestore.exe --host ' + db + ' -d patience -c ' + col + ' D:/back/patience/' + col + '.bson'
|
|
33
|
-
os.system(cmd)
|
|
34
|
-
|
|
35
|
-
path = 'D:\\back\\patience\\' + col + '.bson'
|
|
36
|
-
cmd_del = 'del /F /S /Q ' + path
|
|
37
|
-
os.system(cmd_del)
|
|
38
|
-
|
|
39
|
-
logger.info("import finished:{}", col)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def collection_to_local():
|
|
43
|
-
for db_name in db_name_list:
|
|
44
|
-
try:
|
|
45
|
-
db_export('127.0.0.1:27017', db_name)
|
|
46
|
-
db_import('192.168.1.6:27017', db_name)
|
|
47
|
-
logger.info("同步到集合:{}", db_name)
|
|
48
|
-
except BaseException as e:
|
|
49
|
-
logger.error("出现异常:{}", e)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if __name__ == '__main__':
|
|
53
|
-
collection_to_local()
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
import os
|
|
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
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
9
|
-
from loguru import logger
|
|
10
|
-
|
|
11
|
-
mongodb_util = MongodbUtil('27017')
|
|
12
|
-
|
|
13
|
-
from mns_common.db.MongodbUtilLocal import MongodbUtil as MongodbUtilLocal
|
|
14
|
-
|
|
15
|
-
mongodbUtilLocal = MongodbUtilLocal('27017')
|
|
16
|
-
|
|
17
|
-
db_name_list = [
|
|
18
|
-
# 'company_info', 'company_info_base', 'company_info_his', 'company_info_hk', 'de_list_stock',
|
|
19
|
-
# 'em_stock_asset_liability',
|
|
20
|
-
# 'em_stock_profit',
|
|
21
|
-
# 'k_line_info',
|
|
22
|
-
# 'kpl_best_choose_daily',
|
|
23
|
-
# 'kpl_best_choose_his',
|
|
24
|
-
# 'kpl_best_choose_index',
|
|
25
|
-
# 'kpl_best_choose_index_detail',
|
|
26
|
-
# 'kpl_his_quotes',
|
|
27
|
-
# 'stock_qfq_daily',
|
|
28
|
-
# 'stock_qfq_monthly',
|
|
29
|
-
# 'stock_qfq_weekly',
|
|
30
|
-
# 'stock_gdfx_free_top_10',
|
|
31
|
-
# 'recent_hot_stocks',
|
|
32
|
-
# 'self_black_stock',
|
|
33
|
-
# 'self_choose_plate', 'self_choose_stock', 'sse_info_uid',
|
|
34
|
-
# 'stock_high_chg_pool', 'stock_interactive_question',
|
|
35
|
-
# 'stock_zt_pool', 'stock_zt_pool_five', 'stock_zb_pool', 'sw_industry',
|
|
36
|
-
# 'ths_concept_list', 'ths_stock_concept_detail','ths_zt_pool',
|
|
37
|
-
# 'today_new_concept_list',
|
|
38
|
-
# 'trade_date_list',
|
|
39
|
-
# 'ths_stock_concept_detail_app',
|
|
40
|
-
"stock_zt_pool"
|
|
41
|
-
]
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def sync_collection_to_local():
|
|
45
|
-
for db_name in db_name_list:
|
|
46
|
-
try:
|
|
47
|
-
df_data = mongodb_util.find_all_data(db_name)
|
|
48
|
-
mongodbUtilLocal.save_mongo(df_data, db_name)
|
|
49
|
-
logger.info("同步到集合:{}", db_name)
|
|
50
|
-
except BaseException as e:
|
|
51
|
-
logger.error("出现异常:{}", e)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if __name__ == '__main__':
|
|
55
|
-
sync_collection_to_local()
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
import os
|
|
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
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
9
|
-
from loguru import logger
|
|
10
|
-
|
|
11
|
-
mongodb_util = MongodbUtil('27017')
|
|
12
|
-
from mns_common.db.MongodbUtilLocal import MongodbUtil as MongodbUtilLocal
|
|
13
|
-
|
|
14
|
-
mongodbUtilLocal = MongodbUtilLocal('27017')
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def sync_remote_open_data(str_day):
|
|
18
|
-
query_remote = {"str_day": str_day}
|
|
19
|
-
realtime_quotes_now_open_df = mongodb_util.find_query_data('realtime_quotes_now_open', query_remote)
|
|
20
|
-
mongodbUtilLocal.insert_mongo(realtime_quotes_now_open_df, 'realtime_quotes_now_open')
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if __name__ == '__main__':
|
|
24
|
-
query = {'$and': [{"_id": {"$gte": "2022-03-16"}},
|
|
25
|
-
{"_id": {"$lte": "2024-06-28"}}]}
|
|
26
|
-
trade_date_list = mongodb_util.find_query_data('trade_date_list', query)
|
|
27
|
-
for trade_one in trade_date_list.itertuples():
|
|
28
|
-
try:
|
|
29
|
-
sync_str_day = trade_one.trade_date
|
|
30
|
-
sync_remote_open_data(sync_str_day)
|
|
31
|
-
logger.info('str_day:{}', sync_str_day)
|
|
32
|
-
except BaseException as e:
|
|
33
|
-
logger.error("同步远程数据异常:{}", e)
|
|
@@ -1,99 +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 akshare as ak
|
|
10
|
-
from loguru import logger
|
|
11
|
-
from datetime import datetime
|
|
12
|
-
import mns_common.utils.date_handle_util as date_handle_util
|
|
13
|
-
import mns_common.db.MongodbUtil as MongodbUtil
|
|
14
|
-
import mns_scheduler.backup.em.em_new_concept_sync_common_api as em_new_concept_sync_common_api
|
|
15
|
-
import mns_common.api.em.em_concept_index_api as em_concept_index_api
|
|
16
|
-
|
|
17
|
-
mongodb_util = MongodbUtil('27017')
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
# 同步概念k线
|
|
21
|
-
def sync_concept_k_line(symbol, period, start_date, end_date, adjust):
|
|
22
|
-
try:
|
|
23
|
-
stock_board_concept_hist_em_df = ak.stock_board_concept_hist_em(
|
|
24
|
-
symbol=symbol, period=period, start_date=start_date, end_date=end_date, adjust=adjust
|
|
25
|
-
)
|
|
26
|
-
stock_board_concept_hist_em_df = stock_board_concept_hist_em_df.rename(columns={"日期": "date",
|
|
27
|
-
"开盘": "open",
|
|
28
|
-
"收盘": "close",
|
|
29
|
-
"最高": "high",
|
|
30
|
-
"最低": "low",
|
|
31
|
-
"涨跌幅": "chg",
|
|
32
|
-
"涨跌额": "change",
|
|
33
|
-
"成交量": "volume",
|
|
34
|
-
"成交额": "amount",
|
|
35
|
-
"振幅": "pct_chg",
|
|
36
|
-
"换手率": "exchange"
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
return stock_board_concept_hist_em_df
|
|
40
|
-
except BaseException as e:
|
|
41
|
-
logger.error("同步东方财富概念信息异常:{}", e)
|
|
42
|
-
return None
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
# 同步所有历史概念数据
|
|
46
|
-
def sync_his_em_concept():
|
|
47
|
-
now_date = datetime.now()
|
|
48
|
-
str_day = now_date.strftime('%Y-%m-%d')
|
|
49
|
-
|
|
50
|
-
all_concept_list = em_concept_index_api.sync_all_concept()
|
|
51
|
-
for stock_one in all_concept_list.itertuples():
|
|
52
|
-
try:
|
|
53
|
-
stock_one_df_copy = all_concept_list.loc[all_concept_list['concept_code'] == stock_one.concept_code]
|
|
54
|
-
stock_one_df = stock_one_df_copy.copy()
|
|
55
|
-
|
|
56
|
-
stock_board_concept_hist_em_df = sync_concept_k_line(
|
|
57
|
-
symbol=stock_one.concept_name, period="daily", start_date="19980729",
|
|
58
|
-
end_date=date_handle_util.no_slash_date(str_day), adjust="qfq"
|
|
59
|
-
)
|
|
60
|
-
stock_board_concept_hist_em_df = stock_board_concept_hist_em_df.sort_values(by=['date'], ascending=True)
|
|
61
|
-
stock_board_concept_hist_em_df_first_day = stock_board_concept_hist_em_df.iloc[0:1]
|
|
62
|
-
|
|
63
|
-
list_date = list(stock_board_concept_hist_em_df_first_day['date'])[0]
|
|
64
|
-
str_now_time = list_date + " " + "09:10:00"
|
|
65
|
-
stock_one_df.loc[:, 'str_now_time'] = str_now_time
|
|
66
|
-
|
|
67
|
-
stock_one_df.loc[:, 'str_day'] = list_date
|
|
68
|
-
|
|
69
|
-
stock_one_df['_id'] = stock_one_df['concept_code']
|
|
70
|
-
stock_one_df['url'] = "http://quote.eastmoney.com/center/boardlist.html#boards-" + stock_one.concept_code
|
|
71
|
-
stock_one_df['success'] = True
|
|
72
|
-
|
|
73
|
-
mongodb_util.save_mongo(stock_one_df, 'em_concept_list')
|
|
74
|
-
#
|
|
75
|
-
concept_detail_list = em_new_concept_sync_common_api.sync_concept_detail(stock_one.concept_code)
|
|
76
|
-
|
|
77
|
-
concept_detail_list.loc[:, 'concept_code'] = stock_one.concept_code
|
|
78
|
-
concept_detail_list.loc[:, 'concept_name'] = stock_one.concept_name
|
|
79
|
-
concept_detail_list.loc[:, 'str_day'] = list_date
|
|
80
|
-
|
|
81
|
-
concept_detail_list.loc[:, 'str_now_time'] = str_now_time
|
|
82
|
-
|
|
83
|
-
concept_detail_list['_id'] = concept_detail_list['symbol'] + '-' + concept_detail_list['concept_code']
|
|
84
|
-
|
|
85
|
-
mongodb_util.insert_mongo(concept_detail_list, 'em_stock_concept_detail')
|
|
86
|
-
except BaseException as e:
|
|
87
|
-
logger.error("发生异常:{}", e)
|
|
88
|
-
continue
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if __name__ == '__main__':
|
|
92
|
-
# all_concept = sync_all_concept()
|
|
93
|
-
# all_concept = all_concept.loc[~(all_concept['list_day'] == '-')]
|
|
94
|
-
# all_concept = all_concept.sort_values(by=['list_day'], ascending=False)
|
|
95
|
-
sync_his_em_concept()
|
|
96
|
-
# stock_board_concept_hist_em_df = sync_concept_k_line(
|
|
97
|
-
# symbol="车联网", period="daily", start_date="20220101", end_date="20221128", adjust=""
|
|
98
|
-
# )
|
|
99
|
-
# sync_concept_detail('MLOps概念')
|
|
@@ -1,139 +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
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
10
|
-
import mns_common.api.msg.push_msg_api as push_msg_api
|
|
11
|
-
import mns_common.api.em.em_concept_index_api as em_concept_index_api
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import pandas as pd
|
|
15
|
-
import mns_common.utils.data_frame_util as data_frame_util
|
|
16
|
-
from loguru import logger
|
|
17
|
-
mongodb_util = MongodbUtil('27017')
|
|
18
|
-
|
|
19
|
-
max_concept_code = 1200
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# 获取最大概念代码
|
|
23
|
-
def get_max_concept_code():
|
|
24
|
-
query = {"concept_code": {'$ne': 'null'}, "success": True}
|
|
25
|
-
ths_concept_max = mongodb_util.descend_query(query, 'em_concept_list', 'concept_code', 1)
|
|
26
|
-
if ths_concept_max.shape[0] == 0:
|
|
27
|
-
concept_code = 'BK1134'
|
|
28
|
-
else:
|
|
29
|
-
concept_code = list(ths_concept_max['concept_code'])[0]
|
|
30
|
-
concept_code = concept_code.replace('BK', '')
|
|
31
|
-
return concept_code
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
# 获取概念名称
|
|
35
|
-
def get_concept_name(concept_code):
|
|
36
|
-
concept_df = em_concept_index_api.sync_all_concept()
|
|
37
|
-
concept_df_one = concept_df.loc[concept_df['concept_code'] == concept_code]
|
|
38
|
-
if data_frame_util.is_empty(concept_df_one):
|
|
39
|
-
return ""
|
|
40
|
-
else:
|
|
41
|
-
return concept_df_one
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
# 获取概念详情
|
|
45
|
-
def sync_concept_detail(concept_code):
|
|
46
|
-
try:
|
|
47
|
-
stock_board_concept_cons_em_df = em_concept_index_api.stock_board_concept_cons_em(concept_code)
|
|
48
|
-
if data_frame_util.is_empty(stock_board_concept_cons_em_df):
|
|
49
|
-
return None
|
|
50
|
-
stock_board_concept_cons_em_df = stock_board_concept_cons_em_df.rename(columns={"序号": "index",
|
|
51
|
-
"代码": "symbol",
|
|
52
|
-
"名称": "name",
|
|
53
|
-
"最新价": "now_price",
|
|
54
|
-
"涨跌幅": "chg",
|
|
55
|
-
"涨跌额": "change",
|
|
56
|
-
"成交量": "volume",
|
|
57
|
-
"成交额": "amount",
|
|
58
|
-
"振幅": "pct_chg",
|
|
59
|
-
"最高": "high",
|
|
60
|
-
"最低": "low",
|
|
61
|
-
"今开": "open",
|
|
62
|
-
"昨收": "last_price",
|
|
63
|
-
"换手率": "exchange",
|
|
64
|
-
"市盈率-动态": 'pe',
|
|
65
|
-
"市净率": 'pb'
|
|
66
|
-
})
|
|
67
|
-
return stock_board_concept_cons_em_df
|
|
68
|
-
except BaseException as e:
|
|
69
|
-
logger.error("同步东方财富概念信息异常:{}", e)
|
|
70
|
-
return None
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
# web端获取新概念消息推送
|
|
74
|
-
def push_msg_to_we_chat_web(concept_code, concept_name):
|
|
75
|
-
url = 'http://quote.eastmoney.com/center/boardlist.html#boards-' + str(concept_code)
|
|
76
|
-
msg = "概念代码:" + str(concept_code) + "," + "概念名称:" + concept_name + "," + "url: " + url
|
|
77
|
-
title = "新增东财概念:" + str(concept_code) + "-" + concept_name
|
|
78
|
-
push_msg_api.push_msg_to_wechat(title, msg)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
# 保存新概念信息到数据库
|
|
82
|
-
def save_em_concept_list(concept_code, concept_name, str_day, str_now_time, concept_df_one):
|
|
83
|
-
url = 'https://quote.eastmoney.com/center/boardlist.html#boards-' + str(concept_code)
|
|
84
|
-
if data_frame_util.is_empty(concept_df_one):
|
|
85
|
-
em_concept_list = pd.DataFrame([
|
|
86
|
-
[concept_code, concept_code, concept_name, str_day, url, str_now_time, True],
|
|
87
|
-
], columns=['_id', 'concept_code', 'concept_name', 'str_day', 'url', 'str_now_time', 'success'])
|
|
88
|
-
|
|
89
|
-
mongodb_util.save_mongo(em_concept_list, 'em_concept_list')
|
|
90
|
-
else:
|
|
91
|
-
concept_df_one['_id'] = concept_df_one['concept_code']
|
|
92
|
-
concept_df_one.loc[:, 'str_now_time'] = str_now_time
|
|
93
|
-
concept_df_one.loc[:, 'str_day'] = str_day
|
|
94
|
-
concept_df_one.loc[:, 'url'] = url
|
|
95
|
-
concept_df_one.loc[:, 'success'] = True
|
|
96
|
-
mongodb_util.save_mongo(concept_df_one, 'em_concept_list')
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
# 保存新概念详细信息到数据库
|
|
100
|
-
def save_ths_concept_detail(new_concept_symbol_df, concept_name, str_day, str_now_time, concept_code):
|
|
101
|
-
new_concept_symbol_df['_id'] = new_concept_symbol_df['symbol'] + '-' + concept_code
|
|
102
|
-
|
|
103
|
-
new_concept_symbol_df['concept_code'] = concept_code
|
|
104
|
-
new_concept_symbol_df['concept_name'] = concept_name
|
|
105
|
-
new_concept_symbol_df['str_day'] = str_day
|
|
106
|
-
new_concept_symbol_df['str_now_time'] = str_now_time
|
|
107
|
-
|
|
108
|
-
new_concept_symbol_list = list(new_concept_symbol_df['symbol'])
|
|
109
|
-
|
|
110
|
-
query_company_info = {'symbol': {'$in': new_concept_symbol_list}}
|
|
111
|
-
query_field = {"first_industry": 1, "first_industry": 1, "industry": 1, "company_type": 1, "flow_mv_sp": 1,
|
|
112
|
-
"total_mv_sp": 1}
|
|
113
|
-
company_info = mongodb_util.find_query_data_choose_field('company_info', query_company_info, query_field)
|
|
114
|
-
|
|
115
|
-
company_info = company_info.set_index(['_id'], drop=True)
|
|
116
|
-
new_concept_symbol_df = new_concept_symbol_df.set_index(['symbol'], drop=False)
|
|
117
|
-
|
|
118
|
-
new_concept_symbol_df = pd.merge(new_concept_symbol_df, company_info, how='outer',
|
|
119
|
-
left_index=True, right_index=True)
|
|
120
|
-
query = {'concept_code': concept_code}
|
|
121
|
-
exist_concept_detail = mongodb_util.find_query_data('em_stock_concept_detail', query)
|
|
122
|
-
if data_frame_util.is_empty(exist_concept_detail):
|
|
123
|
-
mongodb_util.save_mongo(new_concept_symbol_df, 'em_stock_concept_detail')
|
|
124
|
-
else:
|
|
125
|
-
exist_concept_detail_symbol_list = list(exist_concept_detail['symbol'])
|
|
126
|
-
new_concept_symbol_df = new_concept_symbol_df.loc[~(
|
|
127
|
-
new_concept_symbol_df['symbol'].isin(exist_concept_detail_symbol_list))]
|
|
128
|
-
if new_concept_symbol_df.shape[0] > 0:
|
|
129
|
-
mongodb_util.save_mongo(new_concept_symbol_df, 'em_stock_concept_detail')
|
|
130
|
-
# update_company_info(new_concept_symbol_df, concept_code, concept_name, str_day)
|
|
131
|
-
# # 公司缓存信息清除
|
|
132
|
-
# common_service_fun_api.company_info_industry_cache_clear()
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if __name__ == '__main__':
|
|
136
|
-
get_concept_name('BK1134')
|
|
137
|
-
|
|
138
|
-
sync_concept_detail('BK1055')
|
|
139
|
-
get_max_concept_code()
|
|
@@ -1,55 +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 time
|
|
11
|
-
from loguru import logger
|
|
12
|
-
import mns_scheduler.backup.em.em_new_concept_sync_common_api as em_new_concept_sync_common_api
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
# 同步东财新概念
|
|
16
|
-
def sync_new_concept_data():
|
|
17
|
-
concept_code = em_new_concept_sync_common_api.get_max_concept_code()
|
|
18
|
-
# 装换为数字
|
|
19
|
-
concept_code = int(concept_code)
|
|
20
|
-
|
|
21
|
-
concept_code = concept_code + 1
|
|
22
|
-
|
|
23
|
-
while concept_code < em_new_concept_sync_common_api.max_concept_code:
|
|
24
|
-
try:
|
|
25
|
-
now_date = datetime.datetime.now()
|
|
26
|
-
str_day = now_date.strftime('%Y-%m-%d')
|
|
27
|
-
str_now_time = now_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
28
|
-
str_concept_code = 'BK' + str(concept_code)
|
|
29
|
-
new_concept_symbol_df = em_new_concept_sync_common_api.sync_concept_detail(str_concept_code)
|
|
30
|
-
if new_concept_symbol_df is None or new_concept_symbol_df.shape[0] == 0:
|
|
31
|
-
concept_code = concept_code + 1
|
|
32
|
-
time.sleep(1)
|
|
33
|
-
continue
|
|
34
|
-
time.sleep(2)
|
|
35
|
-
concept_df_one = em_new_concept_sync_common_api.get_concept_name(str_concept_code)
|
|
36
|
-
# 获取概念名称
|
|
37
|
-
concept_name = list(concept_df_one['concept_name'])[0]
|
|
38
|
-
|
|
39
|
-
# 推送新概念信息到微信
|
|
40
|
-
em_new_concept_sync_common_api.push_msg_to_we_chat_web(str_concept_code, concept_name)
|
|
41
|
-
# 保存新概念信息到数据库
|
|
42
|
-
em_new_concept_sync_common_api.save_em_concept_list(str_concept_code, concept_name, str_day, str_now_time,
|
|
43
|
-
concept_df_one)
|
|
44
|
-
# 保存新概念详细信息到数据库
|
|
45
|
-
em_new_concept_sync_common_api.save_ths_concept_detail(new_concept_symbol_df, concept_name, str_day,
|
|
46
|
-
str_now_time, str_concept_code)
|
|
47
|
-
|
|
48
|
-
concept_code = concept_code + 1
|
|
49
|
-
except BaseException as e:
|
|
50
|
-
logger.error("同步新概念异常:{},concept_code:{}", e, concept_code)
|
|
51
|
-
concept_code = concept_code + 1
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if __name__ == '__main__':
|
|
55
|
-
sync_new_concept_data()
|
|
@@ -1,103 +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
|
-
|
|
10
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
11
|
-
import mns_common.utils.data_frame_util as data_frame_util
|
|
12
|
-
import pandas as pd
|
|
13
|
-
from datetime import datetime
|
|
14
|
-
import akshare as ak
|
|
15
|
-
import mns_scheduler.concept.ths.common.ths_concept_sync_common_api as ths_concept_sync_common_api
|
|
16
|
-
|
|
17
|
-
import mns_scheduler.concept.clean.ths_concept_clean_api as ths_concept_clean_api
|
|
18
|
-
import mns_scheduler.concept.common.detaill.ths_concept_detail_api as ths_concept_detail_api
|
|
19
|
-
mongodb_util = MongodbUtil('27017')
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# 与概念接口对比 找出缺失数据和名称不一样的数据
|
|
23
|
-
|
|
24
|
-
def sync_new_ths_concept_by_ak_api():
|
|
25
|
-
stock_board_concept_name_ths_df = ak.stock_board_concept_name_ths()
|
|
26
|
-
stock_board_concept_name_ths_df = stock_board_concept_name_ths_df.rename(columns={"日期": "str_day",
|
|
27
|
-
"概念名称": "concept_name",
|
|
28
|
-
"成分股数量": "numbers",
|
|
29
|
-
"网址": "url",
|
|
30
|
-
"代码": "concept_code",
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
stock_board_concept_name_ths_df['str_day'].fillna(datetime(1970, 1, 1), inplace=True)
|
|
34
|
-
stock_board_concept_name_ths_df.concept_name = stock_board_concept_name_ths_df.concept_name.str.replace('(', '(')
|
|
35
|
-
stock_board_concept_name_ths_df.concept_name = stock_board_concept_name_ths_df.concept_name.str.replace(')', ')')
|
|
36
|
-
|
|
37
|
-
stock_board_concept_name_ths_df['str_day'] = stock_board_concept_name_ths_df['str_day'].apply(
|
|
38
|
-
lambda x: datetime.strftime(x, '%Y-%m-%d'))
|
|
39
|
-
|
|
40
|
-
# 同花顺概念列表
|
|
41
|
-
ths_concept_list_exist = mongodb_util.find_all_data('ths_concept_list')
|
|
42
|
-
|
|
43
|
-
for concept_one in stock_board_concept_name_ths_df.itertuples():
|
|
44
|
-
try:
|
|
45
|
-
exist_concept_df_one = ths_concept_list_exist.loc[
|
|
46
|
-
(ths_concept_list_exist['name'] == concept_one.concept_name)
|
|
47
|
-
| (ths_concept_list_exist['web_concept_code'] == concept_one.concept_code)]
|
|
48
|
-
now_date = datetime.now()
|
|
49
|
-
str_now_time = now_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
50
|
-
str_day = concept_one.str_day
|
|
51
|
-
if data_frame_util.is_empty(exist_concept_df_one):
|
|
52
|
-
concept_code = concept_one.concept_code
|
|
53
|
-
|
|
54
|
-
diff_one = {
|
|
55
|
-
'_id': int(concept_code),
|
|
56
|
-
'symbol': int(concept_code),
|
|
57
|
-
'name': concept_one.concept_name,
|
|
58
|
-
'url': concept_one.url,
|
|
59
|
-
'str_day': str_day,
|
|
60
|
-
'success': True,
|
|
61
|
-
'str_now_time': str_now_time,
|
|
62
|
-
'web_concept_code': int(concept_one.concept_code),
|
|
63
|
-
'web_concept_url': concept_one.url,
|
|
64
|
-
'valid': True
|
|
65
|
-
}
|
|
66
|
-
diff_one_df = pd.DataFrame(diff_one, index=[1])
|
|
67
|
-
mongodb_util.save_mongo(diff_one_df, 'ths_concept_list')
|
|
68
|
-
url = 'http://q.10jqka.com.cn/gn/detail/code/' + str(concept_one.concept_code)
|
|
69
|
-
# 新增概念信息处理
|
|
70
|
-
handle_new_concept_msg(concept_code, concept_one.concept_name, url)
|
|
71
|
-
new_concept_symbol_df = get_concept_detail_info_web(concept_code)
|
|
72
|
-
if new_concept_symbol_df is None or new_concept_symbol_df.shape[0] == 0:
|
|
73
|
-
return None
|
|
74
|
-
new_concept_symbol_df.loc[:, 'way'] = 'index_sync'
|
|
75
|
-
ths_concept_sync_common_api.save_ths_concept_detail(new_concept_symbol_df, concept_one.concept_name,
|
|
76
|
-
str_day,
|
|
77
|
-
str_now_time, concept_code)
|
|
78
|
-
logger.info("新增同花顺新概念:{}", concept_one.concept_name)
|
|
79
|
-
except BaseException as e:
|
|
80
|
-
logger.error("同步概念:{},信息异常:{}", concept_one.concept_name, e)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def handle_new_concept_msg(concept_code, concept_name, url):
|
|
84
|
-
# 推送新概念信息到微信
|
|
85
|
-
ths_concept_sync_common_api.push_msg_to_we_chat_web(concept_code, concept_name,
|
|
86
|
-
url)
|
|
87
|
-
# 更新ths概念信息
|
|
88
|
-
ths_concept_clean_api.update_ths_concept_info()
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
# 获取web端 新增概念详情
|
|
92
|
-
def get_concept_detail_info_web(concept_code):
|
|
93
|
-
new_concept_symbol_list = ths_concept_detail_api.get_ths_concept_detail(concept_code, None)
|
|
94
|
-
if new_concept_symbol_list is None or new_concept_symbol_list.shape[0] == 0:
|
|
95
|
-
return None
|
|
96
|
-
new_concept_symbol_list = new_concept_symbol_list[ths_concept_sync_common_api.order_fields]
|
|
97
|
-
new_concept_symbol_list['_id'] = str(concept_code) + '-' + new_concept_symbol_list['symbol']
|
|
98
|
-
return new_concept_symbol_list
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if __name__ == '__main__':
|
|
102
|
-
# get_concept_detail_info_web(886068)
|
|
103
|
-
sync_new_ths_concept_by_ak_api()
|
|
@@ -1,88 +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.concept.common.detaill.ths_concept_detail_api as ths_concept_detail_api
|
|
9
|
-
import mns_common.api.ths.concept.web.ths_concept_index_web as ths_concept_index_web
|
|
10
|
-
import datetime
|
|
11
|
-
import time
|
|
12
|
-
import mns_common.api.msg.push_msg_api as push_msg_api
|
|
13
|
-
from loguru import logger
|
|
14
|
-
import mns_scheduler.concept.ths.common.ths_concept_sync_common_api as ths_concept_sync_common_api
|
|
15
|
-
import mns_scheduler.concept.clean.ths_concept_clean_api as ths_concept_clean_api
|
|
16
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
17
|
-
|
|
18
|
-
mongodb_util = MongodbUtil('27017')
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# 获取web端 新增概念详情
|
|
22
|
-
def get_concept_detail_info_web(concept_code):
|
|
23
|
-
new_concept_symbol_list = ths_concept_detail_api.get_ths_concept_detail(concept_code, None)
|
|
24
|
-
if new_concept_symbol_list is None or new_concept_symbol_list.shape[0] == 0:
|
|
25
|
-
return None
|
|
26
|
-
new_concept_symbol_list = new_concept_symbol_list[ths_concept_sync_common_api.order_fields]
|
|
27
|
-
new_concept_symbol_list['_id'] = str(concept_code) + '-' + new_concept_symbol_list['symbol']
|
|
28
|
-
return new_concept_symbol_list
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
# web端获取新概念消息推送
|
|
32
|
-
def push_msg_to_we_chat_web(concept_code, concept_name):
|
|
33
|
-
url = 'http://q.10jqka.com.cn/thshy/detail/code/' + str(concept_code)
|
|
34
|
-
msg = "概念代码:" + str(concept_code) + "," + "概念名称:" + concept_name + "," + "url: " + url
|
|
35
|
-
title = "新增同花顺概念:" + str(concept_code) + "-" + concept_name
|
|
36
|
-
push_msg_api.push_msg_to_wechat(title, msg)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
# # 同步同花顺新增概念指数通过web端接口爬取
|
|
40
|
-
def sync_new_concept_data_by_web():
|
|
41
|
-
concept_code = ths_concept_sync_common_api.get_max_concept_code()
|
|
42
|
-
concept_code = concept_code + 1
|
|
43
|
-
|
|
44
|
-
while concept_code < ths_concept_sync_common_api.max_concept_code:
|
|
45
|
-
try:
|
|
46
|
-
now_date = datetime.datetime.now()
|
|
47
|
-
str_day = now_date.strftime('%Y-%m-%d')
|
|
48
|
-
str_now_time = now_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
49
|
-
new_concept_symbol_df = get_concept_detail_info_web(concept_code)
|
|
50
|
-
if new_concept_symbol_df is None or new_concept_symbol_df.shape[0] == 0:
|
|
51
|
-
concept_code = concept_code + 1
|
|
52
|
-
time.sleep(1)
|
|
53
|
-
continue
|
|
54
|
-
time.sleep(2)
|
|
55
|
-
concept_name = ths_concept_index_web.get_concept_name(concept_code)
|
|
56
|
-
concept_name = concept_name.replace('(', '(')
|
|
57
|
-
concept_name = concept_name.replace(')', ')')
|
|
58
|
-
|
|
59
|
-
url = 'http://q.10jqka.com.cn/thshy/detail/code/' + str(concept_code)
|
|
60
|
-
# 推送新概念信息到微信
|
|
61
|
-
handle_new_concept_msg(concept_code, concept_name, url)
|
|
62
|
-
# 保存新概念信息到概念列表
|
|
63
|
-
ths_concept_sync_common_api.save_ths_concept_list(concept_code, concept_name, str_day, str_now_time)
|
|
64
|
-
# 保存新概念详细信息到数据库
|
|
65
|
-
new_concept_symbol_df.loc[:, 'way'] = 'index_sync'
|
|
66
|
-
ths_concept_sync_common_api.save_ths_concept_detail(new_concept_symbol_df, concept_name, str_day,
|
|
67
|
-
str_now_time, concept_code)
|
|
68
|
-
|
|
69
|
-
concept_code = concept_code + 1
|
|
70
|
-
except BaseException as e:
|
|
71
|
-
logger.error("同步新概念异常:{},concept_code:{}", e, concept_code)
|
|
72
|
-
concept_code = concept_code + 1
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def handle_new_concept_msg(concept_code, concept_name, url):
|
|
76
|
-
# 推送新概念信息到微信
|
|
77
|
-
ths_concept_sync_common_api.push_msg_to_we_chat_web(concept_code, concept_name,
|
|
78
|
-
url)
|
|
79
|
-
# 更新ths概念信息
|
|
80
|
-
ths_concept_clean_api.update_ths_concept_info()
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if __name__ == '__main__':
|
|
84
|
-
# code = 886025
|
|
85
|
-
# push_msg_to_we_chat_web(code, name)
|
|
86
|
-
# get_concept_detail_info_web(886026)
|
|
87
|
-
# get_concept_detail_info_web(886035)
|
|
88
|
-
sync_new_concept_data_by_web()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|