mns-scheduler 1.1.3.5__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/self_choose/ths_self_choose_service.py +27 -9
- mns_scheduler/zt/zt_pool/ths_zt_pool_sync_api.py +19 -19
- mns_scheduler/zz_task/data_sync_task.py +1 -1
- {mns_scheduler-1.1.3.5.dist-info → mns_scheduler-1.1.3.9.dist-info}/METADATA +1 -1
- {mns_scheduler-1.1.3.5.dist-info → mns_scheduler-1.1.3.9.dist-info}/RECORD +19 -29
- 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.5.dist-info → mns_scheduler-1.1.3.9.dist-info}/WHEEL +0 -0
- {mns_scheduler-1.1.3.5.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
|
|
@@ -10,7 +10,10 @@ import mns_common.constant.db_name_constant as db_name_constant
|
|
|
10
10
|
from mns_common.db.MongodbUtil import MongodbUtil
|
|
11
11
|
import mns_common.api.ths.zt.ths_stock_zt_pool_api as ths_stock_zt_pool_api
|
|
12
12
|
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
13
|
-
|
|
13
|
+
import mns_common.component.trade_date.trade_date_common_service_api as trade_date_common_service_api
|
|
14
|
+
from datetime import datetime
|
|
15
|
+
import mns_common.utils.data_frame_util as data_frame_util
|
|
16
|
+
from functools import lru_cache
|
|
14
17
|
mongodb_util = MongodbUtil('27017')
|
|
15
18
|
|
|
16
19
|
# 固定的选择
|
|
@@ -20,6 +23,7 @@ fixed_optional_list = ['USDCNH', 'XAUUSD',
|
|
|
20
23
|
'885736', '881124', '886078',
|
|
21
24
|
'881145', '886073', '881160', '885730',
|
|
22
25
|
'886076', '883418', '881169', '885530',
|
|
26
|
+
'510300', '512100',
|
|
23
27
|
'CN0Y',
|
|
24
28
|
'1B0888',
|
|
25
29
|
'1A0001',
|
|
@@ -31,30 +35,43 @@ fixed_optional_list = ['USDCNH', 'XAUUSD',
|
|
|
31
35
|
'HS2083',
|
|
32
36
|
]
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
def
|
|
38
|
+
@lru_cache()
|
|
39
|
+
def get_ths_cookie():
|
|
36
40
|
query = {"type": "ths_cookie"}
|
|
37
41
|
stock_account_info = mongodb_util.find_query_data(db_name_constant.STOCK_ACCOUNT_INFO, query)
|
|
38
42
|
ths_cookie = list(stock_account_info['cookie'])[0]
|
|
43
|
+
return ths_cookie
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def add_fixed_optional():
|
|
47
|
+
ths_cookie = get_ths_cookie()
|
|
39
48
|
for symbol in fixed_optional_list:
|
|
40
49
|
ths_self_choose_api.add_stock_to_account(symbol, ths_cookie)
|
|
41
50
|
|
|
42
51
|
|
|
43
52
|
def delete_all_self_choose_stocks():
|
|
44
|
-
|
|
45
|
-
stock_account_info = mongodb_util.find_query_data(db_name_constant.STOCK_ACCOUNT_INFO, query)
|
|
46
|
-
ths_cookie = list(stock_account_info['cookie'])[0]
|
|
53
|
+
ths_cookie = get_ths_cookie()
|
|
47
54
|
all_self_choose_stock_list = ths_self_choose_api.get_all_self_choose_stock_list(ths_cookie)
|
|
48
55
|
for stock_one in all_self_choose_stock_list.itertuples():
|
|
49
56
|
symbol = stock_one.code
|
|
50
57
|
ths_self_choose_api.del_stock_from_account(symbol, ths_cookie)
|
|
51
58
|
|
|
52
59
|
|
|
60
|
+
def add_self_choose_local():
|
|
61
|
+
now_date = datetime.now()
|
|
62
|
+
str_day = now_date.strftime('%Y-%m-%d')
|
|
63
|
+
last_trade_day = trade_date_common_service_api.get_last_trade_day(str_day)
|
|
64
|
+
query = {"$and": [{"str_day": {"$gte": last_trade_day}}, {"str_day": {"$lte": str_day}}]}
|
|
65
|
+
trade_stocks_df = mongodb_util.find_query_data(db_name_constant.BUY_STOCK_NAME, query)
|
|
66
|
+
ths_cookie = get_ths_cookie()
|
|
67
|
+
if data_frame_util.is_not_empty(trade_stocks_df):
|
|
68
|
+
for stock_one in trade_stocks_df.itertuples():
|
|
69
|
+
ths_self_choose_api.add_stock_to_account(stock_one.symbol, ths_cookie)
|
|
70
|
+
|
|
71
|
+
|
|
53
72
|
# 添加连板到自选
|
|
54
73
|
def add_continue_boards_zt_stocks():
|
|
55
|
-
|
|
56
|
-
stock_account_info = mongodb_util.find_query_data(db_name_constant.STOCK_ACCOUNT_INFO, query)
|
|
57
|
-
ths_cookie = list(stock_account_info['cookie'])[0]
|
|
74
|
+
ths_cookie = get_ths_cookie()
|
|
58
75
|
ths_stock_zt_pool_df = ths_stock_zt_pool_api.get_zt_reason(None)
|
|
59
76
|
ths_stock_zt_pool_df = ths_stock_zt_pool_df.loc[ths_stock_zt_pool_df['connected_boards_numbers'] > 1]
|
|
60
77
|
ths_stock_zt_pool_df = common_service_fun_api.exclude_st_symbol(ths_stock_zt_pool_df)
|
|
@@ -66,6 +83,7 @@ def add_continue_boards_zt_stocks():
|
|
|
66
83
|
# 自选股操作 删除当天自选股 增加新的连板股票 添加固定选择自选
|
|
67
84
|
def self_choose_stock_handle():
|
|
68
85
|
delete_all_self_choose_stocks()
|
|
86
|
+
add_self_choose_local()
|
|
69
87
|
add_continue_boards_zt_stocks()
|
|
70
88
|
add_fixed_optional()
|
|
71
89
|
|
|
@@ -227,22 +227,22 @@ def save_ths_zt_pool(ths_zt_pool_df, str_day):
|
|
|
227
227
|
|
|
228
228
|
|
|
229
229
|
if __name__ == '__main__':
|
|
230
|
-
trade_date = '
|
|
231
|
-
zt_df = ths_zt_pool(trade_date, None)
|
|
232
|
-
save_ths_zt_pool(zt_df, trade_date)
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
230
|
+
# trade_date = '2024-08-01'
|
|
231
|
+
# zt_df = ths_zt_pool(trade_date, None)
|
|
232
|
+
# save_ths_zt_pool(zt_df, trade_date)
|
|
233
|
+
|
|
234
|
+
query = {"$and": [{'_id': {"$gte": '2013-07-04'}}, {'_id': {"$lte": '2015-04-30'}}]}
|
|
235
|
+
# query = {"$and": [{'_id': {"$gte": '2024-07-24'}}, {'_id': {"$lte": '2024-08-01'}}]}
|
|
236
|
+
trade_date_list = mongodb_util.find_query_data('trade_date_list', query)
|
|
237
|
+
trade_date_list = trade_date_list.sort_values(by=['trade_date'], ascending=False)
|
|
238
|
+
for trade_one in trade_date_list.itertuples():
|
|
239
|
+
try:
|
|
240
|
+
trade_date = trade_one.trade_date
|
|
241
|
+
zt_df = ths_zt_pool(trade_date, None)
|
|
242
|
+
|
|
243
|
+
# zt_df = mongodb_util.find_query_data(db_name_constant.THS_ZT_POOL, query={"str_day": trade_date})
|
|
244
|
+
save_ths_zt_pool(zt_df, trade_date)
|
|
245
|
+
logger.info("同步到日期:{}", trade_date)
|
|
246
|
+
time.sleep(2)
|
|
247
|
+
except BaseException as e:
|
|
248
|
+
logger.warning("同步涨停到日期:{},{}", trade_one.trade_date, e)
|
|
@@ -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')
|