fix: 宇宙三级兜底(资金流活跃股) + 评分启动即跑
This commit is contained in:
+12
-5
@@ -66,14 +66,21 @@ class QuantEngine:
|
||||
return [c for c, _ in pairs], dict(pairs)
|
||||
except Exception as e:
|
||||
print('[quant] 东财宇宙失败:', e, flush=True)
|
||||
# 3) 兜底:资金流表中的活跃股
|
||||
# 3) 兜底:资金流表中的活跃股(当日有资金流的股票即活跃宇宙)
|
||||
try:
|
||||
conn = self.fetcher._conn()
|
||||
try:
|
||||
rows = conn.execute("SELECT DISTINCT ts_code FROM money_flow LIMIT ?",
|
||||
(n,)).fetchall()
|
||||
return [r[0] for r in rows], {}
|
||||
rows = conn.execute("SELECT DISTINCT ts_code FROM money_flow "
|
||||
"ORDER BY trade_date DESC LIMIT ?", (n,)).fetchall()
|
||||
finally:
|
||||
pass
|
||||
conn.close()
|
||||
codes = [r[0] for r in rows]
|
||||
if codes:
|
||||
print('[quant] 宇宙兜底: 资金流活跃股 {} 只'.format(len(codes)), flush=True)
|
||||
return codes, {}
|
||||
except Exception as e:
|
||||
print('[quant] 资金流兜底失败:', e, flush=True)
|
||||
return [], {}
|
||||
|
||||
def _kline_count(self, tf):
|
||||
import sqlite3
|
||||
|
||||
+2
-2
@@ -70,13 +70,13 @@ async def collector_task(_app):
|
||||
quant.start()
|
||||
|
||||
def _quant_loops():
|
||||
time.sleep(5) # 启动即先跑一轮打分(K线可能不足,引擎会自行跳过)
|
||||
while True:
|
||||
try:
|
||||
time.sleep(SCORING_INTERVAL_S)
|
||||
quant.run_scoring_and_push()
|
||||
except Exception as e:
|
||||
print('[quant-loop]', e, flush=True)
|
||||
time.sleep(60)
|
||||
time.sleep(SCORING_INTERVAL_S)
|
||||
|
||||
threading.Thread(target=_quant_loops, daemon=True, name='quant-scoring').start()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user