mns-scheduler 1.1.1.4__py3-none-any.whl → 1.1.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mns-scheduler might be problematic. Click here for more details.

@@ -14,7 +14,7 @@ mongodb_util = MongodbUtil('27017')
14
14
 
15
15
  def get_fix_symbol_industry():
16
16
  return pd.DataFrame([['688480', '赛恩斯', '760103', '环境治理'],
17
- ['000032', '深桑达A', '730200', '通信网络设备及器件'],
17
+ ['000032', '深桑达A', '730204', '通信网络设备及器件'],
18
18
  ['688480', '赛恩斯', '640704', '自动化设备'],
19
19
  ['603260', '合盛硅业', '220316', '有机硅'],
20
20
  ['300559', '佳发教育', '461102', '培训教育'],
@@ -34,13 +34,12 @@ def get_real_time_max_number():
34
34
  def check_max_number():
35
35
  now_max_number = get_real_time_max_number()
36
36
  last_minute_number = cache_service.get_cache(MAX_NUMBER_KEY)
37
+ cache_service.set_cache(MAX_NUMBER_KEY, now_max_number)
37
38
  if last_minute_number is None:
38
- cache_service.set_cache(MAX_NUMBER_KEY, now_max_number)
39
39
  return True
40
40
  elif now_max_number == last_minute_number:
41
41
  return False
42
42
  else:
43
- cache_service.set_cache(MAX_NUMBER_KEY, now_max_number)
44
43
  return True
45
44
 
46
45
 
@@ -24,14 +24,15 @@ choose_field = ["_id",
24
24
  "symbol",
25
25
  "name",
26
26
  "industry",
27
- "now_price",
28
27
  "chg",
29
28
  "quantity_ratio",
30
29
  "amount_level",
30
+ 'sum_main_inflow_disk',
31
31
  "disk_ratio",
32
+ "now_price",
32
33
  "real_disk_diff_amount_exchange",
33
34
  'max_real_main_inflow_multiple',
34
- 'sum_main_inflow_disk',
35
+
35
36
  "real_main_inflow_multiple",
36
37
  "real_super_main_inflow_multiple",
37
38
  "super_main_inflow_multiple",
@@ -73,7 +74,7 @@ choose_field = ["_id",
73
74
  def sync_high_chg_real_time_quotes(str_day):
74
75
  mongo = db_util.get_db(str_day)
75
76
 
76
- realtime_quotes_db_name = db_name_constant.REAL_TIME_QUOTES_NOW + "_" + str_day
77
+ realtime_quotes_db_name = db_name_constant.REAL_TIME_QUOTES_NOW + "_" + str_day
77
78
  high_chg_list = get_high_chg_symbol(str_day)
78
79
  if high_chg_list is None or len(high_chg_list) == 0:
79
80
  return
@@ -92,7 +93,7 @@ def sync_high_chg_real_time_quotes(str_day):
92
93
  real_time_quotes_now_high_chg_all)
93
94
 
94
95
  real_time_quotes_now_high_chg_all['amount_level'] = round(
95
- (real_time_quotes_now_high_chg_all['amount'] / common_service_fun_api.HUNDRED_MILLION), 2) * 10
96
+ (real_time_quotes_now_high_chg_all['amount'] / common_service_fun_api.HUNDRED_MILLION), 2)
96
97
  real_time_quotes_now_high_chg_all['flow_mv_sp'] = round(
97
98
  (real_time_quotes_now_high_chg_all['flow_mv'] / common_service_fun_api.HUNDRED_MILLION), 2)
98
99
  real_time_quotes_now_high_chg_all['total_mv_sp'] = round(
@@ -141,4 +142,4 @@ def save_realtime_quotes_now_zt_data(realtime_quotes_now_zt, str_day, symbol):
141
142
 
142
143
 
143
144
  if __name__ == '__main__':
144
- sync_high_chg_real_time_quotes('2024-06-21')
145
+ sync_high_chg_real_time_quotes('2024-06-24')
@@ -62,7 +62,6 @@ realtime_quotes_now_zt_new_kc_open_field = ['_id',
62
62
  'real_disk_diff_amount_exchange', 'no_open_data']
63
63
 
64
64
 
65
-
66
65
  def sync_all_kc_zt_data(str_day, symbols):
67
66
  if symbols is None:
68
67
  query_daily = {'date': date_handle_util.no_slash_date(str_day),
@@ -173,6 +172,8 @@ def one_symbol_day_open_data(realtime_quotes_now_kc, kc_one, str_day):
173
172
  realtime_quotes_now_zt_new_kc_open_copy.copy(),
174
173
  str_now_date,
175
174
  1)
175
+ if data_frame_util.is_empty(realtime_quotes_now_zt_new_kc_open_copy):
176
+ return None
176
177
  realtime_quotes_now_zt_new_kc_open_copy = realtime_quotes_now_zt_new_kc_open_copy[
177
178
  realtime_quotes_now_zt_new_kc_open_field]
178
179
 
@@ -8,11 +8,9 @@ sys.path.append(project_path)
8
8
  import mns_scheduler.zt.open_data.kcx_high_chg_open_data_sync as kcx_high_chg_open_data_sync
9
9
  from loguru import logger
10
10
 
11
-
12
11
  from mns_common.db.MongodbUtil import MongodbUtil
13
12
  import mns_common.utils.data_frame_util as data_frame_util
14
13
 
15
-
16
14
  mongodb_util = MongodbUtil('27017')
17
15
  mongodb_util_21019 = MongodbUtil('27019')
18
16
  realtime_quotes_now_zt_new_kc_open_field = ['_id',
@@ -53,6 +51,7 @@ realtime_quotes_now_zt_new_kc_open_field = ['_id',
53
51
  'real_super_main_inflow_multiple', 'real_flow_mv',
54
52
  'real_disk_diff_amount_exchange', 'no_open_data']
55
53
 
54
+
56
55
  # query = {'$and': [{"_id": {'$lte': str_end}}, {"_id": {'$gte': '2022-04-25'}}]}
57
56
  def sync_all_high_chg_data(str_end):
58
57
  query = {'$and': [{"_id": {'$lte': str_end}}, {"_id": {'$gte': '2024-03-01'}}]}
@@ -84,7 +83,7 @@ def fix_miss_data(str_end):
84
83
 
85
84
 
86
85
  if __name__ == '__main__':
87
- kcx_high_chg_open_data_sync.sync_all_kc_zt_data('2024-06-21', None)
86
+ kcx_high_chg_open_data_sync.sync_all_kc_zt_data('2024-06-24', None)
88
87
  # sync_all_kc_zt_data('2023-08-16')
89
88
  # sync_all_kc_zt_data('2023-07-07')
90
89
  # realtime_quotes_now_zt_new_kc_open_sync()
@@ -36,4 +36,4 @@ def sync_his_zt_pool_data(begin_day, end_day):
36
36
 
37
37
 
38
38
  if __name__ == '__main__':
39
- sync_high_chg_pool_service.sync_stock_high_chg_pool_list('2024-06-19', None)
39
+ sync_high_chg_pool_service.sync_stock_high_chg_pool_list('2024-06-24', None)
@@ -1,4 +1,4 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mns-scheduler
3
- Version: 1.1.1.4
3
+ Version: 1.1.1.5
4
4
 
@@ -15,7 +15,7 @@ mns_scheduler/company_info/base/sync_company_base_info_api.py,sha256=zI6CaQ7LuXe
15
15
  mns_scheduler/company_info/clean/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
16
16
  mns_scheduler/company_info/clean/company_info_clean_api.py,sha256=zMPbIz91l8DpIGc7ljG6dEdD5QXjir2a0wWHGt2Ca78,4805
17
17
  mns_scheduler/company_info/constant/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
18
- mns_scheduler/company_info/constant/company_constant_data.py,sha256=Fr_R7Hr2vlFzwywKqPQueCV4QVZOScfhftLecyzpqEA,15886
18
+ mns_scheduler/company_info/constant/company_constant_data.py,sha256=9ZnI4_yPp9ylyX9_yzLX7SgcpTbJM46pdDtfbAoWXqQ,15886
19
19
  mns_scheduler/company_info/de_list_stock/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
20
20
  mns_scheduler/company_info/de_list_stock/de_list_stock_service.py,sha256=GCp6hlvO-SuH1oIpEsYZwEnGUOa6fXb2D7CqAUYXKQA,1993
21
21
  mns_scheduler/concept/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
@@ -37,7 +37,7 @@ mns_scheduler/concept/ths/update_concept_info/sync_one_symbol_all_concepts_api.p
37
37
  mns_scheduler/db/__init__.py,sha256=1dpcEuWKyblKcpyOss0Iyy_ZS4ZJsh8x8GoMAv3TiS8,193
38
38
  mns_scheduler/db/col_move_service.py,sha256=VSGJROyErfytjGzSlhyTdH6z3ayHG5nFfJk8qjdpJhE,4057
39
39
  mns_scheduler/db/db_status.py,sha256=e5eW5ZSm5J7tHvmxxhFmFdbZb2_oB_SAcdcFqc4KDmw,733
40
- mns_scheduler/db/real_time_task_check.py,sha256=15CBBc87HU0ZrNEVYrX_auJWmmzsGsl3OMl6rXdCH8o,3010
40
+ mns_scheduler/db/real_time_task_check.py,sha256=XkoPLJt13bEP3ymf3EiYCogx9p1dZklUNH3LNVE-8Pg,2941
41
41
  mns_scheduler/dt/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
42
42
  mns_scheduler/dt/stock_dt_pool_sync.py,sha256=5ivRUOnFtOapZniwTbujf1lVq3y4btm2Cmd5R6JJAVo,3466
43
43
  mns_scheduler/finance/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
@@ -82,9 +82,6 @@ mns_scheduler/lhb/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg
82
82
  mns_scheduler/lhb/stock_lhb_sync_service.py,sha256=NIW0jX23N1dCEdsrKwt7MyzXSfhU7vXNpIO04dUSZwc,641
83
83
  mns_scheduler/open/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
84
84
  mns_scheduler/open/sync_one_day_open_data_to_db_service.py,sha256=wlwJtCeMoTrrqlTukq4A6RUrvj5RBNasa7kDpSt6QJc,2659
85
- mns_scheduler/real_time/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
86
- mns_scheduler/real_time/realtime_quotes_now_create_db_index.py,sha256=ytGtRVGc6Alf9F2m4EUvjcSq8LlGYg8acVQdJO_lMoI,1076
87
- mns_scheduler/real_time/realtime_quotes_now_sync.py,sha256=tXZUU9SLwM80YQv473i-uVw1w_lClTMFaO-uo4jERTI,9669
88
85
  mns_scheduler/risk/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
89
86
  mns_scheduler/risk/financial_report_risk_check_api.py,sha256=BPkMZ7aINfOFPswIV115kFUhyt0j7dLyA755QEDl-So,1648
90
87
  mns_scheduler/risk/compliance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -115,19 +112,18 @@ mns_scheduler/zt/export/__init__.py,sha256=Tyvi_iQlv3jz59EdH67Mycnt9CSixcWPQoJwu
115
112
  mns_scheduler/zt/export/export_kcx_high_chg_open_data_to_excel.py,sha256=9LK1s2BCzsXLMAYMmiMAZsmz8iha88JVcp6SKqIW37s,4063
116
113
  mns_scheduler/zt/high_chg/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
117
114
  mns_scheduler/zt/high_chg/sync_high_chg_pool_service.py,sha256=7hRfzQFhMSwdbzIg57JmX82DEW3Ig5hwZTzS_SPO0sg,13347
118
- mns_scheduler/zt/high_chg/sync_high_chg_real_time_quotes_service.py,sha256=3HZvOuBiR_qzWdVvmurnyWK773axXn10w47CSuy22XI,6355
115
+ mns_scheduler/zt/high_chg/sync_high_chg_real_time_quotes_service.py,sha256=L69lsirRXaiddZ7GKSWbEABQcwMOeCOm33dlVKK3-oQ,6351
119
116
  mns_scheduler/zt/open_data/__init__.py,sha256=Tyvi_iQlv3jz59EdH67Mycnt9CSixcWPQoJwu55bOq0,165
120
- mns_scheduler/zt/open_data/kcx_high_chg_open_data_sync.py,sha256=P6X3HPw3WhzuDOrvniKAxz4sK4HRA7xh_0nVtRpxAW4,11522
117
+ mns_scheduler/zt/open_data/kcx_high_chg_open_data_sync.py,sha256=wZiqOre2UK9CxIR7dDk11DmqRY3n2_eE2pe0JfmMcjk,11616
121
118
  mns_scheduler/zt/script/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
122
- mns_scheduler/zt/script/kcx_high_chg_open_his_data_handle.py,sha256=FIm1A-4pnVaVLBiSIUxveIEuOOI5I-NcQQrWRSPcDQg,5573
123
- mns_scheduler/zt/script/sync_high_chg_pool_his_data.py,sha256=yK38xJtG8jvtzaFflLLtMWxQd1HN9y0DR9edl6DC0XE,1685
119
+ mns_scheduler/zt/script/kcx_high_chg_open_his_data_handle.py,sha256=mtILXQin6CrnqXbep6YV87OTLFHFEb3ta6mxrh3mcgE,5571
120
+ mns_scheduler/zt/script/sync_high_chg_pool_his_data.py,sha256=R4MmBqmYspaHsnyqJc0FkdmD4lCGCMfHZQMs2dsipIw,1685
124
121
  mns_scheduler/zt/zt_pool/__init__.py,sha256=Tyvi_iQlv3jz59EdH67Mycnt9CSixcWPQoJwu55bOq0,165
125
122
  mns_scheduler/zt/zt_pool/em_zt_pool_sync_api.py,sha256=YV0-9m6Rpy_KNDch6Esj83F4kt1fTqF-Y0wMZBPSEGg,7642
126
123
  mns_scheduler/zt/zt_pool/ths_zt_pool_sync_api.py,sha256=Xx_R_WujCtV_p4k1eKaYPshQVpErtegub2OyIOBxzUw,10338
127
124
  mns_scheduler/zz_task/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
128
125
  mns_scheduler/zz_task/data_sync_task.py,sha256=bILPyMR0LEtCxdjEonplUOnGCYHhI65pFrzQWdf8WqI,18050
129
- mns_scheduler/zz_task/sync_realtime_quotes_task.py,sha256=AMTdeyZ-eGaVpZjggKTPr818FFYkRihY3nAvH5Je2A0,941
130
- mns_scheduler-1.1.1.4.dist-info/METADATA,sha256=DahZJs3WNLoRYp-nPKWIprwV9JA342oOBUD6mUNJL1E,64
131
- mns_scheduler-1.1.1.4.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
132
- mns_scheduler-1.1.1.4.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
133
- mns_scheduler-1.1.1.4.dist-info/RECORD,,
126
+ mns_scheduler-1.1.1.5.dist-info/METADATA,sha256=Wa2F_UKwv1z80UXKs8NMibLKE1Tf9s2GUHFR04a6p88,64
127
+ mns_scheduler-1.1.1.5.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
128
+ mns_scheduler-1.1.1.5.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
129
+ mns_scheduler-1.1.1.5.dist-info/RECORD,,
@@ -1,7 +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)
@@ -1,29 +0,0 @@
1
- import sys
2
- import os
3
-
4
- file_path = os.path.abspath(__file__)
5
- end = file_path.index('mns') + 17
6
- project_path = file_path[0:end]
7
- sys.path.append(project_path)
8
- from loguru import logger
9
- from mns_common.db.MongodbUtil import MongodbUtil
10
-
11
- mongodb_util = MongodbUtil('27017')
12
-
13
-
14
- def create_db_index(str_day):
15
- query_trade_day = {'_id': str_day}
16
- is_trade_day = mongodb_util.exist_data_query('trade_date_list', query_trade_day)
17
- if is_trade_day:
18
- try:
19
- mongodb_util.create_index('realtime_quotes_now_' + str_day, [("symbol", 1)])
20
- mongodb_util.create_index('realtime_quotes_now_' + str_day, [("number", 1)])
21
- mongodb_util.create_index('realtime_quotes_now_' + str_day, [("symbol", 1), ("number", 1)])
22
- mongodb_util.create_index('realtime_quotes_now_' + str_day, [("str_now_date", 1)])
23
- logger.info("创建索引成功:{}", str_day)
24
- except BaseException as e:
25
- logger.warning("创建索引异常:{}", e)
26
-
27
-
28
- if __name__ == '__main__':
29
- create_db_index("2023-08-11")
@@ -1,232 +0,0 @@
1
- import sys
2
- import os
3
-
4
- file_path = os.path.abspath(__file__)
5
- end = file_path.index('mns') + 17
6
- project_path = file_path[0:end]
7
- sys.path.append(project_path)
8
-
9
- import datetime
10
- import mns_common.utils.date_handle_util as date_util
11
- import mns_common.component.company.company_common_service_api as company_common_service_api
12
- from loguru import logger
13
- import mns_common.api.em.east_money_stock_api as east_money_stock_api
14
- import time
15
- import mns_common.component.common_service_fun_api as common_service_fun_api
16
- import mns_common.component.data.data_init_api as data_init_api
17
- import mns_scheduler.real_time.realtime_quotes_now_create_db_index as realtime_quotes_now_create_db_index_api
18
- import pandas as pd
19
- from mns_common.db.MongodbUtil import MongodbUtil
20
- from mns_common.utils.async_fun import async_fun
21
- import mns_scheduler.trade.auto_sell_service_api as auto_sell_service_api
22
- import mns_common.constant.db_name_constant as db_name_constant
23
- import warnings
24
-
25
- warnings.filterwarnings("ignore")
26
-
27
- mongodb_util = MongodbUtil('27017')
28
- order = ["_id",
29
- "symbol",
30
- "name",
31
- "industry",
32
- "chg",
33
- "quantity_ratio",
34
- "amount_level",
35
- "real_exchange",
36
- "disk_ratio",
37
- 'real_disk_diff_amount_exchange',
38
- 'max_real_main_inflow_multiple',
39
- 'sum_main_inflow_disk',
40
- "main_inflow_multiple",
41
- 'super_main_inflow_multiple',
42
- 'disk_diff_amount',
43
- "disk_diff_amount_exchange",
44
- "exchange",
45
- "amount",
46
- "today_main_net_inflow",
47
- "today_main_net_inflow_ratio",
48
- "super_large_order_net_inflow",
49
- "super_large_order_net_inflow_ratio",
50
- "large_order_net_inflow",
51
- "large_order_net_inflow_ratio",
52
- "super_main_inflow_multiple",
53
- "up_speed",
54
- "up_speed_05",
55
- "now_price",
56
- "high",
57
- "low",
58
- "open",
59
- "yesterday_price",
60
- "volume",
61
- "total_mv",
62
- "flow_mv",
63
- "list_date",
64
- "wei_bi",
65
- "buy_1_num",
66
- "sell_1_num",
67
- "outer_disk",
68
- "inner_disk",
69
- "average_price",
70
- "classification",
71
- "str_now_date",
72
- "number"]
73
-
74
-
75
- # 实时表移除数据
76
- @async_fun
77
- def remove_real_time_data(number, realtime_quotes_db_name):
78
- if number % 50 == 0:
79
- remove_query = {'number': {"$lte": number - 50}}
80
- mongodb_util.remove_data(remove_query, realtime_quotes_db_name)
81
-
82
-
83
- def remove_real_time_all_data():
84
- remove_query = {}
85
- mongodb_util.remove_data(remove_query, db_name_constant.REAL_TIME_QUOTES_NOW)
86
-
87
-
88
- # 保存实时表数据
89
- def save_real_time_quotes(real_time_quotes, now_date, realtime_quotes_db_name, number):
90
- if 'first_sw_industry' in real_time_quotes.columns:
91
- real_time_quotes.drop(columns=['first_sw_industry'], inplace=True)
92
- if 'second_sw_industry' in real_time_quotes.columns:
93
- real_time_quotes.drop(columns=['second_sw_industry'], inplace=True)
94
- if 'third_sw_industry' in real_time_quotes.columns:
95
- real_time_quotes.drop(columns=['third_sw_industry'], inplace=True)
96
- real_time_quotes.symbol = real_time_quotes.symbol.astype(str)
97
- str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S:%f')
98
- real_time_quotes['_id'] = real_time_quotes['symbol'] + '-' + str_now_date
99
-
100
- try:
101
-
102
- real_time_quotes = real_time_quotes[order]
103
- real_time_quotes['sum_main_inflow_disk'] = round(real_time_quotes['sum_main_inflow_disk'], 2)
104
- mongodb_util.insert_mongo(real_time_quotes, realtime_quotes_db_name)
105
- # 移除现在的数据
106
- remove_real_time_data(number, realtime_quotes_db_name)
107
- except BaseException as e:
108
- logger.error('保存实时数据异常:{}', e)
109
-
110
-
111
- # 保存历史表数据
112
- def save_real_time_quotes_his(real_time_quotes, now_date, realtime_quotes_db_name, number_his):
113
- if 'first_sw_industry' in real_time_quotes.columns:
114
- real_time_quotes.drop(columns=['first_sw_industry'], inplace=True)
115
- if 'second_sw_industry' in real_time_quotes.columns:
116
- real_time_quotes.drop(columns=['second_sw_industry'], inplace=True)
117
- if 'third_sw_industry' in real_time_quotes.columns:
118
- real_time_quotes.drop(columns=['third_sw_industry'], inplace=True)
119
- real_time_quotes.symbol = real_time_quotes.symbol.astype(str)
120
- str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S:%f')
121
- real_time_quotes['_id'] = real_time_quotes['symbol'] + '-' + str_now_date
122
-
123
- try:
124
- real_time_quotes['number'] = number_his
125
-
126
- real_time_quotes = real_time_quotes[order]
127
- mongodb_util.insert_mongo(real_time_quotes, realtime_quotes_db_name)
128
- except Exception as e:
129
- logger.error('保存实时历史数据异常:{}', e)
130
-
131
-
132
- def handle_init_real_time_quotes_data(real_time_quotes_now, str_now_date, number):
133
- # exclude b symbol
134
- real_time_quotes_now = common_service_fun_api.exclude_b_symbol(real_time_quotes_now.copy())
135
- # classification symbol
136
- real_time_quotes_now = common_service_fun_api.classify_symbol(real_time_quotes_now.copy())
137
- # fix industry
138
- real_time_quotes_now = fix_industry_data(real_time_quotes_now.copy())
139
- # calculate parameter
140
- real_time_quotes_now = data_init_api.calculate_parameter_factor(real_time_quotes_now.copy())
141
-
142
- real_time_quotes_now = real_time_quotes_now.loc[real_time_quotes_now['amount'] != 0]
143
- real_time_quotes_now['str_now_date'] = str_now_date
144
- real_time_quotes_now['number'] = number
145
- return real_time_quotes_now
146
-
147
-
148
- # fix 错杀数据 有成交量的数据
149
- def fix_industry_data(real_time_quotes_now):
150
- # fix industry
151
- real_time_quotes_now_r = company_common_service_api.amendment_industry(real_time_quotes_now.copy())
152
-
153
- symbol_list = list(real_time_quotes_now_r['symbol'])
154
-
155
- na_real_now = real_time_quotes_now.loc[
156
- ~(real_time_quotes_now['symbol'].isin(symbol_list))]
157
-
158
- na_real_now = na_real_now.loc[na_real_now['amount'] != 0]
159
-
160
- real_time_quotes_now_result = pd.concat([real_time_quotes_now_r, na_real_now], axis=0)
161
- return real_time_quotes_now_result
162
-
163
-
164
- def sync_realtime_quotes():
165
- # 移除昨日数据
166
- remove_real_time_all_data()
167
-
168
- now_date_init = datetime.datetime.now()
169
- str_day_init = now_date_init.strftime('%Y-%m-%d')
170
- realtime_quotes_db_name = db_name_constant.REAL_TIME_QUOTES_NOW + "_" + str_day_init
171
- number_his = common_service_fun_api.realtime_quotes_now_max_number(realtime_quotes_db_name, 'number')
172
- number_his = number_his + 1
173
- number = common_service_fun_api.realtime_quotes_now_max_number(
174
- db_name_constant.REAL_TIME_QUOTES_NOW + '_' + str_day_init, 'number')
175
- number = number + 1
176
- realtime_quotes_now_create_db_index_api.create_db_index(str_day_init)
177
- while True:
178
- now_date = datetime.datetime.now()
179
-
180
- str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S')
181
- if bool(date_util.is_trade_time(now_date)):
182
- try:
183
- real_time_quotes_now = east_money_stock_api.get_real_time_quotes_all_stocks()
184
- real_time_quotes_now = handle_init_real_time_quotes_data(real_time_quotes_now.copy(),
185
- str_now_date, number)
186
- save_real_time_quotes(real_time_quotes_now.copy(), now_date, db_name_constant.REAL_TIME_QUOTES_NOW,
187
- number)
188
- try:
189
- auto_sell_service_api.auto_sell_stock(real_time_quotes_now.copy())
190
- except Exception as e:
191
- logger.error("自动卖出执行异常:{}", e)
192
- # 集合竞价前同步
193
- if date_util.is_call_auction(str_now_date):
194
- if number % 4 == 0:
195
- save_real_time_quotes_his(real_time_quotes_now.copy(), now_date, realtime_quotes_db_name,
196
- number_his)
197
- number_his = number_his + 1
198
- # 开盘前一个小时同步
199
- elif date_util.is_begin_one_hour(now_date):
200
- save_real_time_quotes_his(real_time_quotes_now.copy(), now_date, realtime_quotes_db_name,
201
- number_his)
202
- number_his = number_his + 1
203
- # 下午同步次数
204
- elif date_util.is_afternoon_time(now_date):
205
- if number % 3 == 0:
206
- save_real_time_quotes_his(real_time_quotes_now.copy(), now_date, realtime_quotes_db_name,
207
- number_his)
208
- number_his = number_his + 1
209
-
210
- else:
211
- # 10:30 到11:30
212
- if number % 2 == 0:
213
- save_real_time_quotes_his(real_time_quotes_now.copy(), now_date, realtime_quotes_db_name,
214
- number_his)
215
- number_his = number_his + 1
216
-
217
- logger.info("同步实时行情信息:{}", number)
218
- number = number + 1
219
-
220
- except Exception as e:
221
- number_his = number_his + 1
222
- number = number + 1
223
- logger.error("获取实时行情信息:{}", e)
224
- elif bool(date_util.is_no_trade_time(now_date)):
225
-
226
- break
227
- else:
228
- time.sleep(1)
229
-
230
-
231
- if __name__ == '__main__':
232
- sync_realtime_quotes()
@@ -1,28 +0,0 @@
1
- import sys
2
- import os
3
-
4
- file_path = os.path.abspath(__file__)
5
- end = file_path.index('mns') + 17
6
- project_path = file_path[0:end]
7
- sys.path.append(project_path)
8
- import mns_scheduler.real_time.realtime_quotes_now_sync as realtime_quotes_now_sync
9
- import mns_scheduler.company_info.clean.company_info_clean_api as company_info_clean_api
10
- from loguru import logger
11
- from apscheduler.schedulers.blocking import BlockingScheduler
12
-
13
-
14
- def sync_realtime_quotes():
15
- logger.error("同步实时数据开始")
16
- # 更新新股公司信息
17
- company_info_clean_api.new_company_info_update()
18
- realtime_quotes_now_sync.sync_realtime_quotes()
19
- logger.error("同步实时数据完成")
20
-
21
-
22
- blockingScheduler = BlockingScheduler()
23
-
24
- # 同步实时数据
25
- blockingScheduler.add_job(sync_realtime_quotes, 'cron', hour='09', minute='20', max_instances=4)
26
-
27
- print('同步实时行情定时任务启动成功')
28
- blockingScheduler.start()