|
@@ -17,6 +17,7 @@ import os
|
|
|
import psutil
|
|
|
import traceback
|
|
|
from apscheduler.schedulers.blocking import BlockingScheduler
|
|
|
+import gc
|
|
|
|
|
|
#原始版本
|
|
|
|
|
@@ -29,6 +30,7 @@ pd.set_option('display.max_columns', None) # 设置显示最大行
|
|
|
fre = '1d'
|
|
|
|
|
|
def run(seq):
|
|
|
+ print('seq=', seq)
|
|
|
'''阻塞线程接收行情回调'''
|
|
|
import time
|
|
|
client = xtdata.get_client()
|
|
@@ -267,10 +269,13 @@ def hlfx(data):
|
|
|
cursor_pool.execute(sql)
|
|
|
db_pool.commit()
|
|
|
print(f'{dt.now()}写入新的results{len(results_list)}个,hlfx_pool更新')
|
|
|
+ del df_day
|
|
|
+ gc.collect()
|
|
|
engine_hlfx_pool.dispose()
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
def bridge(list):
|
|
|
print(f'MyPid is {os.getpid()}, now is {dt.now()},我需要负责{len(list)}个个股数据')
|
|
|
seq = xtdata.subscribe_whole_quote(list, callback=hlfx)
|
|
@@ -281,7 +286,7 @@ def prepare():
|
|
|
stocks = xtdata.get_stock_list_in_sector('沪深A股')
|
|
|
|
|
|
cpu_count = 4
|
|
|
- pool = mp.Pool(processes=cpu_count, maxtasksperchild=8)
|
|
|
+ pool = mp.Pool(processes=cpu_count, maxtasksperchild=4)
|
|
|
step = math.ceil(len(stocks) / cpu_count)
|
|
|
to_hlfx_list = []
|
|
|
|
|
@@ -319,7 +324,7 @@ if __name__ == '__main__':
|
|
|
print('对交易回调进行订阅,订阅后可以收到交易主推,返回0表示订阅成功', subscribe_result)
|
|
|
|
|
|
scheduler = BlockingScheduler()
|
|
|
- scheduler.add_job(func=prepare, trigger='cron', day_of_week='0-4', hour='9', minute='25',
|
|
|
+ scheduler.add_job(func=prepare, trigger='cron', day_of_week='0-4', hour='14', minute='51',
|
|
|
timezone="Asia/Shanghai")
|
|
|
try:
|
|
|
scheduler.start()
|