This commit is contained in:
2026-09-01 15:49:09 +08:00
parent 556e21d624
commit 66ccd42d4e
10 changed files with 31 additions and 32 deletions

View File

@@ -32,7 +32,7 @@ class DipWatch:
) -> bool:
"""更新观察价格;达到反弹阈值时返回 ``True``。"""
if price <= 0:
log.warning("[%s观察] %s 价格无效:%.2f", tag, code, price)
log.warning("[%s Watch] %s 价格无效:%.2f", tag, code, price)
return False
current = now or datetime.now()
@@ -42,24 +42,23 @@ class DipWatch:
if watch is None:
self._start(code, price, current)
log.info(
"[%s观察] %s 开始观察,收盘价=%.2f,反弹阈值=%.2f%%",
"[%s Watch] %s 开始观察,收盘价=%.2f",
tag,
code,
price,
self.rebound_threshold,
)
return False
if current >= watch.expires_at:
self._start(code, price, current)
log.info("[%s观察] %s 观察已过期,重新观察,收盘价=%.2f", tag, code, price)
log.info("[%sWatch] %s 观察已过期,重新观察,收盘价=%.2f", tag, code, price)
return False
if price < watch.last_close:
old_price = watch.last_close
self._start(code, price, current)
log.info(
"[%s观察] %s 刷新低点,原收盘价=%.2f,新收盘价=%.2f",
"[%s Watch] %s 刷新低点,原收盘价=%.2f,新收盘价=%.2f",
tag,
code,
old_price,
@@ -70,7 +69,7 @@ class DipWatch:
rebound = (price - watch.last_close) / watch.last_close * 100
if rebound < self.rebound_threshold:
log.debug(
"[%s观察] %s 等待反弹,收盘价=%.2f,现价=%.2f,反弹=%.2f%%,阈值=%.2f%%",
"[%s Watch] %s 等待反弹,收盘价=%.2f,现价=%.2f,反弹=%.2f%%,阈值=%.2f%%",
tag,
code,
watch.last_close,
@@ -82,7 +81,7 @@ class DipWatch:
del self.data[code]
log.info(
"[%s观察] %s 反弹触发,收盘价=%.2f,现价=%.2f,反弹=%.2f%%",
"[%s Watch] %s 反弹触发,收盘价=%.2f,现价=%.2f,反弹=%.2f%%",
tag,
code,
watch.last_close,
@@ -96,7 +95,7 @@ class DipWatch:
with self.lock:
removed = self.data.pop(code, None)
if removed is not None:
log.info("[价格观察] %s 已清除观察状态", code)
log.info("[Watch] %s 已清除观察状态", code)
def _start(self, code: str, price: float, now: datetime) -> None:
self.data[code] = _Entry(