scheduler: auto-detect new signals once per day, deduplicate existing

- scheduler tick runs detect after fetch+score (once per UTC day)
- ChanSignalDetector skips already-recorded signals
- Prevents duplicate signal_features entries on repeated runs
This commit is contained in:
jackyu66git
2026-06-24 19:19:40 +08:00
parent 3c72aa1310
commit 7b91f459d7
2 changed files with 35 additions and 3 deletions
+17 -1
View File
@@ -115,7 +115,23 @@ class MacroScheduler:
conn.commit()
conn.close()
self._last_run = datetime.now(timezone.utc)
# 检测新信号(每天运行一次,UTC 0 点后首次触发)
now = datetime.now(timezone.utc)
if self._last_run is None or now.date() > self._last_run.date():
try:
from chan_integration import ChanSignalDetector
detector = ChanSignalDetector()
# 检测最近 90 天的 4h 信号
count = detector.populate_signal_features(
start_date=(today - __import__('datetime').timedelta(days=90)).isoformat(),
end_date=today.isoformat(),
)
if count > 0:
logger.info(f"新增 {count} 条信号记录")
except Exception as e:
logger.debug(f"信号检测跳过: {e}")
self._last_run = now
logger.info(
f"Tick 完成: regime={r.regime.value} conf={r.confidence:.2f} "
f"breadth={br.score:.0f}({br.breadth_bucket.value}) "