Daniel 1 年之前
父节点
当前提交
a8a611401d
共有 1 个文件被更改,包括 11 次插入7 次删除
  1. 11 7
      QMT/qmt_get_indicators.py

+ 11 - 7
QMT/qmt_get_indicators.py

@@ -15,6 +15,7 @@ import os
 import traceback
 from apscheduler.schedulers.blocking import BlockingScheduler
 import psutil
+import random
 
 pd.set_option('display.max_columns', None)  # 设置显示最大行
 
@@ -223,9 +224,9 @@ def tech_anal(stocks, hlfx_pool, hlfx_pool_daily, err_list):
 
     for stock in stocks:
         engine = create_engine('mysql+pymysql://root:r6kEwqWU9!v3@localhost:3307/qmt_stocks_whole?charset=utf8',
-                               pool_size=1, pool_recycle=7200, max_overflow=1000, pool_timeout=60)
+                               )
         engine_tech = create_engine('mysql+pymysql://root:r6kEwqWU9!v3@localhost:3307/qmt_stocks_tech?charset=utf8',
-                                    pool_size=1, pool_recycle=3600, max_overflow=1000, pool_timeout=60)
+                                    )
         # print(stock)
         try:
             df = pd.read_sql_table('%s_1d' % stock, con=engine.connect())
@@ -280,21 +281,24 @@ def ind():
 
     stocks = xtdata.get_stock_list_in_sector('沪深A股')
     print(len(stocks))
-    stocks.sort()
+    # stocks.sort()
+    random.shuffle(stocks)
+
 
     err_list = mp.Manager().list()
     fre = '1d'
     engine_hlfx_pool = create_engine('mysql+pymysql://root:r6kEwqWU9!v3@localhost:3307/hlfx_pool?charset=utf8',
-                                     pool_size=1, pool_recycle=3600, max_overflow=1000, pool_timeout=60)
+                                     )
     hlfx_pool = mp.Manager().list()
     hlfx_pool_daily = mp.Manager().list()
     hlfx_pool.extend(pd.read_sql_query(
         text("select value from %s" % fre), engine_hlfx_pool.connect()).iloc[-1, 0].split(","))
+    engine_hlfx_pool.dispose()
 
     pool = mp.Pool(processes=int(mp.cpu_count()))
     step = math.ceil(len(stocks) / mp.cpu_count())
-    # pool = mp.Pool(processes=16)
-    # step = math.ceil(len(stocks) / 16)
+    # pool = mp.Pool(processes=18)
+    # step = math.ceil(len(stocks) / 18)
     # step = 10000
     # tech_anal(stocks, hlfx_pool)
     for i in range(0, len(stocks), step):
@@ -303,7 +307,7 @@ def ind():
     time.sleep(5)
     pool.close()
     pool.join()
-    engine_hlfx_pool.dispose()
+    
 
     print(f'当日信号:{len(hlfx_pool_daily)},持续检测为:{len(hlfx_pool)}')
     print(len(err_list), err_list)