mns-scheduler 1.0.1.7__py3-none-any.whl → 1.0.1.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.

@@ -13,7 +13,7 @@ import mns_common.api.ths.ths_stock_api as ths_stock_api
13
13
  import mns_common.api.em.east_money_stock_v2_api as east_money_stock_v2_api
14
14
  import mns_scheduler.company_info.company_constant_data as company_constant_data_api
15
15
  import mns_common.component.common_service_fun_api as common_service_fun_api
16
- import mns_common.component.concept.concept_common_service_api as concept_common_service_api
16
+ import mns_common.component.concept.ths_concept_common_service_api as ths_concept_common_service_api
17
17
  from mns_common.db.MongodbUtil import MongodbUtil
18
18
  import mns_common.api.kpl.symbol.kpl_real_time_quotes_api as kpl_real_time_quotes_api
19
19
  import mns_common.utils.data_frame_util as data_frame_util
@@ -292,7 +292,7 @@ def single_thread_sync_company_info(east_money_stock_info,
292
292
  company_info_type['classification'] = company_one.classification
293
293
  company_info_type['mv_circulation_ratio'] = calculate_circu_ratio(company_one.symbol)
294
294
  # 获取同花顺最新概念
295
- company_info_type = concept_common_service_api.set_ths_concept(company_one.symbol, company_info_type)
295
+ company_info_type = ths_concept_common_service_api.set_ths_concept(company_one.symbol, company_info_type)
296
296
  now_date = datetime.now()
297
297
  str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S')
298
298
  company_info_type['sync_date'] = str_now_date
@@ -46,24 +46,25 @@ def choose_field_choose_first_index():
46
46
 
47
47
 
48
48
  # 多线程分片同步
49
- def multithread_shard_sync_index(data_df, page_number):
49
+ def multithread_shard_sync_index(first_kpl_df, page_number):
50
50
  global result
51
- for stock_one in data_df.itertuples():
51
+ for first_kpl_one in first_kpl_df.itertuples():
52
52
  try:
53
- kpl_best_choose_sub_index_detail = selection_plate_api.best_choose_sub_index(stock_one.plate_code)
53
+ kpl_best_choose_sub_index_detail = selection_plate_api.best_choose_sub_index(first_kpl_one.plate_code)
54
54
  if data_frame_util.is_not_empty(kpl_best_choose_sub_index_detail):
55
55
  # 保存第二级精选指数
56
- sync_best_choose_second_index(kpl_best_choose_sub_index_detail)
56
+ sync_best_choose_second_index(kpl_best_choose_sub_index_detail, first_kpl_one.plate_code)
57
57
  sub_plate_code_list = kpl_best_choose_sub_index_detail.to_string(index=False)
58
58
  # 更新第一级和第二级指数关联关系
59
- update_first_index_sub_index(stock_one.plate_code, sub_plate_code_list)
60
- data_df.loc[data_df['plate_code'] == stock_one.plate_code, "sub_plate_code_list"] = sub_plate_code_list
59
+ update_first_index_sub_index(first_kpl_one.plate_code, sub_plate_code_list)
60
+ first_kpl_df.loc[
61
+ first_kpl_df['plate_code'] == first_kpl_one.plate_code, "sub_plate_code_list"] = sub_plate_code_list
61
62
 
62
63
  except BaseException as e:
63
64
  logger.error("处理一级精选指数异常:{}", e)
64
65
  with result_lock:
65
66
  # 使用锁来保护 result 变量的访问,将每页的数据添加到结果中
66
- result = pd.concat([result, data_df], ignore_index=True)
67
+ result = pd.concat([result, first_kpl_df], ignore_index=True)
67
68
 
68
69
 
69
70
  # 同步第一和第二级别精选指数 更新一级和二级之间的关联关系
@@ -105,12 +106,12 @@ def sync_best_choose_index():
105
106
  if data_frame_util.is_empty(new_data_df):
106
107
  return None
107
108
  # 处理一级指数
108
- handle_new_kpl_index(new_data_df, kpl_constant.FIRST_INDEX)
109
+ handle_new_kpl_index(new_data_df, kpl_constant.FIRST_INDEX, None)
109
110
  return result
110
111
 
111
112
 
112
113
  # 处理新增指数数据
113
- def handle_new_kpl_index(new_data_df, index_class):
114
+ def handle_new_kpl_index(new_data_df, index_class, first_plate_code):
114
115
  for new_data_one in new_data_df.itertuples():
115
116
  try:
116
117
  concept_code = new_data_one.plate_code
@@ -125,11 +126,16 @@ def handle_new_kpl_index(new_data_df, index_class):
125
126
  now_date = datetime.now()
126
127
  str_day = now_date.strftime('%Y-%m-%d')
127
128
  str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S')
129
+ if first_plate_code is not None:
130
+ new_data_df['first_plate_code'] = first_plate_code
131
+ else:
132
+ new_data_df['first_plate_code'] = new_data_one.plate_code
133
+
128
134
  new_data_df['create_day'] = str_day
129
135
  new_data_df['create_time'] = str_now_date
130
136
  new_data_df.loc[:, "create_day"] = str_day
131
137
  new_data_df.loc[:, "create_time"] = str_now_date
132
- new_data_df.loc[:, "valid"] = False
138
+ new_data_df.loc[:, "valid"] = True
133
139
  new_data_df = new_data_df[["_id",
134
140
  "plate_code",
135
141
  "plate_name",
@@ -138,11 +144,13 @@ def handle_new_kpl_index(new_data_df, index_class):
138
144
  "sync_str_day",
139
145
  "sync_str_time",
140
146
  "create_day",
141
- "create_time"]]
147
+ "create_time",
148
+ "first_plate_code",
149
+ "valid"]]
142
150
  mongodb_util.insert_mongo(new_data_df, 'kpl_best_choose_index')
143
151
 
144
152
 
145
- # 更新第一级精选指数 次级指数
153
+ # 更新第一级精选指数 次级指数关系
146
154
  def update_first_index_sub_index(first_plate_code, sub_plate_code_list):
147
155
  now_date = datetime.now()
148
156
  str_day = now_date.strftime('%Y-%m-%d')
@@ -155,7 +163,7 @@ def update_first_index_sub_index(first_plate_code, sub_plate_code_list):
155
163
 
156
164
 
157
165
  # 同步二级精选指数
158
- def sync_best_choose_second_index(kpl_best_choose_sub_index_detail):
166
+ def sync_best_choose_second_index(kpl_best_choose_sub_index_detail, first_plate_code):
159
167
  kpl_best_choose_sub_index_detail['_id'] = kpl_best_choose_sub_index_detail['plate_code']
160
168
  kpl_best_choose_sub_index_detail['index_class'] = kpl_constant.SUB_INDEX
161
169
  now_date = datetime.now()
@@ -177,4 +185,4 @@ def sync_best_choose_second_index(kpl_best_choose_sub_index_detail):
177
185
  if data_frame_util.is_empty(new_data_df):
178
186
  return None
179
187
 
180
- handle_new_kpl_index(new_data_df, kpl_constant.SUB_INDEX)
188
+ handle_new_kpl_index(new_data_df, kpl_constant.SUB_INDEX, first_plate_code)
@@ -1,14 +1,15 @@
1
1
  import sys
2
2
  import os
3
-
3
+ import mns_common.component.concept.kpl_concept_common_service_api as kpl_concept_common_service_api
4
4
  import mns_common.api.kpl.selection.kpl_selection_plate_api as selection_plate_api
5
5
  from mns_common.db.MongodbUtil import MongodbUtil
6
6
  from loguru import logger
7
- import mns_common.api.kpl.constant.kpl_constant as kpl_constant
8
7
  import mns_common.utils.data_frame_util as data_frame_util
9
8
  import mns_scheduler.kpl.selection.index.sync_best_choose_index as sync_best_choose_first_index
10
9
  import mns_scheduler.kpl.selection.symbol.sync_best_choose_symbol as sync_best_choose_symbol
11
10
  import threading
11
+ import mns_common.constant.db_name_constant as db_name_constant
12
+ import mns_common.api.kpl.constant.kpl_constant as kpl_constant
12
13
 
13
14
  file_path = os.path.abspath(__file__)
14
15
  end = file_path.index('mns') + 17
@@ -81,6 +82,61 @@ def sync_all_plate_info():
81
82
  logger.info("同步开票啦精选概念股票组成完成")
82
83
 
83
84
 
85
+ # 更新一二级关系
86
+ def update_best_choose_plate_relation():
87
+ first_index_df = sync_best_choose_first_index.choose_field_choose_first_index()
88
+ kpl_all_concept_df = kpl_concept_common_service_api.get_kpl_all_concept()
89
+ for first_index_df_one in first_index_df.itertuples():
90
+ try:
91
+ kpl_best_choose_sub_index_detail = selection_plate_api.best_choose_sub_index(first_index_df_one.plate_code)
92
+ # 更新指数级别
93
+
94
+ kpl_one_concept_df_first = kpl_all_concept_df.loc[
95
+ kpl_all_concept_df['plate_code'] == first_index_df_one.plate_code]
96
+
97
+ if data_frame_util.is_not_empty(kpl_one_concept_df_first):
98
+ kpl_one_concept_df_first_exist = kpl_one_concept_df_first.loc[
99
+ kpl_one_concept_df_first['index_class'] == kpl_constant.FIRST_INDEX]
100
+ if data_frame_util.is_not_empty(kpl_one_concept_df_first_exist):
101
+ update_query = {"plate_code": first_index_df_one.plate_code}
102
+ new_values = {"$set": {"first_plate_code": first_index_df_one.plate_code,
103
+ "heat_score": first_index_df_one.heat_score,
104
+ "plate_name": first_index_df_one.plate_name,
105
+ "first_plate_name": first_index_df_one.plate_name}}
106
+ mongodb_util.update_many(update_query, new_values, db_name_constant.KPL_BEST_CHOOSE_INDEX)
107
+ else:
108
+ update_query = {"plate_code": first_index_df_one.plate_code}
109
+ new_values = {"$set": {
110
+ "first_plate_code": first_index_df_one.plate_code,
111
+ "first_plate_name": first_index_df_one.plate_name,
112
+ "plate_name": first_index_df_one.plate_name,
113
+ "index_class": kpl_constant.SUB_INDEX}}
114
+ mongodb_util.update_many(update_query, new_values, db_name_constant.KPL_BEST_CHOOSE_INDEX)
115
+
116
+ if data_frame_util.is_not_empty(kpl_best_choose_sub_index_detail):
117
+ update_query = {"plate_code": {"$in": list(kpl_best_choose_sub_index_detail['plate_code'])}}
118
+ new_values = {"$set": {"first_plate_code": first_index_df_one.plate_code,
119
+ "first_plate_name": first_index_df_one.plate_name}}
120
+ mongodb_util.update_many(update_query, new_values, db_name_constant.KPL_BEST_CHOOSE_INDEX)
121
+ except BaseException as e:
122
+ logger.error("同步开盘啦精选板块指数关系异常:{},{}", first_index_df_one.plate_code, e)
123
+ # 更新二级指数关系
124
+ update_sub_index_relation(first_index_df, kpl_all_concept_df)
125
+
126
+
127
+ def update_sub_index_relation(first_index_df, kpl_all_concept_df):
128
+ kpl_sub_concept_df_exist = kpl_all_concept_df.loc[
129
+ kpl_all_concept_df['index_class'] == kpl_constant.SUB_INDEX]
130
+ kpl_sub_concept_df_change = first_index_df.loc[
131
+ first_index_df['plate_code'].isin(list(kpl_sub_concept_df_exist['plate_code']))]
132
+ if data_frame_util.is_not_empty(kpl_sub_concept_df_change):
133
+ update_query = {"plate_code": {"$in": list(kpl_sub_concept_df_change['plate_code'])}}
134
+ new_values = {"$set": {"index_class": kpl_constant.FIRST_INDEX}}
135
+ mongodb_util.update_many(update_query, new_values, db_name_constant.KPL_BEST_CHOOSE_INDEX)
136
+
137
+
84
138
  if __name__ == '__main__':
139
+ update_best_choose_plate_relation()
140
+
85
141
  # 同步第一和第二级别精选指数
86
142
  sync_all_plate_info()
@@ -9,7 +9,7 @@ import pandas as pd
9
9
  import mns_common.api.akshare.stock_zt_pool_api as stock_zt_pool_api
10
10
  import mns_common.api.ths.ths_stock_zt_pool_api as ths_stock_zt_pool_api
11
11
  import mns_common.utils.date_handle_util as date_handle_util
12
- import mns_common.component.concept.concept_common_service_api as concept_common_service_api
12
+ import mns_common.component.concept.ths_concept_common_service_api as ths_concept_common_service_api
13
13
  from mns_common.db.MongodbUtil import MongodbUtil
14
14
  import mns_common.component.company.company_common_service_api as company_common_service_api
15
15
  from loguru import logger
@@ -62,7 +62,7 @@ def save_zt_info(str_day):
62
62
 
63
63
  for stock_one in stock_em_zt_pool_df_data.itertuples():
64
64
  try:
65
- stock_em_zt_pool_df_data = concept_common_service_api.set_last_ths_concept(stock_one.symbol,
65
+ stock_em_zt_pool_df_data = ths_concept_common_service_api.set_last_ths_concept(stock_one.symbol,
66
66
  stock_em_zt_pool_df_data,
67
67
  str_day)
68
68
  ths_zt_pool_one_df = ths_zt_pool_df_data.loc[ths_zt_pool_df_data['symbol'] == stock_one.symbol]
@@ -242,6 +242,12 @@ def sync_all_kpl_plate_info():
242
242
  sync_new_concept_data_by_web()
243
243
 
244
244
 
245
+ # 更新一二级关系
246
+ def update_best_choose_plate_relation():
247
+ logger.info('同步开盘啦精选指数关系')
248
+ sync_kpl_best_total_sync_api.update_best_choose_plate_relation()
249
+
250
+
245
251
  # 同步新概念通过web端
246
252
  def sync_new_concept_data_web():
247
253
  # 同步同花顺新增概念指数通过web端接口爬取
@@ -327,6 +333,9 @@ blockingScheduler.add_job(sync_stock_zt_pool, 'cron', hour='15,19,21,23', minute
327
333
  # 自动打新 打新中签高时间段 10:30-11:30
328
334
  blockingScheduler.add_job(auto_ipo_buy, 'cron', hour='10', minute='40,50')
329
335
 
336
+ # 更新开盘啦指数关系
337
+ blockingScheduler.add_job(update_best_choose_plate_relation, 'cron', hour='09,18', minute='25')
338
+
330
339
  print('定时任务启动成功')
331
340
  blockingScheduler.start()
332
341
 
@@ -1,4 +1,4 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mns-scheduler
3
- Version: 1.0.1.7
3
+ Version: 1.0.1.9
4
4
 
@@ -3,7 +3,7 @@ mns_scheduler/big_deal/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9
3
3
  mns_scheduler/big_deal/ths_big_deal_sync.py,sha256=wezGJWFRnKYBaPP9PVXLqMbHENOXgvJtw3HSGCSlX5c,4555
4
4
  mns_scheduler/company_info/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
5
5
  mns_scheduler/company_info/company_constant_data.py,sha256=LwyBWLoErAUPXss68ebVj3Qe8GouvKDFtyHrWuMd-qU,15238
6
- mns_scheduler/company_info/company_info_sync_api.py,sha256=yGOszsg7ivAypzyg-N6yBOeJeNekfHNm260yUOzem_M,20673
6
+ mns_scheduler/company_info/company_info_sync_api.py,sha256=uXfIVclp4zTQz_b4MbvZB5lqmoUeURlzH18B13RPC50,20685
7
7
  mns_scheduler/concept/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
8
8
  mns_scheduler/concept/clean/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
9
9
  mns_scheduler/concept/clean/ths_effective_concept_clean_api.py,sha256=2CzG7zvA2mydjIvnckMWz8eR_tmdfOl8k-I0eov9fy4,2440
@@ -40,11 +40,11 @@ mns_scheduler/k_line/sync/daily_week_month_line_sync.py,sha256=SNKkwGoyE1qzds1o-
40
40
  mns_scheduler/kpl/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
41
41
  mns_scheduler/kpl/selection/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
42
42
  mns_scheduler/kpl/selection/index/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
43
- mns_scheduler/kpl/selection/index/sync_best_choose_index.py,sha256=II9uTG883zQYfF0Tow9xQ-9IXmA4VPBZjyZXcSBePKA,7591
43
+ mns_scheduler/kpl/selection/index/sync_best_choose_index.py,sha256=-34drqAMsx792DxR8P1A8DrGCM5yIVGsop3UzDNzsPw,8016
44
44
  mns_scheduler/kpl/selection/symbol/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
45
45
  mns_scheduler/kpl/selection/symbol/sync_best_choose_symbol.py,sha256=kUKs0SWCqekhvV0o5A1pDv0Nw4x6VTS-ij0AryzKe8w,4679
46
46
  mns_scheduler/kpl/selection/total/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
47
- mns_scheduler/kpl/selection/total/sync_kpl_best_total_sync_api.py,sha256=IRWjVETR-a5P3UdVHj3MDSgJJnmo7vG8OE8K3lpWDWk,3859
47
+ mns_scheduler/kpl/selection/total/sync_kpl_best_total_sync_api.py,sha256=B03DKH6IcmFK_OmXrbnjrxSOSjRrnYXrSUXOw9ft-HM,7527
48
48
  mns_scheduler/real_time/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
49
49
  mns_scheduler/real_time/realtime_quotes_now_create_db_index.py,sha256=qQCjcsG3WYgn3zemS45Ms0AHtbkCwlSVPPCntxVvK8Q,1066
50
50
  mns_scheduler/real_time/realtime_quotes_now_sync.py,sha256=YldmBI19eKNEL_yTZvBrWewL33B5G6a8cuEn7YQMV9w,8850
@@ -55,11 +55,11 @@ mns_scheduler/zt/export_open_data_to_excel.py,sha256=haOSmh-aXnScp58u0mLE_QvcWII
55
55
  mns_scheduler/zt/realtime_quotes_now_zt_kc_sync.py,sha256=9xTMcHBoSotN8ZvGOBkh_E8BDfPbwsCoLzX3XZMV0-s,17269
56
56
  mns_scheduler/zt/today_high_chg_pool_sync_api.py,sha256=G6FXMH7HnvhyMFoE-RszggkByEp4bThyebt_9KiSX7c,21283
57
57
  mns_scheduler/zt/zt_five_boards_sync_api.py,sha256=HfjPHKD99fU9c37kSenEX2_qNvFAjQGgy8ERuacSxwk,10916
58
- mns_scheduler/zt/zt_pool_sync_api.py,sha256=AhWYrpHzO3KOKecyGqQFvopYd2KFmf1ykRiv2R9Pjo4,7490
58
+ mns_scheduler/zt/zt_pool_sync_api.py,sha256=_EUlc_22fRtAGp--wc0d6UFmO5uKqoWbe09gNnSU_aI,7502
59
59
  mns_scheduler/zz_task/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
60
- mns_scheduler/zz_task/data_sync_task.py,sha256=SgVpGmlBOZJS1d0KMZanzbXOO-lT1cmg9JsNj-1H1ug,13443
60
+ mns_scheduler/zz_task/data_sync_task.py,sha256=oeEC_bSL8lsmdx3SRFnW_EUfv3HXcpByut4zAszQu3w,13768
61
61
  mns_scheduler/zz_task/sync_realtime_quotes_task.py,sha256=DN3bq2XCDZC-PHlbD2NTog48bR44EruIEc2QVGKg7Tk,932
62
- mns_scheduler-1.0.1.7.dist-info/METADATA,sha256=fG-QpUmDiN_620Ip75cxINvZlctFJ56NL8_51PaMSfY,64
63
- mns_scheduler-1.0.1.7.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
64
- mns_scheduler-1.0.1.7.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
65
- mns_scheduler-1.0.1.7.dist-info/RECORD,,
62
+ mns_scheduler-1.0.1.9.dist-info/METADATA,sha256=74obxgGjTYzMdH_qMqCKRc4GwZaUK-3l9zemBoIoxqM,64
63
+ mns_scheduler-1.0.1.9.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
64
+ mns_scheduler-1.0.1.9.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
65
+ mns_scheduler-1.0.1.9.dist-info/RECORD,,