mns-scheduler 1.0.3.0__py3-none-any.whl → 1.0.3.2__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.

@@ -0,0 +1,112 @@
1
+ import sys
2
+ import os
3
+
4
+ file_path = os.path.abspath(__file__)
5
+ end = file_path.index('mns') + 17
6
+ project_path = file_path[0:end]
7
+ sys.path.append(project_path)
8
+
9
+ import sys
10
+ import os
11
+
12
+ from mns_common.db.MongodbUtil import MongodbUtil
13
+ import mns_common.constant.db_name_constant as db_name_constant
14
+ import threading
15
+ import pandas as pd
16
+ import mns_common.api.kpl.common.kpl_common_api as kpl_common_api
17
+ import mns_common.utils.data_frame_util as data_frame_util
18
+
19
+ KPL_MINUTE_LIST = ['0930', '0935', '0940', '0945', '0950', '0955',
20
+ '1000', '1005', '1010', '1015', '1020', '1025',
21
+ '1030', '1035', '1040', '1045', '1050', '1055',
22
+ '1100', '1105', '1110', '1115', '1120', '1125',
23
+ '1130',
24
+ '1305', '1310', '1315', '1320', '1325',
25
+ '1330', '1335', '1340', '1345', '1350', '1355',
26
+ '1400', '1405', '1410', '1415', '1420', '1425',
27
+ '1430', '1435', '1440', '1445', '1450', '1455',
28
+ '1500']
29
+
30
+ KPL_MINUTE_BEGIN = "0925"
31
+ KPL_MINUTE_END = "1500"
32
+ file_path = os.path.abspath(__file__)
33
+ end = file_path.index('mns') + 17
34
+ project_path = file_path[0:end]
35
+ sys.path.append(project_path)
36
+
37
+ mongodb_util = MongodbUtil('27017')
38
+ # 定义一个全局锁,用于保护 result 变量的访问
39
+ result_lock = threading.Lock()
40
+ # 初始化 result 变量为一个空的 Pandas DataFrame
41
+ result = pd.DataFrame()
42
+
43
+
44
+ def sync_best_choose_his_index(str_day):
45
+ all_kpl_best_choose_index_df = kpl_common_api \
46
+ .get_plate_index(kpl_common_api.BEST_CHOOSE)
47
+ kpl_best_choose_index_number = all_kpl_best_choose_index_df.shape[0]
48
+ page_max_number = kpl_best_choose_index_number / kpl_common_api.HIS_PAGE_MAX_COUNT
49
+ page_number = 0
50
+ number = 1
51
+ for end_time in KPL_MINUTE_LIST:
52
+ while page_number <= page_max_number:
53
+ index = page_number * kpl_common_api.HIS_PAGE_MAX_COUNT
54
+ kpl_plate_best_index_df = kpl_common_api.get_plate_index_his(index, kpl_common_api.BEST_CHOOSE,
55
+ str_day, KPL_MINUTE_BEGIN,
56
+ end_time)
57
+
58
+ if data_frame_util.is_empty(kpl_plate_best_index_df):
59
+ continue
60
+ kpl_plate_best_index_df['number'] = number
61
+ kpl_plate_best_index_df['str_day'] = str_day
62
+ kpl_plate_best_index_df = kpl_plate_best_index_df[[
63
+ "plate_code",
64
+ "plate_name",
65
+ "heat_score",
66
+ "chg",
67
+ "speed",
68
+ "amount",
69
+ "main_net_inflow",
70
+ "main_inflow_in",
71
+ "main_inflow_out",
72
+ "quantity_ratio",
73
+ "flow_mv",
74
+ "super_order_net",
75
+ "total_mv",
76
+ "last_reason_organ_add",
77
+ "ava_pe_now",
78
+ "ava_pe_next",
79
+ "number",
80
+ "str_day",
81
+
82
+ ]]
83
+ save_kpl_his_index(kpl_plate_best_index_df, str_day, end_time)
84
+ if end_time == KPL_MINUTE_END:
85
+ save_kpl_his_daily(kpl_plate_best_index_df, str_day, end_time)
86
+ page_number = page_number + 1
87
+ # 执行下一个时间段
88
+ page_number = 0
89
+ number = number + 1
90
+
91
+
92
+ def save_kpl_his_index(kpl_plate_best_index_df, str_day, end_time):
93
+ kpl_plate_best_index_df['_id'] = str_day + '-' + end_time + '-' + kpl_plate_best_index_df['plate_code']
94
+ mongodb_util.save_mongo(kpl_plate_best_index_df, db_name_constant.KPL_BEST_CHOOSE_HIS)
95
+
96
+
97
+ def save_kpl_his_daily(kpl_plate_best_index_df, str_day, end_time):
98
+ kpl_plate_best_index_df['_id'] = str_day + '-' + end_time + '-' + kpl_plate_best_index_df['plate_code']
99
+ mongodb_util.save_mongo(kpl_plate_best_index_df, db_name_constant.KPL_BEST_CHOOSE_DAILY)
100
+
101
+
102
+ def sync_all_days():
103
+ query = {"_id": {"$gte": '2022-07-22'}, 'trade_date': {"$lte": "2022-11-21"}}
104
+ trade_date_list = mongodb_util.find_query_data('trade_date_list', query)
105
+ trade_date_list = trade_date_list.sort_values(by=['trade_date'], ascending=False)
106
+ for trade_one in trade_date_list.itertuples():
107
+ sync_best_choose_his_index(trade_one.trade_date)
108
+
109
+
110
+ if __name__ == '__main__':
111
+ sync_all_days()
112
+ # sync_best_choose_his_index('2024-04-19')
@@ -34,6 +34,7 @@ import mns_scheduler.concept.clean.ths_effective_concept_clean_api as ths_effect
34
34
  import mns_scheduler.kpl.selection.total.sync_kpl_best_total_sync_api as sync_kpl_best_total_sync_api
35
35
  import mns_scheduler.company_info.company_info_sync_api as company_info_sync_api
36
36
  import mns_scheduler.ipo.auto_ipo_buy_api as auto_ipo_buy_api
37
+ import mns_scheduler.kpl.selection.index.sync_best_choose_his_index as sync_best_choose_his_index
37
38
 
38
39
 
39
40
  # 同步交易日期任务完成
@@ -272,6 +273,16 @@ def auto_ipo_buy():
272
273
  auto_ipo_buy_api.auto_ipo_buy()
273
274
 
274
275
 
276
+ # 同步开盘啦当日精选指数行情数据
277
+
278
+ def sync_kpl_best_his_quotes():
279
+ now_date = datetime.now()
280
+ str_day = now_date.strftime('%Y-%m-%d')
281
+ if trade_date_common_service_api.is_trade_day(str_day):
282
+ sync_best_choose_his_index.sync_best_choose_his_index(str_day)
283
+ logger.info('同步开盘啦当日精选指数行情数据任务完成')
284
+
285
+
275
286
  # # 定义BlockingScheduler
276
287
  blockingScheduler = BlockingScheduler()
277
288
  # sync_trade_date 同步交易日期
@@ -336,6 +347,9 @@ blockingScheduler.add_job(auto_ipo_buy, 'cron', hour='10', minute='40,50')
336
347
  # 更新开盘啦指数关系
337
348
  blockingScheduler.add_job(update_best_choose_plate_relation, 'cron', hour='09,18', minute='25')
338
349
 
350
+ # 更新开盘啦指数关系
351
+ blockingScheduler.add_job(sync_kpl_best_his_quotes, 'cron', hour='18,22', minute='25')
352
+
339
353
  print('定时任务启动成功')
340
354
  blockingScheduler.start()
341
355
 
@@ -1,4 +1,4 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mns-scheduler
3
- Version: 1.0.3.0
3
+ Version: 1.0.3.2
4
4
 
@@ -41,6 +41,7 @@ mns_scheduler/k_line/sync/daily_week_month_line_sync.py,sha256=SNKkwGoyE1qzds1o-
41
41
  mns_scheduler/kpl/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
42
42
  mns_scheduler/kpl/selection/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
43
43
  mns_scheduler/kpl/selection/index/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
44
+ mns_scheduler/kpl/selection/index/sync_best_choose_his_index.py,sha256=gm9VJlMRUCDh650_pw4Y_WiGrb-xwLuH2vdm-IGjraE,4501
44
45
  mns_scheduler/kpl/selection/index/sync_best_choose_index.py,sha256=-34drqAMsx792DxR8P1A8DrGCM5yIVGsop3UzDNzsPw,8016
45
46
  mns_scheduler/kpl/selection/symbol/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
46
47
  mns_scheduler/kpl/selection/symbol/sync_best_choose_symbol.py,sha256=kUKs0SWCqekhvV0o5A1pDv0Nw4x6VTS-ij0AryzKe8w,4679
@@ -58,9 +59,9 @@ mns_scheduler/zt/today_high_chg_pool_sync_api.py,sha256=G6FXMH7HnvhyMFoE-RszggkB
58
59
  mns_scheduler/zt/zt_five_boards_sync_api.py,sha256=HfjPHKD99fU9c37kSenEX2_qNvFAjQGgy8ERuacSxwk,10916
59
60
  mns_scheduler/zt/zt_pool_sync_api.py,sha256=tzSCnqAelV7MQBZ3KcpOQQHNYnjFnmvoDFcapBpU_NA,7534
60
61
  mns_scheduler/zz_task/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
61
- mns_scheduler/zz_task/data_sync_task.py,sha256=oeEC_bSL8lsmdx3SRFnW_EUfv3HXcpByut4zAszQu3w,13768
62
+ mns_scheduler/zz_task/data_sync_task.py,sha256=TS8V5K9i_ZGZqd4uCINDYvnfwEYDaJnfcV_BhXrwmeI,14367
62
63
  mns_scheduler/zz_task/sync_realtime_quotes_task.py,sha256=DN3bq2XCDZC-PHlbD2NTog48bR44EruIEc2QVGKg7Tk,932
63
- mns_scheduler-1.0.3.0.dist-info/METADATA,sha256=v7UN3md1rRa8LgR_WWNi0lP7udOkmeswwN2dISBSi64,64
64
- mns_scheduler-1.0.3.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
65
- mns_scheduler-1.0.3.0.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
66
- mns_scheduler-1.0.3.0.dist-info/RECORD,,
64
+ mns_scheduler-1.0.3.2.dist-info/METADATA,sha256=Ef6EhoCBL-YFvWW0CNYRmuhBZOCVnr0osgMOZmuhkVg,64
65
+ mns_scheduler-1.0.3.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
66
+ mns_scheduler-1.0.3.2.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
67
+ mns_scheduler-1.0.3.2.dist-info/RECORD,,