mns-scheduler 1.3.3.0__py3-none-any.whl → 1.3.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.
- mns_scheduler/k_line/common/k_line_common_api.py +46 -2
- mns_scheduler/zz_task/data_sync_task.py +8 -5
- {mns_scheduler-1.3.3.0.dist-info → mns_scheduler-1.3.3.2.dist-info}/METADATA +1 -1
- {mns_scheduler-1.3.3.0.dist-info → mns_scheduler-1.3.3.2.dist-info}/RECORD +6 -6
- {mns_scheduler-1.3.3.0.dist-info → mns_scheduler-1.3.3.2.dist-info}/WHEEL +0 -0
- {mns_scheduler-1.3.3.0.dist-info → mns_scheduler-1.3.3.2.dist-info}/top_level.txt +0 -0
|
@@ -18,6 +18,7 @@ import mns_common.api.msg.push_msg_api as push_msg_api
|
|
|
18
18
|
import numpy as np
|
|
19
19
|
import mns_common.utils.data_frame_util as data_frame_util
|
|
20
20
|
from loguru import logger
|
|
21
|
+
import threading
|
|
21
22
|
|
|
22
23
|
# source_type = 'xue_qiu'
|
|
23
24
|
source_type = 'xue_qiu'
|
|
@@ -29,14 +30,57 @@ def custom_alert(current: int, threshold: int):
|
|
|
29
30
|
push_msg_api.push_msg_to_wechat('获取k线数据异常', "当前次数:" + str(current) + "阈值:" + str(threshold))
|
|
30
31
|
|
|
31
32
|
|
|
33
|
+
# 定义一个带超时的函数调用
|
|
34
|
+
def call_with_timeout(func, *args, timeout=10, **kwargs):
|
|
35
|
+
# 用于存储函数执行结果
|
|
36
|
+
result = None
|
|
37
|
+
exception = None
|
|
38
|
+
|
|
39
|
+
# 定义一个线程目标函数
|
|
40
|
+
def target():
|
|
41
|
+
nonlocal result, exception
|
|
42
|
+
try:
|
|
43
|
+
result = func(*args, **kwargs)
|
|
44
|
+
except Exception as e:
|
|
45
|
+
exception = e
|
|
46
|
+
|
|
47
|
+
# 创建线程并启动
|
|
48
|
+
thread = threading.Thread(target=target)
|
|
49
|
+
thread.start()
|
|
50
|
+
|
|
51
|
+
# 等待线程完成,最多等待 timeout 秒
|
|
52
|
+
thread.join(timeout)
|
|
53
|
+
|
|
54
|
+
# 如果线程仍然存活,说明函数超时了
|
|
55
|
+
if thread.is_alive():
|
|
56
|
+
raise TimeoutError(f"Function exceeded timeout of {timeout} seconds")
|
|
57
|
+
|
|
58
|
+
# 如果函数抛出了异常,重新抛出
|
|
59
|
+
if exception is not None:
|
|
60
|
+
raise exception
|
|
61
|
+
return result
|
|
62
|
+
|
|
63
|
+
|
|
32
64
|
def get_k_line_common_adapter(symbol, period, hq, end_date):
|
|
33
65
|
global error_no
|
|
34
66
|
df = pd.DataFrame()
|
|
35
67
|
try:
|
|
36
68
|
if source_type == 'em':
|
|
37
|
-
|
|
69
|
+
|
|
70
|
+
df = call_with_timeout(get_em_k_line_api,
|
|
71
|
+
symbol,
|
|
72
|
+
period,
|
|
73
|
+
hq,
|
|
74
|
+
end_date,
|
|
75
|
+
timeout=10)
|
|
38
76
|
elif source_type == 'xue_qiu':
|
|
39
|
-
df = get_xueqiu_k_line_api
|
|
77
|
+
df = call_with_timeout(get_xueqiu_k_line_api,
|
|
78
|
+
symbol,
|
|
79
|
+
period,
|
|
80
|
+
hq,
|
|
81
|
+
end_date,
|
|
82
|
+
timeout=10)
|
|
83
|
+
|
|
40
84
|
if data_frame_util.is_empty(df):
|
|
41
85
|
error_no = error_no + 1
|
|
42
86
|
except BaseException as e:
|
|
@@ -184,7 +184,11 @@ def generate_new_day_k_line_info():
|
|
|
184
184
|
now_date = datetime.now()
|
|
185
185
|
str_day = now_date.strftime('%Y-%m-%d')
|
|
186
186
|
# 生成下一个交易日日期k线数据 number=2 获取下一个交易日 日期
|
|
187
|
-
|
|
187
|
+
if trade_date_common_service_api.is_trade_day(str_day):
|
|
188
|
+
dis_number = 2
|
|
189
|
+
else:
|
|
190
|
+
dis_number = 1
|
|
191
|
+
next_trade_day = trade_date_common_service_api.get_further_trade_date(str_day, dis_number)
|
|
188
192
|
k_line_info_clean_service.sync_k_line_info_task(next_trade_day)
|
|
189
193
|
logger.info('计算当日k线信息完成:{}', str_day)
|
|
190
194
|
|
|
@@ -562,8 +566,7 @@ blockingScheduler.add_job(sync_all_kpl_plate_info, 'interval', minutes=5, max_in
|
|
|
562
566
|
# blockingScheduler.add_job(sync_company_announce, 'cron', hour='07,18,23', minute='33')
|
|
563
567
|
|
|
564
568
|
print('定时任务启动成功')
|
|
565
|
-
blockingScheduler.start()
|
|
566
|
-
#
|
|
567
|
-
# if __name__ == '__main__':
|
|
569
|
+
# blockingScheduler.start()
|
|
568
570
|
#
|
|
569
|
-
|
|
571
|
+
if __name__ == '__main__':
|
|
572
|
+
generate_new_day_k_line_info()
|
|
@@ -79,7 +79,7 @@ mns_scheduler/k_line/clean/week_month/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3
|
|
|
79
79
|
mns_scheduler/k_line/clean/week_month/normal_week_month_k_line_service.py,sha256=n2osY8dozHClIlSOE7NR6S_oK_8GV-z72Az13D3fhCQ,10160
|
|
80
80
|
mns_scheduler/k_line/clean/week_month/sub_new_week_month_k_line_service.py,sha256=0rc2Rz_EoqoqpVvgPe4daCe09JtHBlJsQr1bMIlBQ2o,5526
|
|
81
81
|
mns_scheduler/k_line/common/__init__.py,sha256=itoGlqKhsx7EVXQoD1vchDKQ5GPB16vDjofTSuQtrXg,161
|
|
82
|
-
mns_scheduler/k_line/common/k_line_common_api.py,sha256=
|
|
82
|
+
mns_scheduler/k_line/common/k_line_common_api.py,sha256=9ep7-NyI_x2a1onTlmPg-R4VNx3yZ-IBQuhu1HgcBbM,7120
|
|
83
83
|
mns_scheduler/k_line/hot_stocks/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
84
84
|
mns_scheduler/k_line/hot_stocks/recent_hot_stocks_clean_service.py,sha256=8woZzGVORYX9KZr6xtfiYYgApDKissnzYM6hS2k6XBA,2628
|
|
85
85
|
mns_scheduler/k_line/month_week_daily/__init__.py,sha256=ffZXFCLFdIwOsbxnw__u1MbQYh9yz7Bs8UMP6VF0X2M,161
|
|
@@ -155,8 +155,8 @@ mns_scheduler/zt/zt_pool/em_zt_pool_sync_api.py,sha256=LOEUyTA5g7N6FWxUpHWimWTeX
|
|
|
155
155
|
mns_scheduler/zt/zt_pool/ths_zt_pool_sync_api.py,sha256=9Sv1G88poLG3_8aLPkfr8bdwD_AzbSrwvHTGPErOtQU,7501
|
|
156
156
|
mns_scheduler/zt/zt_pool/update_null_zt_reason_api.py,sha256=caW-MuF0RFLavJZafeLDYQ29-GxwGsmr5YVrN4lost8,2135
|
|
157
157
|
mns_scheduler/zz_task/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
158
|
-
mns_scheduler/zz_task/data_sync_task.py,sha256=
|
|
159
|
-
mns_scheduler-1.3.3.
|
|
160
|
-
mns_scheduler-1.3.3.
|
|
161
|
-
mns_scheduler-1.3.3.
|
|
162
|
-
mns_scheduler-1.3.3.
|
|
158
|
+
mns_scheduler/zz_task/data_sync_task.py,sha256=a5N2w2nW88ce_4mvtirqI22ure_kQYqMecExm-EUT3w,23282
|
|
159
|
+
mns_scheduler-1.3.3.2.dist-info/METADATA,sha256=LGOD9tcHJ6CTKNn1y7JZCb_OhEf2zBtChVS4o6LNr6M,64
|
|
160
|
+
mns_scheduler-1.3.3.2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
161
|
+
mns_scheduler-1.3.3.2.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
|
|
162
|
+
mns_scheduler-1.3.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|